@@ -10,294 +10,294 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | trait MessagesAdmin |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 15 | - * a string. |
|
| 16 | - */ |
|
| 17 | - public function amOnMessagesActivityListTablePage($additional_params = '') |
|
| 18 | - { |
|
| 19 | - $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params)); |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 24 | - * a string. |
|
| 25 | - */ |
|
| 26 | - public function amOnDefaultMessageTemplateListTablePage($additional_params = '') |
|
| 27 | - { |
|
| 28 | - $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params)); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 34 | - * a string. |
|
| 35 | - */ |
|
| 36 | - public function amOnCustomMessageTemplateListTablePage($additional_params = '') |
|
| 37 | - { |
|
| 38 | - $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params)); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Directs to message settings page |
|
| 44 | - */ |
|
| 45 | - public function amOnMessageSettingsPage() |
|
| 46 | - { |
|
| 47 | - $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl()); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email') |
|
| 52 | - { |
|
| 53 | - $this->actor()->dragAndDrop( |
|
| 54 | - MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug), |
|
| 55 | - MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR |
|
| 56 | - ); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Assumes you are already on the list table page that has the ui for editing the template. |
|
| 62 | - * @param string $message_type_slug |
|
| 63 | - * @param string $context [optional] if you want to click directly to the given context in the editor |
|
| 64 | - */ |
|
| 65 | - public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '') |
|
| 66 | - { |
|
| 67 | - $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context)); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Use this action to verify that the count for the given text in the specified field is as expected. For example |
|
| 73 | - * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column. |
|
| 74 | - * |
|
| 75 | - * @param int $expected_occurence_count |
|
| 76 | - * @param string $text_to_check_for |
|
| 77 | - * @param string $field |
|
| 78 | - * @param string $message_type_label |
|
| 79 | - * @param string $message_status |
|
| 80 | - * @param string $messenger |
|
| 81 | - * @param string $context |
|
| 82 | - */ |
|
| 83 | - public function verifyMatchingCountofTextInMessageActivityListTableFor( |
|
| 84 | - $expected_occurence_count, |
|
| 85 | - $text_to_check_for, |
|
| 86 | - $field, |
|
| 87 | - $message_type_label, |
|
| 88 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
| 89 | - $messenger = 'Email', |
|
| 90 | - $context = 'Event Admin' |
|
| 91 | - ) { |
|
| 92 | - $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor( |
|
| 93 | - $field, |
|
| 94 | - $message_type_label, |
|
| 95 | - $message_status, |
|
| 96 | - $messenger, |
|
| 97 | - $context, |
|
| 98 | - $text_to_check_for, |
|
| 99 | - 0 |
|
| 100 | - )); |
|
| 101 | - $actual_count = count($elements); |
|
| 102 | - $this->actor()->assertEquals( |
|
| 103 | - $expected_occurence_count, |
|
| 104 | - $actual_count, |
|
| 105 | - sprintf( |
|
| 106 | - 'Expected %s of the %s text for the %s field but there were actually %s counted.', |
|
| 107 | - $expected_occurence_count, |
|
| 108 | - $text_to_check_for, |
|
| 109 | - $field, |
|
| 110 | - $actual_count |
|
| 111 | - ) |
|
| 112 | - ); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * This will create a custom message template for the given messenger and message type from the context of the |
|
| 118 | - * default (global) message template list table. |
|
| 119 | - * Also takes care of verifying the template was created. |
|
| 120 | - * @param string $message_type_label |
|
| 121 | - * @param string $messenger_label |
|
| 122 | - */ |
|
| 123 | - public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label) |
|
| 124 | - { |
|
| 125 | - $this->amOnDefaultMessageTemplateListTablePage(); |
|
| 126 | - $this->actor()->click( |
|
| 127 | - MessagesPage::createCustomButtonForMessageTypeAndMessenger( |
|
| 128 | - $message_type_label, |
|
| 129 | - $messenger_label |
|
| 130 | - ) |
|
| 131 | - ); |
|
| 132 | - $this->actor()->seeInField('#title', 'New Custom Template'); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * This switches the context of the current messages template to the given reference. |
|
| 138 | - * @param string $context_reference This should be the visible label for the option. |
|
| 139 | - */ |
|
| 140 | - public function switchContextTo($context_reference) |
|
| 141 | - { |
|
| 142 | - $this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference); |
|
| 143 | - $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR); |
|
| 144 | - $this->actor()->waitForText($context_reference, 10, 'h1'); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * Toggles Context so its turned off or on (depending on where it started) and verifies the expected state after |
|
| 150 | - * toggling. |
|
| 151 | - * |
|
| 152 | - * @param string $context_string What context is being switched (used for the expected state text) |
|
| 153 | - * @param bool $expected_state_is_active Used to indicate whether the expected state is active (true) or inactive |
|
| 154 | - * (false) |
|
| 155 | - */ |
|
| 156 | - public function toggleContextState($context_string, $expected_state_is_active = true) |
|
| 157 | - { |
|
| 158 | - $this->actor()->scrollTo(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR); |
|
| 159 | - $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE); |
|
| 160 | - if ($expected_state_is_active) { |
|
| 161 | - $this->actor()->waitForText("The template for $context_string is currently active."); |
|
| 162 | - } else { |
|
| 163 | - $this->actor()->waitForText("The template for $context_string is currently inactive"); |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Triggers saving the message template. |
|
| 170 | - * @param bool $and_close Use to indicate to click the Save and Close button. |
|
| 171 | - */ |
|
| 172 | - public function saveMessageTemplate($and_close = false) |
|
| 173 | - { |
|
| 174 | - $this->actor()->scrollTo(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR); |
|
| 175 | - if ($and_close) { |
|
| 176 | - $this->actor()->click('Save and Close'); |
|
| 177 | - } else { |
|
| 178 | - $this->actor()->click('Save'); |
|
| 179 | - } |
|
| 180 | - $this->actor()->waitForText('successfully updated'); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * This takes care of clicking the View Message icon for the given parameters. |
|
| 186 | - * Assumes you are already viewing the messages activity list table. |
|
| 187 | - * @param $message_type_label |
|
| 188 | - * @param $message_status |
|
| 189 | - * @param string $messenger |
|
| 190 | - * @param string $context |
|
| 191 | - * @param int $number_in_set |
|
| 192 | - */ |
|
| 193 | - public function viewMessageInMessagesListTableFor( |
|
| 194 | - $message_type_label, |
|
| 195 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
| 196 | - $messenger = 'Email', |
|
| 197 | - $context = 'Event Admin', |
|
| 198 | - $number_in_set = 1 |
|
| 199 | - ) { |
|
| 200 | - $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor( |
|
| 201 | - $message_type_label, |
|
| 202 | - $message_status, |
|
| 203 | - $messenger, |
|
| 204 | - $context, |
|
| 205 | - $number_in_set |
|
| 206 | - )); |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * Takes care of deleting a message matching the given parameters via the message activity list table. |
|
| 212 | - * Assumes you are already viewing the messages activity list table. |
|
| 213 | - * @param $message_type_label |
|
| 214 | - * @param $message_status |
|
| 215 | - * @param string $messenger |
|
| 216 | - * @param string $context |
|
| 217 | - * @param int $number_in_set |
|
| 218 | - */ |
|
| 219 | - public function deleteMessageInMessagesListTableFor( |
|
| 220 | - $message_type_label, |
|
| 221 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
| 222 | - $messenger = 'Email', |
|
| 223 | - $context = 'Event Admin', |
|
| 224 | - $number_in_set = 1 |
|
| 225 | - ) { |
|
| 226 | - $delete_action_selector = MessagesPage::messagesActivityListTableDeleteActionSelectorFor( |
|
| 227 | - $message_type_label, |
|
| 228 | - $message_status, |
|
| 229 | - $messenger, |
|
| 230 | - $context, |
|
| 231 | - $number_in_set |
|
| 232 | - ); |
|
| 233 | - $cell_selector = MessagesPage::messagesActivityListTableCellSelectorFor( |
|
| 234 | - 'to', |
|
| 235 | - $message_type_label, |
|
| 236 | - $message_status, |
|
| 237 | - $messenger, |
|
| 238 | - $context, |
|
| 239 | - '', |
|
| 240 | - $number_in_set |
|
| 241 | - ); |
|
| 242 | - $this->actor()->scrollTo($cell_selector, 0, -30); |
|
| 243 | - $this->actor()->moveMouseOver( |
|
| 244 | - $cell_selector, |
|
| 245 | - 5, |
|
| 246 | - 5 |
|
| 247 | - ); |
|
| 248 | - $this->actor()->waitForElementVisible( |
|
| 249 | - $delete_action_selector |
|
| 250 | - ); |
|
| 251 | - $this->actor()->click( |
|
| 252 | - $delete_action_selector |
|
| 253 | - ); |
|
| 254 | - $this->actor()->waitForText('successfully deleted', 20); |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
| 260 | - * list table, this will take care of validating the given text is in that window. |
|
| 261 | - * @param string $text_to_view |
|
| 262 | - */ |
|
| 263 | - public function seeTextInViewMessageModal($text_to_view, $should_not_see = false) |
|
| 264 | - { |
|
| 265 | - $this->actor()->wait(2); |
|
| 266 | - $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
| 267 | - $this->actor()->switchToIframe('message-view-window'); |
|
| 268 | - $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view); |
|
| 269 | - $this->actor()->switchToIframe(); |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - |
|
| 273 | - /** |
|
| 274 | - * This returns the value for the link at the given selector in the message modal. |
|
| 275 | - * @param string $selector (any selector string accepted by WebDriver) |
|
| 276 | - */ |
|
| 277 | - public function observeLinkAtSelectorInMessageModal($selector) |
|
| 278 | - { |
|
| 279 | - $this->actor()->wait(2); |
|
| 280 | - $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
| 281 | - $this->actor()->switchToIframe('message-view-window'); |
|
| 282 | - $link = $this->actor()->observeLinkUrlAt($selector); |
|
| 283 | - $this->actor()->switchToIframe(); |
|
| 284 | - return $link; |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
| 290 | - * list table, this will take care of validating the given text is NOT that window. |
|
| 291 | - * @param string $text_to_view |
|
| 292 | - */ |
|
| 293 | - public function dontSeeTextInViewMessageModal($text_to_view) |
|
| 294 | - { |
|
| 295 | - $this->seeTextInViewMessageModal($text_to_view, true); |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - |
|
| 299 | - public function dismissMessageModal() |
|
| 300 | - { |
|
| 301 | - $this->actor()->executeJs('window.dialogHelper.closeModal()'); |
|
| 302 | - } |
|
| 13 | + /** |
|
| 14 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 15 | + * a string. |
|
| 16 | + */ |
|
| 17 | + public function amOnMessagesActivityListTablePage($additional_params = '') |
|
| 18 | + { |
|
| 19 | + $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params)); |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 24 | + * a string. |
|
| 25 | + */ |
|
| 26 | + public function amOnDefaultMessageTemplateListTablePage($additional_params = '') |
|
| 27 | + { |
|
| 28 | + $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params)); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 34 | + * a string. |
|
| 35 | + */ |
|
| 36 | + public function amOnCustomMessageTemplateListTablePage($additional_params = '') |
|
| 37 | + { |
|
| 38 | + $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params)); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Directs to message settings page |
|
| 44 | + */ |
|
| 45 | + public function amOnMessageSettingsPage() |
|
| 46 | + { |
|
| 47 | + $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl()); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email') |
|
| 52 | + { |
|
| 53 | + $this->actor()->dragAndDrop( |
|
| 54 | + MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug), |
|
| 55 | + MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR |
|
| 56 | + ); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Assumes you are already on the list table page that has the ui for editing the template. |
|
| 62 | + * @param string $message_type_slug |
|
| 63 | + * @param string $context [optional] if you want to click directly to the given context in the editor |
|
| 64 | + */ |
|
| 65 | + public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '') |
|
| 66 | + { |
|
| 67 | + $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context)); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Use this action to verify that the count for the given text in the specified field is as expected. For example |
|
| 73 | + * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column. |
|
| 74 | + * |
|
| 75 | + * @param int $expected_occurence_count |
|
| 76 | + * @param string $text_to_check_for |
|
| 77 | + * @param string $field |
|
| 78 | + * @param string $message_type_label |
|
| 79 | + * @param string $message_status |
|
| 80 | + * @param string $messenger |
|
| 81 | + * @param string $context |
|
| 82 | + */ |
|
| 83 | + public function verifyMatchingCountofTextInMessageActivityListTableFor( |
|
| 84 | + $expected_occurence_count, |
|
| 85 | + $text_to_check_for, |
|
| 86 | + $field, |
|
| 87 | + $message_type_label, |
|
| 88 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
| 89 | + $messenger = 'Email', |
|
| 90 | + $context = 'Event Admin' |
|
| 91 | + ) { |
|
| 92 | + $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor( |
|
| 93 | + $field, |
|
| 94 | + $message_type_label, |
|
| 95 | + $message_status, |
|
| 96 | + $messenger, |
|
| 97 | + $context, |
|
| 98 | + $text_to_check_for, |
|
| 99 | + 0 |
|
| 100 | + )); |
|
| 101 | + $actual_count = count($elements); |
|
| 102 | + $this->actor()->assertEquals( |
|
| 103 | + $expected_occurence_count, |
|
| 104 | + $actual_count, |
|
| 105 | + sprintf( |
|
| 106 | + 'Expected %s of the %s text for the %s field but there were actually %s counted.', |
|
| 107 | + $expected_occurence_count, |
|
| 108 | + $text_to_check_for, |
|
| 109 | + $field, |
|
| 110 | + $actual_count |
|
| 111 | + ) |
|
| 112 | + ); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * This will create a custom message template for the given messenger and message type from the context of the |
|
| 118 | + * default (global) message template list table. |
|
| 119 | + * Also takes care of verifying the template was created. |
|
| 120 | + * @param string $message_type_label |
|
| 121 | + * @param string $messenger_label |
|
| 122 | + */ |
|
| 123 | + public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label) |
|
| 124 | + { |
|
| 125 | + $this->amOnDefaultMessageTemplateListTablePage(); |
|
| 126 | + $this->actor()->click( |
|
| 127 | + MessagesPage::createCustomButtonForMessageTypeAndMessenger( |
|
| 128 | + $message_type_label, |
|
| 129 | + $messenger_label |
|
| 130 | + ) |
|
| 131 | + ); |
|
| 132 | + $this->actor()->seeInField('#title', 'New Custom Template'); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * This switches the context of the current messages template to the given reference. |
|
| 138 | + * @param string $context_reference This should be the visible label for the option. |
|
| 139 | + */ |
|
| 140 | + public function switchContextTo($context_reference) |
|
| 141 | + { |
|
| 142 | + $this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference); |
|
| 143 | + $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR); |
|
| 144 | + $this->actor()->waitForText($context_reference, 10, 'h1'); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * Toggles Context so its turned off or on (depending on where it started) and verifies the expected state after |
|
| 150 | + * toggling. |
|
| 151 | + * |
|
| 152 | + * @param string $context_string What context is being switched (used for the expected state text) |
|
| 153 | + * @param bool $expected_state_is_active Used to indicate whether the expected state is active (true) or inactive |
|
| 154 | + * (false) |
|
| 155 | + */ |
|
| 156 | + public function toggleContextState($context_string, $expected_state_is_active = true) |
|
| 157 | + { |
|
| 158 | + $this->actor()->scrollTo(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR); |
|
| 159 | + $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE); |
|
| 160 | + if ($expected_state_is_active) { |
|
| 161 | + $this->actor()->waitForText("The template for $context_string is currently active."); |
|
| 162 | + } else { |
|
| 163 | + $this->actor()->waitForText("The template for $context_string is currently inactive"); |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Triggers saving the message template. |
|
| 170 | + * @param bool $and_close Use to indicate to click the Save and Close button. |
|
| 171 | + */ |
|
| 172 | + public function saveMessageTemplate($and_close = false) |
|
| 173 | + { |
|
| 174 | + $this->actor()->scrollTo(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR); |
|
| 175 | + if ($and_close) { |
|
| 176 | + $this->actor()->click('Save and Close'); |
|
| 177 | + } else { |
|
| 178 | + $this->actor()->click('Save'); |
|
| 179 | + } |
|
| 180 | + $this->actor()->waitForText('successfully updated'); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * This takes care of clicking the View Message icon for the given parameters. |
|
| 186 | + * Assumes you are already viewing the messages activity list table. |
|
| 187 | + * @param $message_type_label |
|
| 188 | + * @param $message_status |
|
| 189 | + * @param string $messenger |
|
| 190 | + * @param string $context |
|
| 191 | + * @param int $number_in_set |
|
| 192 | + */ |
|
| 193 | + public function viewMessageInMessagesListTableFor( |
|
| 194 | + $message_type_label, |
|
| 195 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
| 196 | + $messenger = 'Email', |
|
| 197 | + $context = 'Event Admin', |
|
| 198 | + $number_in_set = 1 |
|
| 199 | + ) { |
|
| 200 | + $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor( |
|
| 201 | + $message_type_label, |
|
| 202 | + $message_status, |
|
| 203 | + $messenger, |
|
| 204 | + $context, |
|
| 205 | + $number_in_set |
|
| 206 | + )); |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * Takes care of deleting a message matching the given parameters via the message activity list table. |
|
| 212 | + * Assumes you are already viewing the messages activity list table. |
|
| 213 | + * @param $message_type_label |
|
| 214 | + * @param $message_status |
|
| 215 | + * @param string $messenger |
|
| 216 | + * @param string $context |
|
| 217 | + * @param int $number_in_set |
|
| 218 | + */ |
|
| 219 | + public function deleteMessageInMessagesListTableFor( |
|
| 220 | + $message_type_label, |
|
| 221 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
| 222 | + $messenger = 'Email', |
|
| 223 | + $context = 'Event Admin', |
|
| 224 | + $number_in_set = 1 |
|
| 225 | + ) { |
|
| 226 | + $delete_action_selector = MessagesPage::messagesActivityListTableDeleteActionSelectorFor( |
|
| 227 | + $message_type_label, |
|
| 228 | + $message_status, |
|
| 229 | + $messenger, |
|
| 230 | + $context, |
|
| 231 | + $number_in_set |
|
| 232 | + ); |
|
| 233 | + $cell_selector = MessagesPage::messagesActivityListTableCellSelectorFor( |
|
| 234 | + 'to', |
|
| 235 | + $message_type_label, |
|
| 236 | + $message_status, |
|
| 237 | + $messenger, |
|
| 238 | + $context, |
|
| 239 | + '', |
|
| 240 | + $number_in_set |
|
| 241 | + ); |
|
| 242 | + $this->actor()->scrollTo($cell_selector, 0, -30); |
|
| 243 | + $this->actor()->moveMouseOver( |
|
| 244 | + $cell_selector, |
|
| 245 | + 5, |
|
| 246 | + 5 |
|
| 247 | + ); |
|
| 248 | + $this->actor()->waitForElementVisible( |
|
| 249 | + $delete_action_selector |
|
| 250 | + ); |
|
| 251 | + $this->actor()->click( |
|
| 252 | + $delete_action_selector |
|
| 253 | + ); |
|
| 254 | + $this->actor()->waitForText('successfully deleted', 20); |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
| 260 | + * list table, this will take care of validating the given text is in that window. |
|
| 261 | + * @param string $text_to_view |
|
| 262 | + */ |
|
| 263 | + public function seeTextInViewMessageModal($text_to_view, $should_not_see = false) |
|
| 264 | + { |
|
| 265 | + $this->actor()->wait(2); |
|
| 266 | + $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
| 267 | + $this->actor()->switchToIframe('message-view-window'); |
|
| 268 | + $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view); |
|
| 269 | + $this->actor()->switchToIframe(); |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + |
|
| 273 | + /** |
|
| 274 | + * This returns the value for the link at the given selector in the message modal. |
|
| 275 | + * @param string $selector (any selector string accepted by WebDriver) |
|
| 276 | + */ |
|
| 277 | + public function observeLinkAtSelectorInMessageModal($selector) |
|
| 278 | + { |
|
| 279 | + $this->actor()->wait(2); |
|
| 280 | + $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
| 281 | + $this->actor()->switchToIframe('message-view-window'); |
|
| 282 | + $link = $this->actor()->observeLinkUrlAt($selector); |
|
| 283 | + $this->actor()->switchToIframe(); |
|
| 284 | + return $link; |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
| 290 | + * list table, this will take care of validating the given text is NOT that window. |
|
| 291 | + * @param string $text_to_view |
|
| 292 | + */ |
|
| 293 | + public function dontSeeTextInViewMessageModal($text_to_view) |
|
| 294 | + { |
|
| 295 | + $this->seeTextInViewMessageModal($text_to_view, true); |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + |
|
| 299 | + public function dismissMessageModal() |
|
| 300 | + { |
|
| 301 | + $this->actor()->executeJs('window.dialogHelper.closeModal()'); |
|
| 302 | + } |
|
| 303 | 303 | } |
@@ -16,24 +16,24 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class AssetRegistrationException extends RuntimeException |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * @param $script_handle |
|
| 21 | - * @param string $message |
|
| 22 | - * @param int $code |
|
| 23 | - * @param Exception|null $previous |
|
| 24 | - */ |
|
| 25 | - public function __construct($script_handle, $message = '', $code = 0, Exception $previous = null) |
|
| 26 | - { |
|
| 27 | - if (empty($message)) { |
|
| 28 | - $message = sprintf( |
|
| 29 | - esc_html_x( |
|
| 30 | - 'The "%1$s" script could not be registered with WordPress core.', |
|
| 31 | - 'The "script-handle" script could not be registered with WordPress core.', |
|
| 32 | - 'event_espresso' |
|
| 33 | - ), |
|
| 34 | - $script_handle |
|
| 35 | - ); |
|
| 36 | - } |
|
| 37 | - parent::__construct($message, $code, $previous); |
|
| 38 | - } |
|
| 19 | + /** |
|
| 20 | + * @param $script_handle |
|
| 21 | + * @param string $message |
|
| 22 | + * @param int $code |
|
| 23 | + * @param Exception|null $previous |
|
| 24 | + */ |
|
| 25 | + public function __construct($script_handle, $message = '', $code = 0, Exception $previous = null) |
|
| 26 | + { |
|
| 27 | + if (empty($message)) { |
|
| 28 | + $message = sprintf( |
|
| 29 | + esc_html_x( |
|
| 30 | + 'The "%1$s" script could not be registered with WordPress core.', |
|
| 31 | + 'The "script-handle" script could not be registered with WordPress core.', |
|
| 32 | + 'event_espresso' |
|
| 33 | + ), |
|
| 34 | + $script_handle |
|
| 35 | + ); |
|
| 36 | + } |
|
| 37 | + parent::__construct($message, $code, $previous); |
|
| 38 | + } |
|
| 39 | 39 | } |
| 40 | 40 | \ No newline at end of file |
@@ -15,106 +15,106 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class ExportTransaction implements PersonalDataExporterInterface |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @var EEM_Transaction $transaction_model |
|
| 20 | - */ |
|
| 21 | - protected $transaction_model; |
|
| 18 | + /** |
|
| 19 | + * @var EEM_Transaction $transaction_model |
|
| 20 | + */ |
|
| 21 | + protected $transaction_model; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * ExportTransaction constructor. |
|
| 25 | - * |
|
| 26 | - * @param $transaction_model |
|
| 27 | - */ |
|
| 28 | - public function __construct(EEM_Transaction $transaction_model) |
|
| 29 | - { |
|
| 30 | - $this->transaction_model = $transaction_model; |
|
| 31 | - } |
|
| 23 | + /** |
|
| 24 | + * ExportTransaction constructor. |
|
| 25 | + * |
|
| 26 | + * @param $transaction_model |
|
| 27 | + */ |
|
| 28 | + public function __construct(EEM_Transaction $transaction_model) |
|
| 29 | + { |
|
| 30 | + $this->transaction_model = $transaction_model; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Returns data for export. |
|
| 36 | - * |
|
| 37 | - * @param string $email_address , |
|
| 38 | - * @param int $page starts at 1, not 0 |
|
| 39 | - * @return array { |
|
| 40 | - * @type array $data { |
|
| 41 | - * @type array { |
|
| 42 | - * @type string $group_id (not translated, same for all exports) |
|
| 43 | - * @type string $group_label (translated string) |
|
| 44 | - * @type string|int $item_id |
|
| 45 | - * @type array $data { |
|
| 46 | - * @type array { |
|
| 47 | - * @type string $name what's shown in the left-column of the export row |
|
| 48 | - * @type string $value what's showin the right-column of the export row |
|
| 49 | - * } |
|
| 50 | - * } |
|
| 51 | - * } |
|
| 52 | - * } |
|
| 53 | - * } |
|
| 54 | - */ |
|
| 55 | - public function export($email_address, $page = 1) |
|
| 56 | - { |
|
| 57 | - $page_size = 10; |
|
| 58 | - $transactions = $this->transaction_model->get_all( |
|
| 59 | - array( |
|
| 60 | - array( |
|
| 61 | - 'Registration.Attendee.ATT_email' => $email_address, |
|
| 62 | - ), |
|
| 63 | - 'limit' => array( |
|
| 64 | - ($page - 1) * $page_size, |
|
| 65 | - $page_size, |
|
| 66 | - ), |
|
| 67 | - ) |
|
| 68 | - ); |
|
| 69 | - $export_fields = array_intersect_key( |
|
| 70 | - EEM_Transaction::instance()->field_settings(), |
|
| 71 | - array_flip( |
|
| 72 | - array( |
|
| 73 | - 'TXN_timestamp', |
|
| 74 | - 'TXN_total', |
|
| 75 | - 'TXN_paid', |
|
| 76 | - 'TXN_session_data', |
|
| 77 | - ) |
|
| 78 | - ) |
|
| 79 | - ); |
|
| 80 | - $export_items = array(); |
|
| 81 | - $found_something = false; |
|
| 82 | - foreach ($transactions as $transaction) { |
|
| 83 | - $found_something = true; |
|
| 84 | - $data = array(); |
|
| 85 | - foreach ($export_fields as $field_name => $field_obj) { |
|
| 86 | - if ($field_name === 'TXN_session_data') { |
|
| 87 | - $value = $transaction->get_pretty($field_name, 'print_r'); |
|
| 88 | - } else { |
|
| 89 | - $value = $transaction->get_pretty($field_name); |
|
| 90 | - } |
|
| 91 | - $data[] = array( |
|
| 92 | - 'name' => $field_obj->get_nicename(), |
|
| 93 | - 'value' => $value, |
|
| 94 | - ); |
|
| 95 | - } |
|
| 96 | - $export_items[] = array( |
|
| 97 | - 'group_id' => 'transactions', |
|
| 98 | - 'group_label' => esc_html__('Transactions', 'event_espresso'), |
|
| 99 | - 'item_id' => $transaction->ID(), |
|
| 100 | - 'data' => $data, |
|
| 101 | - ); |
|
| 102 | - } |
|
| 103 | - return array( |
|
| 104 | - 'data' => $export_items, |
|
| 105 | - 'done' => ! $found_something, |
|
| 106 | - ); |
|
| 107 | - } |
|
| 34 | + /** |
|
| 35 | + * Returns data for export. |
|
| 36 | + * |
|
| 37 | + * @param string $email_address , |
|
| 38 | + * @param int $page starts at 1, not 0 |
|
| 39 | + * @return array { |
|
| 40 | + * @type array $data { |
|
| 41 | + * @type array { |
|
| 42 | + * @type string $group_id (not translated, same for all exports) |
|
| 43 | + * @type string $group_label (translated string) |
|
| 44 | + * @type string|int $item_id |
|
| 45 | + * @type array $data { |
|
| 46 | + * @type array { |
|
| 47 | + * @type string $name what's shown in the left-column of the export row |
|
| 48 | + * @type string $value what's showin the right-column of the export row |
|
| 49 | + * } |
|
| 50 | + * } |
|
| 51 | + * } |
|
| 52 | + * } |
|
| 53 | + * } |
|
| 54 | + */ |
|
| 55 | + public function export($email_address, $page = 1) |
|
| 56 | + { |
|
| 57 | + $page_size = 10; |
|
| 58 | + $transactions = $this->transaction_model->get_all( |
|
| 59 | + array( |
|
| 60 | + array( |
|
| 61 | + 'Registration.Attendee.ATT_email' => $email_address, |
|
| 62 | + ), |
|
| 63 | + 'limit' => array( |
|
| 64 | + ($page - 1) * $page_size, |
|
| 65 | + $page_size, |
|
| 66 | + ), |
|
| 67 | + ) |
|
| 68 | + ); |
|
| 69 | + $export_fields = array_intersect_key( |
|
| 70 | + EEM_Transaction::instance()->field_settings(), |
|
| 71 | + array_flip( |
|
| 72 | + array( |
|
| 73 | + 'TXN_timestamp', |
|
| 74 | + 'TXN_total', |
|
| 75 | + 'TXN_paid', |
|
| 76 | + 'TXN_session_data', |
|
| 77 | + ) |
|
| 78 | + ) |
|
| 79 | + ); |
|
| 80 | + $export_items = array(); |
|
| 81 | + $found_something = false; |
|
| 82 | + foreach ($transactions as $transaction) { |
|
| 83 | + $found_something = true; |
|
| 84 | + $data = array(); |
|
| 85 | + foreach ($export_fields as $field_name => $field_obj) { |
|
| 86 | + if ($field_name === 'TXN_session_data') { |
|
| 87 | + $value = $transaction->get_pretty($field_name, 'print_r'); |
|
| 88 | + } else { |
|
| 89 | + $value = $transaction->get_pretty($field_name); |
|
| 90 | + } |
|
| 91 | + $data[] = array( |
|
| 92 | + 'name' => $field_obj->get_nicename(), |
|
| 93 | + 'value' => $value, |
|
| 94 | + ); |
|
| 95 | + } |
|
| 96 | + $export_items[] = array( |
|
| 97 | + 'group_id' => 'transactions', |
|
| 98 | + 'group_label' => esc_html__('Transactions', 'event_espresso'), |
|
| 99 | + 'item_id' => $transaction->ID(), |
|
| 100 | + 'data' => $data, |
|
| 101 | + ); |
|
| 102 | + } |
|
| 103 | + return array( |
|
| 104 | + 'data' => $export_items, |
|
| 105 | + 'done' => ! $found_something, |
|
| 106 | + ); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Gets the Translated name of this exporter |
|
| 111 | - * |
|
| 112 | - * @return string |
|
| 113 | - */ |
|
| 114 | - public function name() |
|
| 115 | - { |
|
| 116 | - return esc_html__('Event Espresso Transaction Exporter', 'event_espresso'); |
|
| 117 | - } |
|
| 109 | + /** |
|
| 110 | + * Gets the Translated name of this exporter |
|
| 111 | + * |
|
| 112 | + * @return string |
|
| 113 | + */ |
|
| 114 | + public function name() |
|
| 115 | + { |
|
| 116 | + return esc_html__('Event Espresso Transaction Exporter', 'event_espresso'); |
|
| 117 | + } |
|
| 118 | 118 | } |
| 119 | 119 | // End of file ExportTransaction.php |
| 120 | 120 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportTransaction.php |
@@ -16,112 +16,112 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class ExportCheckins implements PersonalDataExporterInterface |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * @var EEM_Checkin |
|
| 21 | - */ |
|
| 22 | - protected $checkin_model; |
|
| 19 | + /** |
|
| 20 | + * @var EEM_Checkin |
|
| 21 | + */ |
|
| 22 | + protected $checkin_model; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * ExportCheckins constructor. |
|
| 26 | - * |
|
| 27 | - * @param EEM_Checkin $checkin_model |
|
| 28 | - */ |
|
| 29 | - public function __construct(EEM_Checkin $checkin_model) |
|
| 30 | - { |
|
| 31 | - $this->checkin_model = $checkin_model; |
|
| 32 | - } |
|
| 24 | + /** |
|
| 25 | + * ExportCheckins constructor. |
|
| 26 | + * |
|
| 27 | + * @param EEM_Checkin $checkin_model |
|
| 28 | + */ |
|
| 29 | + public function __construct(EEM_Checkin $checkin_model) |
|
| 30 | + { |
|
| 31 | + $this->checkin_model = $checkin_model; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Returns data for export. |
|
| 37 | - * |
|
| 38 | - * @param string $email_address , |
|
| 39 | - * @param int $page starts at 1, not 0 |
|
| 40 | - * @return array { |
|
| 41 | - * @type array $data { |
|
| 42 | - * @type array { |
|
| 43 | - * @type string $group_id (not translated, same for all exports) |
|
| 44 | - * @type string $group_label (translated string) |
|
| 45 | - * @type string|int $item_id |
|
| 46 | - * @type array $data { |
|
| 47 | - * @type array { |
|
| 48 | - * @type string $name what's shown in the left-column of the export row |
|
| 49 | - * @type string $value what's showin the right-column of the export row |
|
| 50 | - * } |
|
| 51 | - * } |
|
| 52 | - * } |
|
| 53 | - * } |
|
| 54 | - * } |
|
| 55 | - */ |
|
| 56 | - public function export($email_address, $page = 1) |
|
| 57 | - { |
|
| 58 | - $page_size = 10; |
|
| 59 | - $checkins = $this->checkin_model->get_all( |
|
| 60 | - array( |
|
| 61 | - array( |
|
| 62 | - 'Registration.Attendee.ATT_email' => $email_address, |
|
| 63 | - ), |
|
| 64 | - 'limit' => array( |
|
| 65 | - ($page - 1) * $page_size, |
|
| 66 | - $page_size, |
|
| 67 | - ), |
|
| 68 | - 'force_join' => array('Registration.Event'), |
|
| 69 | - ) |
|
| 70 | - ); |
|
| 35 | + /** |
|
| 36 | + * Returns data for export. |
|
| 37 | + * |
|
| 38 | + * @param string $email_address , |
|
| 39 | + * @param int $page starts at 1, not 0 |
|
| 40 | + * @return array { |
|
| 41 | + * @type array $data { |
|
| 42 | + * @type array { |
|
| 43 | + * @type string $group_id (not translated, same for all exports) |
|
| 44 | + * @type string $group_label (translated string) |
|
| 45 | + * @type string|int $item_id |
|
| 46 | + * @type array $data { |
|
| 47 | + * @type array { |
|
| 48 | + * @type string $name what's shown in the left-column of the export row |
|
| 49 | + * @type string $value what's showin the right-column of the export row |
|
| 50 | + * } |
|
| 51 | + * } |
|
| 52 | + * } |
|
| 53 | + * } |
|
| 54 | + * } |
|
| 55 | + */ |
|
| 56 | + public function export($email_address, $page = 1) |
|
| 57 | + { |
|
| 58 | + $page_size = 10; |
|
| 59 | + $checkins = $this->checkin_model->get_all( |
|
| 60 | + array( |
|
| 61 | + array( |
|
| 62 | + 'Registration.Attendee.ATT_email' => $email_address, |
|
| 63 | + ), |
|
| 64 | + 'limit' => array( |
|
| 65 | + ($page - 1) * $page_size, |
|
| 66 | + $page_size, |
|
| 67 | + ), |
|
| 68 | + 'force_join' => array('Registration.Event'), |
|
| 69 | + ) |
|
| 70 | + ); |
|
| 71 | 71 | |
| 72 | - if (empty($checkins)) { |
|
| 73 | - return array( |
|
| 74 | - 'data' => array(), |
|
| 75 | - 'done' => true, |
|
| 76 | - ); |
|
| 77 | - } |
|
| 72 | + if (empty($checkins)) { |
|
| 73 | + return array( |
|
| 74 | + 'data' => array(), |
|
| 75 | + 'done' => true, |
|
| 76 | + ); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - $export_items = array(); |
|
| 80 | - foreach ($checkins as $checkin) { |
|
| 81 | - $reg = $checkin->get_first_related('Registration'); |
|
| 82 | - if ($reg instanceof EE_Registration) { |
|
| 83 | - $event_name = $reg->event_name(); |
|
| 84 | - } else { |
|
| 85 | - $event_name = esc_html__('Unknown', 'event_espresso'); |
|
| 86 | - } |
|
| 87 | - $export_items[] = |
|
| 88 | - array( |
|
| 89 | - 'group_id' => 'check-ins', |
|
| 90 | - 'group_label' => esc_html__('Event Check-Ins', 'event_espresso'), |
|
| 91 | - 'item_id' => $checkin->ID(), |
|
| 92 | - 'data' => array( |
|
| 93 | - array( |
|
| 94 | - 'name' => esc_html__('Time', 'event_espresso'), |
|
| 95 | - 'value' => $checkin->get_pretty('CHK_timestamp'), |
|
| 96 | - ), |
|
| 97 | - array( |
|
| 98 | - 'name' => esc_html__('Check in/out', 'event_espresso'), |
|
| 99 | - 'value' => $checkin->get('CHK_in') |
|
| 100 | - ? esc_html__('In', 'event_espresso') |
|
| 101 | - : esc_html__('Out', 'event_espresso'), |
|
| 102 | - ), |
|
| 103 | - array( |
|
| 104 | - 'name' => esc_html__('Event', 'event_espresso'), |
|
| 105 | - 'value' => $event_name, |
|
| 106 | - ), |
|
| 107 | - ), |
|
| 108 | - ); |
|
| 109 | - } |
|
| 110 | - return array( |
|
| 111 | - 'data' => $export_items, |
|
| 112 | - 'done' => true, |
|
| 113 | - ); |
|
| 114 | - } |
|
| 79 | + $export_items = array(); |
|
| 80 | + foreach ($checkins as $checkin) { |
|
| 81 | + $reg = $checkin->get_first_related('Registration'); |
|
| 82 | + if ($reg instanceof EE_Registration) { |
|
| 83 | + $event_name = $reg->event_name(); |
|
| 84 | + } else { |
|
| 85 | + $event_name = esc_html__('Unknown', 'event_espresso'); |
|
| 86 | + } |
|
| 87 | + $export_items[] = |
|
| 88 | + array( |
|
| 89 | + 'group_id' => 'check-ins', |
|
| 90 | + 'group_label' => esc_html__('Event Check-Ins', 'event_espresso'), |
|
| 91 | + 'item_id' => $checkin->ID(), |
|
| 92 | + 'data' => array( |
|
| 93 | + array( |
|
| 94 | + 'name' => esc_html__('Time', 'event_espresso'), |
|
| 95 | + 'value' => $checkin->get_pretty('CHK_timestamp'), |
|
| 96 | + ), |
|
| 97 | + array( |
|
| 98 | + 'name' => esc_html__('Check in/out', 'event_espresso'), |
|
| 99 | + 'value' => $checkin->get('CHK_in') |
|
| 100 | + ? esc_html__('In', 'event_espresso') |
|
| 101 | + : esc_html__('Out', 'event_espresso'), |
|
| 102 | + ), |
|
| 103 | + array( |
|
| 104 | + 'name' => esc_html__('Event', 'event_espresso'), |
|
| 105 | + 'value' => $event_name, |
|
| 106 | + ), |
|
| 107 | + ), |
|
| 108 | + ); |
|
| 109 | + } |
|
| 110 | + return array( |
|
| 111 | + 'data' => $export_items, |
|
| 112 | + 'done' => true, |
|
| 113 | + ); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * Gets the Translated name of this exporter |
|
| 118 | - * |
|
| 119 | - * @return string |
|
| 120 | - */ |
|
| 121 | - public function name() |
|
| 122 | - { |
|
| 123 | - return esc_html__('Event Espresso Checkins Exporter', 'event_espresso'); |
|
| 124 | - } |
|
| 116 | + /** |
|
| 117 | + * Gets the Translated name of this exporter |
|
| 118 | + * |
|
| 119 | + * @return string |
|
| 120 | + */ |
|
| 121 | + public function name() |
|
| 122 | + { |
|
| 123 | + return esc_html__('Event Espresso Checkins Exporter', 'event_espresso'); |
|
| 124 | + } |
|
| 125 | 125 | } |
| 126 | 126 | // End of file ExportCheckins.php |
| 127 | 127 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportCheckins.php |
@@ -15,116 +15,116 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class ExportAttendee implements PersonalDataExporterInterface |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @var EEM_Attendee |
|
| 20 | - */ |
|
| 21 | - protected $attendee_model; |
|
| 18 | + /** |
|
| 19 | + * @var EEM_Attendee |
|
| 20 | + */ |
|
| 21 | + protected $attendee_model; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * ExportAttendee constructor. |
|
| 25 | - * |
|
| 26 | - * @param EEM_Attendee $attendee_model |
|
| 27 | - */ |
|
| 28 | - public function __construct(EEM_Attendee $attendee_model) |
|
| 29 | - { |
|
| 30 | - $this->attendee_model = $attendee_model; |
|
| 31 | - } |
|
| 23 | + /** |
|
| 24 | + * ExportAttendee constructor. |
|
| 25 | + * |
|
| 26 | + * @param EEM_Attendee $attendee_model |
|
| 27 | + */ |
|
| 28 | + public function __construct(EEM_Attendee $attendee_model) |
|
| 29 | + { |
|
| 30 | + $this->attendee_model = $attendee_model; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Returns data for export. |
|
| 36 | - * |
|
| 37 | - * @param string $email_address , |
|
| 38 | - * @param int $page starts at 1, not 0 |
|
| 39 | - * @return array { |
|
| 40 | - * @type array $data { |
|
| 41 | - * @type array { |
|
| 42 | - * @type string $group_id (not translated, same for all exports) |
|
| 43 | - * @type string $group_label (translated string) |
|
| 44 | - * @type string|int $item_id |
|
| 45 | - * @type array $data { |
|
| 46 | - * @type array { |
|
| 47 | - * @type string $name what's shown in the left-column of the export row |
|
| 48 | - * @type string $value what's showin the right-column of the export row |
|
| 49 | - * } |
|
| 50 | - * } |
|
| 51 | - * } |
|
| 52 | - * } |
|
| 53 | - * } |
|
| 54 | - */ |
|
| 55 | - public function export($email_address, $page = 1) |
|
| 56 | - { |
|
| 57 | - $attendees = $this->attendee_model->get_all( |
|
| 58 | - array( |
|
| 59 | - array( |
|
| 60 | - 'ATT_email' => $email_address, |
|
| 61 | - ), |
|
| 62 | - ) |
|
| 63 | - ); |
|
| 34 | + /** |
|
| 35 | + * Returns data for export. |
|
| 36 | + * |
|
| 37 | + * @param string $email_address , |
|
| 38 | + * @param int $page starts at 1, not 0 |
|
| 39 | + * @return array { |
|
| 40 | + * @type array $data { |
|
| 41 | + * @type array { |
|
| 42 | + * @type string $group_id (not translated, same for all exports) |
|
| 43 | + * @type string $group_label (translated string) |
|
| 44 | + * @type string|int $item_id |
|
| 45 | + * @type array $data { |
|
| 46 | + * @type array { |
|
| 47 | + * @type string $name what's shown in the left-column of the export row |
|
| 48 | + * @type string $value what's showin the right-column of the export row |
|
| 49 | + * } |
|
| 50 | + * } |
|
| 51 | + * } |
|
| 52 | + * } |
|
| 53 | + * } |
|
| 54 | + */ |
|
| 55 | + public function export($email_address, $page = 1) |
|
| 56 | + { |
|
| 57 | + $attendees = $this->attendee_model->get_all( |
|
| 58 | + array( |
|
| 59 | + array( |
|
| 60 | + 'ATT_email' => $email_address, |
|
| 61 | + ), |
|
| 62 | + ) |
|
| 63 | + ); |
|
| 64 | 64 | |
| 65 | - if (empty($attendees)) { |
|
| 66 | - return array( |
|
| 67 | - 'data' => array(), |
|
| 68 | - 'done' => true, |
|
| 69 | - ); |
|
| 70 | - } |
|
| 65 | + if (empty($attendees)) { |
|
| 66 | + return array( |
|
| 67 | + 'data' => array(), |
|
| 68 | + 'done' => true, |
|
| 69 | + ); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - $export_items = array(); |
|
| 73 | - foreach ($attendees as $attendee) { |
|
| 74 | - $export_fields = array_intersect_key( |
|
| 75 | - $this->attendee_model->field_settings(), |
|
| 76 | - array_flip( |
|
| 77 | - array( |
|
| 78 | - 'ATT_fname', |
|
| 79 | - 'ATT_lname', |
|
| 80 | - 'ATT_email', |
|
| 81 | - 'ATT_address1', |
|
| 82 | - 'ATT_address2', |
|
| 83 | - 'ATT_city', |
|
| 84 | - 'STA_ID', |
|
| 85 | - 'CNT_ISO', |
|
| 86 | - 'ATT_zip', |
|
| 87 | - 'ATT_phone', |
|
| 88 | - ) |
|
| 89 | - ) |
|
| 90 | - ); |
|
| 91 | - $data = array(); |
|
| 92 | - foreach ($export_fields as $field_name => $field_obj) { |
|
| 93 | - if ($field_name === 'STA_ID') { |
|
| 94 | - $value = $attendee->state_name(); |
|
| 95 | - } elseif ($field_name == 'CNT_ISO') { |
|
| 96 | - $value = $attendee->country_name(); |
|
| 97 | - } else { |
|
| 98 | - $value = $attendee->get_pretty($field_name); |
|
| 99 | - } |
|
| 100 | - $data[] = array( |
|
| 101 | - 'name' => $field_obj->get_nicename(), |
|
| 102 | - 'value' => $value, |
|
| 103 | - ); |
|
| 104 | - } |
|
| 105 | - $export_items[] = |
|
| 106 | - array( |
|
| 107 | - 'group_id' => 'att-' . $attendee->ID(), |
|
| 108 | - 'group_label' => esc_html__('Contact Profiles', 'event_espresso'), |
|
| 109 | - 'item_id' => $attendee->ID(), |
|
| 110 | - 'data' => $data, |
|
| 111 | - ); |
|
| 112 | - } |
|
| 113 | - return array( |
|
| 114 | - 'data' => $export_items, |
|
| 115 | - 'done' => true, |
|
| 116 | - ); |
|
| 117 | - } |
|
| 72 | + $export_items = array(); |
|
| 73 | + foreach ($attendees as $attendee) { |
|
| 74 | + $export_fields = array_intersect_key( |
|
| 75 | + $this->attendee_model->field_settings(), |
|
| 76 | + array_flip( |
|
| 77 | + array( |
|
| 78 | + 'ATT_fname', |
|
| 79 | + 'ATT_lname', |
|
| 80 | + 'ATT_email', |
|
| 81 | + 'ATT_address1', |
|
| 82 | + 'ATT_address2', |
|
| 83 | + 'ATT_city', |
|
| 84 | + 'STA_ID', |
|
| 85 | + 'CNT_ISO', |
|
| 86 | + 'ATT_zip', |
|
| 87 | + 'ATT_phone', |
|
| 88 | + ) |
|
| 89 | + ) |
|
| 90 | + ); |
|
| 91 | + $data = array(); |
|
| 92 | + foreach ($export_fields as $field_name => $field_obj) { |
|
| 93 | + if ($field_name === 'STA_ID') { |
|
| 94 | + $value = $attendee->state_name(); |
|
| 95 | + } elseif ($field_name == 'CNT_ISO') { |
|
| 96 | + $value = $attendee->country_name(); |
|
| 97 | + } else { |
|
| 98 | + $value = $attendee->get_pretty($field_name); |
|
| 99 | + } |
|
| 100 | + $data[] = array( |
|
| 101 | + 'name' => $field_obj->get_nicename(), |
|
| 102 | + 'value' => $value, |
|
| 103 | + ); |
|
| 104 | + } |
|
| 105 | + $export_items[] = |
|
| 106 | + array( |
|
| 107 | + 'group_id' => 'att-' . $attendee->ID(), |
|
| 108 | + 'group_label' => esc_html__('Contact Profiles', 'event_espresso'), |
|
| 109 | + 'item_id' => $attendee->ID(), |
|
| 110 | + 'data' => $data, |
|
| 111 | + ); |
|
| 112 | + } |
|
| 113 | + return array( |
|
| 114 | + 'data' => $export_items, |
|
| 115 | + 'done' => true, |
|
| 116 | + ); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * Gets the Translated name of this exporter |
|
| 121 | - * |
|
| 122 | - * @return string |
|
| 123 | - */ |
|
| 124 | - public function name() |
|
| 125 | - { |
|
| 126 | - return esc_html__('Event Espresso Attendee Data Exporter', 'event_espresso'); |
|
| 127 | - } |
|
| 119 | + /** |
|
| 120 | + * Gets the Translated name of this exporter |
|
| 121 | + * |
|
| 122 | + * @return string |
|
| 123 | + */ |
|
| 124 | + public function name() |
|
| 125 | + { |
|
| 126 | + return esc_html__('Event Espresso Attendee Data Exporter', 'event_espresso'); |
|
| 127 | + } |
|
| 128 | 128 | } |
| 129 | 129 | // End of file ExportAttendee.php |
| 130 | 130 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportAttendee.php |
@@ -104,7 +104,7 @@ |
||
| 104 | 104 | } |
| 105 | 105 | $export_items[] = |
| 106 | 106 | array( |
| 107 | - 'group_id' => 'att-' . $attendee->ID(), |
|
| 107 | + 'group_id' => 'att-'.$attendee->ID(), |
|
| 108 | 108 | 'group_label' => esc_html__('Contact Profiles', 'event_espresso'), |
| 109 | 109 | 'item_id' => $attendee->ID(), |
| 110 | 110 | 'data' => $data, |
@@ -18,133 +18,133 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class ExportRegistration implements PersonalDataExporterInterface |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * @var EEM_Registration |
|
| 23 | - */ |
|
| 24 | - protected $registration_model; |
|
| 21 | + /** |
|
| 22 | + * @var EEM_Registration |
|
| 23 | + */ |
|
| 24 | + protected $registration_model; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * ExportRegistration constructor. |
|
| 28 | - * |
|
| 29 | - * @param EEM_Registration $registration_model |
|
| 30 | - */ |
|
| 31 | - public function __construct(EEM_Registration $registration_model) |
|
| 32 | - { |
|
| 33 | - $this->registration_model = $registration_model; |
|
| 34 | - } |
|
| 26 | + /** |
|
| 27 | + * ExportRegistration constructor. |
|
| 28 | + * |
|
| 29 | + * @param EEM_Registration $registration_model |
|
| 30 | + */ |
|
| 31 | + public function __construct(EEM_Registration $registration_model) |
|
| 32 | + { |
|
| 33 | + $this->registration_model = $registration_model; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Returns data for export. |
|
| 39 | - * |
|
| 40 | - * @param string $email_address , |
|
| 41 | - * @param int $page starts at 1, not 0 |
|
| 42 | - * @return array { |
|
| 43 | - * @type array $data { |
|
| 44 | - * @type array { |
|
| 45 | - * @type string $group_id (not translated, same for all exports) |
|
| 46 | - * @type string $group_label (translated string) |
|
| 47 | - * @type string|int $item_id |
|
| 48 | - * @type array $data { |
|
| 49 | - * @type array { |
|
| 50 | - * @type string $name what's shown in the left-column of the export row |
|
| 51 | - * @type string $value what's showin the right-column of the export row |
|
| 52 | - * } |
|
| 53 | - * } |
|
| 54 | - * } |
|
| 55 | - * } |
|
| 56 | - * } |
|
| 57 | - */ |
|
| 58 | - public function export($email_address, $page = 1) |
|
| 59 | - { |
|
| 60 | - $page_size = 10; |
|
| 61 | - $registrations = $this->registration_model->get_all( |
|
| 62 | - array( |
|
| 63 | - array( |
|
| 64 | - 'Attendee.ATT_email' => $email_address, |
|
| 65 | - ), |
|
| 66 | - 'limit' => array( |
|
| 67 | - ($page - 1) * $page_size, |
|
| 68 | - $page_size, |
|
| 69 | - ), |
|
| 70 | - ) |
|
| 71 | - ); |
|
| 72 | - $export_fields = array_intersect_key( |
|
| 73 | - $this->registration_model->field_settings(), |
|
| 74 | - array_flip( |
|
| 75 | - array( |
|
| 76 | - 'REG_code', |
|
| 77 | - 'REG_date', |
|
| 78 | - 'REG_final_price', |
|
| 79 | - 'REG_paid', |
|
| 80 | - 'REG_url_link', |
|
| 81 | - 'REG_count', |
|
| 82 | - 'REG_group_size', |
|
| 83 | - 'REG_att_is_going', |
|
| 84 | - ) |
|
| 85 | - ) |
|
| 86 | - ); |
|
| 87 | - $export_items = array(); |
|
| 88 | - $found_something = false; |
|
| 89 | - foreach ($registrations as $registration) { |
|
| 90 | - /** |
|
| 91 | - * @var $registration EE_Registration |
|
| 92 | - */ |
|
| 93 | - $found_something = true; |
|
| 94 | - $data = array(); |
|
| 95 | - foreach ($export_fields as $field_name => $field_obj) { |
|
| 96 | - $data[] = array( |
|
| 97 | - 'name' => $field_obj->get_nicename(), |
|
| 98 | - 'value' => $registration->get_pretty($field_name), |
|
| 99 | - ); |
|
| 100 | - } |
|
| 101 | - $answers = $registration->answers( |
|
| 102 | - array( |
|
| 103 | - 'force_join' => array( |
|
| 104 | - 'Question', |
|
| 105 | - ), |
|
| 106 | - ) |
|
| 107 | - ); |
|
| 108 | - foreach ($answers as $answer) { |
|
| 109 | - $data[] = array( |
|
| 110 | - 'name' => $answer->question()->display_text(), |
|
| 111 | - 'value' => $answer->pretty_value(), |
|
| 112 | - ); |
|
| 113 | - } |
|
| 114 | - $ticket = $registration->ticket(); |
|
| 115 | - if ($ticket instanceof EE_Ticket) { |
|
| 116 | - $data[] = array( |
|
| 117 | - 'name' => esc_html__('Ticket', 'event_espresso'), |
|
| 118 | - 'value' => $ticket->name_and_info(), |
|
| 119 | - ); |
|
| 120 | - $data[] = array( |
|
| 121 | - 'name' => esc_html__('Event', 'event_espresso'), |
|
| 122 | - 'value' => $ticket->get_event_name(), |
|
| 123 | - ); |
|
| 124 | - } |
|
| 37 | + /** |
|
| 38 | + * Returns data for export. |
|
| 39 | + * |
|
| 40 | + * @param string $email_address , |
|
| 41 | + * @param int $page starts at 1, not 0 |
|
| 42 | + * @return array { |
|
| 43 | + * @type array $data { |
|
| 44 | + * @type array { |
|
| 45 | + * @type string $group_id (not translated, same for all exports) |
|
| 46 | + * @type string $group_label (translated string) |
|
| 47 | + * @type string|int $item_id |
|
| 48 | + * @type array $data { |
|
| 49 | + * @type array { |
|
| 50 | + * @type string $name what's shown in the left-column of the export row |
|
| 51 | + * @type string $value what's showin the right-column of the export row |
|
| 52 | + * } |
|
| 53 | + * } |
|
| 54 | + * } |
|
| 55 | + * } |
|
| 56 | + * } |
|
| 57 | + */ |
|
| 58 | + public function export($email_address, $page = 1) |
|
| 59 | + { |
|
| 60 | + $page_size = 10; |
|
| 61 | + $registrations = $this->registration_model->get_all( |
|
| 62 | + array( |
|
| 63 | + array( |
|
| 64 | + 'Attendee.ATT_email' => $email_address, |
|
| 65 | + ), |
|
| 66 | + 'limit' => array( |
|
| 67 | + ($page - 1) * $page_size, |
|
| 68 | + $page_size, |
|
| 69 | + ), |
|
| 70 | + ) |
|
| 71 | + ); |
|
| 72 | + $export_fields = array_intersect_key( |
|
| 73 | + $this->registration_model->field_settings(), |
|
| 74 | + array_flip( |
|
| 75 | + array( |
|
| 76 | + 'REG_code', |
|
| 77 | + 'REG_date', |
|
| 78 | + 'REG_final_price', |
|
| 79 | + 'REG_paid', |
|
| 80 | + 'REG_url_link', |
|
| 81 | + 'REG_count', |
|
| 82 | + 'REG_group_size', |
|
| 83 | + 'REG_att_is_going', |
|
| 84 | + ) |
|
| 85 | + ) |
|
| 86 | + ); |
|
| 87 | + $export_items = array(); |
|
| 88 | + $found_something = false; |
|
| 89 | + foreach ($registrations as $registration) { |
|
| 90 | + /** |
|
| 91 | + * @var $registration EE_Registration |
|
| 92 | + */ |
|
| 93 | + $found_something = true; |
|
| 94 | + $data = array(); |
|
| 95 | + foreach ($export_fields as $field_name => $field_obj) { |
|
| 96 | + $data[] = array( |
|
| 97 | + 'name' => $field_obj->get_nicename(), |
|
| 98 | + 'value' => $registration->get_pretty($field_name), |
|
| 99 | + ); |
|
| 100 | + } |
|
| 101 | + $answers = $registration->answers( |
|
| 102 | + array( |
|
| 103 | + 'force_join' => array( |
|
| 104 | + 'Question', |
|
| 105 | + ), |
|
| 106 | + ) |
|
| 107 | + ); |
|
| 108 | + foreach ($answers as $answer) { |
|
| 109 | + $data[] = array( |
|
| 110 | + 'name' => $answer->question()->display_text(), |
|
| 111 | + 'value' => $answer->pretty_value(), |
|
| 112 | + ); |
|
| 113 | + } |
|
| 114 | + $ticket = $registration->ticket(); |
|
| 115 | + if ($ticket instanceof EE_Ticket) { |
|
| 116 | + $data[] = array( |
|
| 117 | + 'name' => esc_html__('Ticket', 'event_espresso'), |
|
| 118 | + 'value' => $ticket->name_and_info(), |
|
| 119 | + ); |
|
| 120 | + $data[] = array( |
|
| 121 | + 'name' => esc_html__('Event', 'event_espresso'), |
|
| 122 | + 'value' => $ticket->get_event_name(), |
|
| 123 | + ); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - $export_items[] = array( |
|
| 127 | - 'group_id' => 'registration', |
|
| 128 | - 'group_label' => esc_html__('Event Registrations', 'event_espresso'), |
|
| 129 | - 'item_id' => $registration->ID(), |
|
| 130 | - 'data' => $data, |
|
| 131 | - ); |
|
| 132 | - } |
|
| 133 | - return array( |
|
| 134 | - 'data' => $export_items, |
|
| 135 | - 'done' => ! $found_something, |
|
| 136 | - ); |
|
| 137 | - } |
|
| 126 | + $export_items[] = array( |
|
| 127 | + 'group_id' => 'registration', |
|
| 128 | + 'group_label' => esc_html__('Event Registrations', 'event_espresso'), |
|
| 129 | + 'item_id' => $registration->ID(), |
|
| 130 | + 'data' => $data, |
|
| 131 | + ); |
|
| 132 | + } |
|
| 133 | + return array( |
|
| 134 | + 'data' => $export_items, |
|
| 135 | + 'done' => ! $found_something, |
|
| 136 | + ); |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * Gets the Translated name of this exporter |
|
| 141 | - * |
|
| 142 | - * @return string |
|
| 143 | - */ |
|
| 144 | - public function name() |
|
| 145 | - { |
|
| 146 | - return esc_html__('Event Espresso Registration Data Exporter', 'event_espresso'); |
|
| 147 | - } |
|
| 139 | + /** |
|
| 140 | + * Gets the Translated name of this exporter |
|
| 141 | + * |
|
| 142 | + * @return string |
|
| 143 | + */ |
|
| 144 | + public function name() |
|
| 145 | + { |
|
| 146 | + return esc_html__('Event Espresso Registration Data Exporter', 'event_espresso'); |
|
| 147 | + } |
|
| 148 | 148 | } |
| 149 | 149 | // End of file ExportRegistration.php |
| 150 | 150 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportRegistration.php |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $JSON_response['success'] = $this->success(); |
| 123 | 123 | } |
| 124 | 124 | // but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked |
| 125 | - if (! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) { |
|
| 125 | + if ( ! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) { |
|
| 126 | 126 | $JSON_response['success'] = null; |
| 127 | 127 | } |
| 128 | 128 | // set redirect_url, IF it exists |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | // and finally, add return_data array to main JSON response array, IF it contains anything |
| 163 | 163 | // why did we add some of the above properties to the return data array? |
| 164 | 164 | // because it is easier and cleaner in the Javascript to deal with this way |
| 165 | - if (! empty($return_data)) { |
|
| 165 | + if ( ! empty($return_data)) { |
|
| 166 | 166 | $JSON_response['return_data'] = $return_data; |
| 167 | 167 | } |
| 168 | 168 | // filter final array |
@@ -14,401 +14,401 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class EE_SPCO_JSON_Response |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 20 | - protected $_errors = ''; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 25 | - protected $_unexpected_errors = ''; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @var string |
|
| 29 | - */ |
|
| 30 | - protected $_attention = ''; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 35 | - protected $_success = ''; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 40 | - protected $_plz_select_method_of_payment = ''; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @var string |
|
| 44 | - */ |
|
| 45 | - protected $_redirect_url = ''; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @var string |
|
| 49 | - */ |
|
| 50 | - protected $_registration_time_limit = ''; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @var string |
|
| 54 | - */ |
|
| 55 | - protected $_redirect_form = ''; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @var string |
|
| 59 | - */ |
|
| 60 | - protected $_reg_step_html = ''; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * @var string |
|
| 64 | - */ |
|
| 65 | - protected $_method_of_payment = ''; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @var float |
|
| 69 | - */ |
|
| 70 | - protected $_payment_amount; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @var array |
|
| 74 | - */ |
|
| 75 | - protected $_return_data = array(); |
|
| 76 | - |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @var array |
|
| 80 | - */ |
|
| 81 | - protected $_validation_rules = array(); |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * class constructor |
|
| 86 | - */ |
|
| 87 | - public function __construct() |
|
| 88 | - { |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * __toString |
|
| 94 | - * |
|
| 95 | - * allows you to simply echo or print an EE_SPCO_JSON_Response object to produce a JSON encoded string |
|
| 96 | - * |
|
| 97 | - * @access public |
|
| 98 | - * @return string |
|
| 99 | - */ |
|
| 100 | - public function __toString() |
|
| 101 | - { |
|
| 102 | - $JSON_response = array(); |
|
| 103 | - // grab notices |
|
| 104 | - $notices = EE_Error::get_notices(false); |
|
| 105 | - $this->set_attention(isset($notices['attention']) ? $notices['attention'] : ''); |
|
| 106 | - $this->set_errors(isset($notices['errors']) ? $notices['errors'] : ''); |
|
| 107 | - $this->set_success(isset($notices['success']) ? $notices['success'] : ''); |
|
| 108 | - // add notices to JSON response, but only if they exist |
|
| 109 | - if ($this->attention()) { |
|
| 110 | - $JSON_response['attention'] = $this->attention(); |
|
| 111 | - } |
|
| 112 | - if ($this->errors()) { |
|
| 113 | - $JSON_response['errors'] = $this->errors(); |
|
| 114 | - } |
|
| 115 | - if ($this->unexpected_errors()) { |
|
| 116 | - $JSON_response['unexpected_errors'] = $this->unexpected_errors(); |
|
| 117 | - } |
|
| 118 | - if ($this->success()) { |
|
| 119 | - $JSON_response['success'] = $this->success(); |
|
| 120 | - } |
|
| 121 | - // but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked |
|
| 122 | - if (! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) { |
|
| 123 | - $JSON_response['success'] = null; |
|
| 124 | - } |
|
| 125 | - // set redirect_url, IF it exists |
|
| 126 | - if ($this->redirect_url()) { |
|
| 127 | - $JSON_response['redirect_url'] = $this->redirect_url(); |
|
| 128 | - } |
|
| 129 | - // set registration_time_limit, IF it exists |
|
| 130 | - if ($this->registration_time_limit()) { |
|
| 131 | - $JSON_response['registration_time_limit'] = $this->registration_time_limit(); |
|
| 132 | - } |
|
| 133 | - // set payment_amount, IF it exists |
|
| 134 | - if ($this->payment_amount() !== null) { |
|
| 135 | - $JSON_response['payment_amount'] = $this->payment_amount(); |
|
| 136 | - } |
|
| 137 | - // grab generic return data |
|
| 138 | - $return_data = $this->return_data(); |
|
| 139 | - // add billing form validation rules |
|
| 140 | - if ($this->validation_rules()) { |
|
| 141 | - $return_data['validation_rules'] = $this->validation_rules(); |
|
| 142 | - } |
|
| 143 | - // set reg_step_html, IF it exists |
|
| 144 | - if ($this->reg_step_html()) { |
|
| 145 | - $return_data['reg_step_html'] = $this->reg_step_html(); |
|
| 146 | - } |
|
| 147 | - // set method of payment, IF it exists |
|
| 148 | - if ($this->method_of_payment()) { |
|
| 149 | - $return_data['method_of_payment'] = $this->method_of_payment(); |
|
| 150 | - } |
|
| 151 | - // set "plz_select_method_of_payment" message, IF it exists |
|
| 152 | - if ($this->plz_select_method_of_payment()) { |
|
| 153 | - $return_data['plz_select_method_of_payment'] = $this->plz_select_method_of_payment(); |
|
| 154 | - } |
|
| 155 | - // set redirect_form, IF it exists |
|
| 156 | - if ($this->redirect_form()) { |
|
| 157 | - $return_data['redirect_form'] = $this->redirect_form(); |
|
| 158 | - } |
|
| 159 | - // and finally, add return_data array to main JSON response array, IF it contains anything |
|
| 160 | - // why did we add some of the above properties to the return data array? |
|
| 161 | - // because it is easier and cleaner in the Javascript to deal with this way |
|
| 162 | - if (! empty($return_data)) { |
|
| 163 | - $JSON_response['return_data'] = $return_data; |
|
| 164 | - } |
|
| 165 | - // filter final array |
|
| 166 | - $JSON_response = apply_filters('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response); |
|
| 167 | - // return encoded array |
|
| 168 | - return (string) wp_json_encode($JSON_response); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * @param string $attention |
|
| 174 | - */ |
|
| 175 | - public function set_attention($attention) |
|
| 176 | - { |
|
| 177 | - $this->_attention = $attention; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * @return string |
|
| 183 | - */ |
|
| 184 | - public function attention() |
|
| 185 | - { |
|
| 186 | - return $this->_attention; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * @param string $errors |
|
| 192 | - */ |
|
| 193 | - public function set_errors($errors) |
|
| 194 | - { |
|
| 195 | - $this->_errors = $errors; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * @return string |
|
| 201 | - */ |
|
| 202 | - public function errors() |
|
| 203 | - { |
|
| 204 | - return $this->_errors; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * @return string |
|
| 210 | - */ |
|
| 211 | - public function unexpected_errors() |
|
| 212 | - { |
|
| 213 | - return $this->_unexpected_errors; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * @param string $unexpected_errors |
|
| 219 | - */ |
|
| 220 | - public function set_unexpected_errors($unexpected_errors) |
|
| 221 | - { |
|
| 222 | - $this->_unexpected_errors = $unexpected_errors; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * @param string $success |
|
| 228 | - */ |
|
| 229 | - public function set_success($success) |
|
| 230 | - { |
|
| 231 | - $this->_success = $success; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * @return string |
|
| 237 | - */ |
|
| 238 | - public function success() |
|
| 239 | - { |
|
| 240 | - return $this->_success; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - |
|
| 244 | - /** |
|
| 245 | - * @param string $method_of_payment |
|
| 246 | - */ |
|
| 247 | - public function set_method_of_payment($method_of_payment) |
|
| 248 | - { |
|
| 249 | - $this->_method_of_payment = $method_of_payment; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * @return string |
|
| 255 | - */ |
|
| 256 | - public function method_of_payment() |
|
| 257 | - { |
|
| 258 | - return $this->_method_of_payment; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - |
|
| 262 | - /** |
|
| 263 | - * @return float |
|
| 264 | - */ |
|
| 265 | - public function payment_amount() |
|
| 266 | - { |
|
| 267 | - return $this->_payment_amount; |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - |
|
| 271 | - /** |
|
| 272 | - * @param float $payment_amount |
|
| 273 | - * @throws EE_Error |
|
| 274 | - */ |
|
| 275 | - public function set_payment_amount($payment_amount) |
|
| 276 | - { |
|
| 277 | - $this->_payment_amount = (float) $payment_amount; |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - |
|
| 281 | - /** |
|
| 282 | - * @param string $next_step_html |
|
| 283 | - */ |
|
| 284 | - public function set_reg_step_html($next_step_html) |
|
| 285 | - { |
|
| 286 | - $this->_reg_step_html = $next_step_html; |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - |
|
| 290 | - /** |
|
| 291 | - * @return string |
|
| 292 | - */ |
|
| 293 | - public function reg_step_html() |
|
| 294 | - { |
|
| 295 | - return $this->_reg_step_html; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - |
|
| 299 | - /** |
|
| 300 | - * @param string $redirect_form |
|
| 301 | - */ |
|
| 302 | - public function set_redirect_form($redirect_form) |
|
| 303 | - { |
|
| 304 | - $this->_redirect_form = $redirect_form; |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - |
|
| 308 | - /** |
|
| 309 | - * @return string |
|
| 310 | - */ |
|
| 311 | - public function redirect_form() |
|
| 312 | - { |
|
| 313 | - return ! empty($this->_redirect_form) ? $this->_redirect_form : false; |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - |
|
| 317 | - /** |
|
| 318 | - * @param string $plz_select_method_of_payment |
|
| 319 | - */ |
|
| 320 | - public function set_plz_select_method_of_payment($plz_select_method_of_payment) |
|
| 321 | - { |
|
| 322 | - $this->_plz_select_method_of_payment = $plz_select_method_of_payment; |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - |
|
| 326 | - /** |
|
| 327 | - * @return string |
|
| 328 | - */ |
|
| 329 | - public function plz_select_method_of_payment() |
|
| 330 | - { |
|
| 331 | - return $this->_plz_select_method_of_payment; |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - |
|
| 335 | - /** |
|
| 336 | - * @param string $redirect_url |
|
| 337 | - */ |
|
| 338 | - public function set_redirect_url($redirect_url) |
|
| 339 | - { |
|
| 340 | - $this->_redirect_url = $redirect_url; |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * @return string |
|
| 346 | - */ |
|
| 347 | - public function redirect_url() |
|
| 348 | - { |
|
| 349 | - return $this->_redirect_url; |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - |
|
| 353 | - /** |
|
| 354 | - * @return string |
|
| 355 | - */ |
|
| 356 | - public function registration_time_limit() |
|
| 357 | - { |
|
| 358 | - return $this->_registration_time_limit; |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * @param string $registration_time_limit |
|
| 364 | - */ |
|
| 365 | - public function set_registration_time_limit($registration_time_limit) |
|
| 366 | - { |
|
| 367 | - $this->_registration_time_limit = $registration_time_limit; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - |
|
| 371 | - /** |
|
| 372 | - * @param array $return_data |
|
| 373 | - */ |
|
| 374 | - public function set_return_data($return_data) |
|
| 375 | - { |
|
| 376 | - $this->_return_data = array_merge($this->_return_data, $return_data); |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - |
|
| 380 | - /** |
|
| 381 | - * @return array |
|
| 382 | - */ |
|
| 383 | - public function return_data() |
|
| 384 | - { |
|
| 385 | - return $this->_return_data; |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - |
|
| 389 | - /** |
|
| 390 | - * @param array $validation_rules |
|
| 391 | - */ |
|
| 392 | - public function add_validation_rules(array $validation_rules = array()) |
|
| 393 | - { |
|
| 394 | - if (is_array($validation_rules) && ! empty($validation_rules)) { |
|
| 395 | - $this->_validation_rules = array_merge($this->_validation_rules, $validation_rules); |
|
| 396 | - } |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - |
|
| 400 | - /** |
|
| 401 | - * @return array | bool |
|
| 402 | - */ |
|
| 403 | - public function validation_rules() |
|
| 404 | - { |
|
| 405 | - return ! empty($this->_validation_rules) ? $this->_validation_rules : false; |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - |
|
| 409 | - public function echoAndExit() |
|
| 410 | - { |
|
| 411 | - echo ($this); |
|
| 412 | - exit(); |
|
| 413 | - } |
|
| 17 | + /** |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | + protected $_errors = ''; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | + protected $_unexpected_errors = ''; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @var string |
|
| 29 | + */ |
|
| 30 | + protected $_attention = ''; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | + protected $_success = ''; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | + protected $_plz_select_method_of_payment = ''; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @var string |
|
| 44 | + */ |
|
| 45 | + protected $_redirect_url = ''; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @var string |
|
| 49 | + */ |
|
| 50 | + protected $_registration_time_limit = ''; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @var string |
|
| 54 | + */ |
|
| 55 | + protected $_redirect_form = ''; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @var string |
|
| 59 | + */ |
|
| 60 | + protected $_reg_step_html = ''; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * @var string |
|
| 64 | + */ |
|
| 65 | + protected $_method_of_payment = ''; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @var float |
|
| 69 | + */ |
|
| 70 | + protected $_payment_amount; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @var array |
|
| 74 | + */ |
|
| 75 | + protected $_return_data = array(); |
|
| 76 | + |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @var array |
|
| 80 | + */ |
|
| 81 | + protected $_validation_rules = array(); |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * class constructor |
|
| 86 | + */ |
|
| 87 | + public function __construct() |
|
| 88 | + { |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * __toString |
|
| 94 | + * |
|
| 95 | + * allows you to simply echo or print an EE_SPCO_JSON_Response object to produce a JSON encoded string |
|
| 96 | + * |
|
| 97 | + * @access public |
|
| 98 | + * @return string |
|
| 99 | + */ |
|
| 100 | + public function __toString() |
|
| 101 | + { |
|
| 102 | + $JSON_response = array(); |
|
| 103 | + // grab notices |
|
| 104 | + $notices = EE_Error::get_notices(false); |
|
| 105 | + $this->set_attention(isset($notices['attention']) ? $notices['attention'] : ''); |
|
| 106 | + $this->set_errors(isset($notices['errors']) ? $notices['errors'] : ''); |
|
| 107 | + $this->set_success(isset($notices['success']) ? $notices['success'] : ''); |
|
| 108 | + // add notices to JSON response, but only if they exist |
|
| 109 | + if ($this->attention()) { |
|
| 110 | + $JSON_response['attention'] = $this->attention(); |
|
| 111 | + } |
|
| 112 | + if ($this->errors()) { |
|
| 113 | + $JSON_response['errors'] = $this->errors(); |
|
| 114 | + } |
|
| 115 | + if ($this->unexpected_errors()) { |
|
| 116 | + $JSON_response['unexpected_errors'] = $this->unexpected_errors(); |
|
| 117 | + } |
|
| 118 | + if ($this->success()) { |
|
| 119 | + $JSON_response['success'] = $this->success(); |
|
| 120 | + } |
|
| 121 | + // but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked |
|
| 122 | + if (! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) { |
|
| 123 | + $JSON_response['success'] = null; |
|
| 124 | + } |
|
| 125 | + // set redirect_url, IF it exists |
|
| 126 | + if ($this->redirect_url()) { |
|
| 127 | + $JSON_response['redirect_url'] = $this->redirect_url(); |
|
| 128 | + } |
|
| 129 | + // set registration_time_limit, IF it exists |
|
| 130 | + if ($this->registration_time_limit()) { |
|
| 131 | + $JSON_response['registration_time_limit'] = $this->registration_time_limit(); |
|
| 132 | + } |
|
| 133 | + // set payment_amount, IF it exists |
|
| 134 | + if ($this->payment_amount() !== null) { |
|
| 135 | + $JSON_response['payment_amount'] = $this->payment_amount(); |
|
| 136 | + } |
|
| 137 | + // grab generic return data |
|
| 138 | + $return_data = $this->return_data(); |
|
| 139 | + // add billing form validation rules |
|
| 140 | + if ($this->validation_rules()) { |
|
| 141 | + $return_data['validation_rules'] = $this->validation_rules(); |
|
| 142 | + } |
|
| 143 | + // set reg_step_html, IF it exists |
|
| 144 | + if ($this->reg_step_html()) { |
|
| 145 | + $return_data['reg_step_html'] = $this->reg_step_html(); |
|
| 146 | + } |
|
| 147 | + // set method of payment, IF it exists |
|
| 148 | + if ($this->method_of_payment()) { |
|
| 149 | + $return_data['method_of_payment'] = $this->method_of_payment(); |
|
| 150 | + } |
|
| 151 | + // set "plz_select_method_of_payment" message, IF it exists |
|
| 152 | + if ($this->plz_select_method_of_payment()) { |
|
| 153 | + $return_data['plz_select_method_of_payment'] = $this->plz_select_method_of_payment(); |
|
| 154 | + } |
|
| 155 | + // set redirect_form, IF it exists |
|
| 156 | + if ($this->redirect_form()) { |
|
| 157 | + $return_data['redirect_form'] = $this->redirect_form(); |
|
| 158 | + } |
|
| 159 | + // and finally, add return_data array to main JSON response array, IF it contains anything |
|
| 160 | + // why did we add some of the above properties to the return data array? |
|
| 161 | + // because it is easier and cleaner in the Javascript to deal with this way |
|
| 162 | + if (! empty($return_data)) { |
|
| 163 | + $JSON_response['return_data'] = $return_data; |
|
| 164 | + } |
|
| 165 | + // filter final array |
|
| 166 | + $JSON_response = apply_filters('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response); |
|
| 167 | + // return encoded array |
|
| 168 | + return (string) wp_json_encode($JSON_response); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * @param string $attention |
|
| 174 | + */ |
|
| 175 | + public function set_attention($attention) |
|
| 176 | + { |
|
| 177 | + $this->_attention = $attention; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * @return string |
|
| 183 | + */ |
|
| 184 | + public function attention() |
|
| 185 | + { |
|
| 186 | + return $this->_attention; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * @param string $errors |
|
| 192 | + */ |
|
| 193 | + public function set_errors($errors) |
|
| 194 | + { |
|
| 195 | + $this->_errors = $errors; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * @return string |
|
| 201 | + */ |
|
| 202 | + public function errors() |
|
| 203 | + { |
|
| 204 | + return $this->_errors; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * @return string |
|
| 210 | + */ |
|
| 211 | + public function unexpected_errors() |
|
| 212 | + { |
|
| 213 | + return $this->_unexpected_errors; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + |
|
| 217 | + /** |
|
| 218 | + * @param string $unexpected_errors |
|
| 219 | + */ |
|
| 220 | + public function set_unexpected_errors($unexpected_errors) |
|
| 221 | + { |
|
| 222 | + $this->_unexpected_errors = $unexpected_errors; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * @param string $success |
|
| 228 | + */ |
|
| 229 | + public function set_success($success) |
|
| 230 | + { |
|
| 231 | + $this->_success = $success; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * @return string |
|
| 237 | + */ |
|
| 238 | + public function success() |
|
| 239 | + { |
|
| 240 | + return $this->_success; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + |
|
| 244 | + /** |
|
| 245 | + * @param string $method_of_payment |
|
| 246 | + */ |
|
| 247 | + public function set_method_of_payment($method_of_payment) |
|
| 248 | + { |
|
| 249 | + $this->_method_of_payment = $method_of_payment; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * @return string |
|
| 255 | + */ |
|
| 256 | + public function method_of_payment() |
|
| 257 | + { |
|
| 258 | + return $this->_method_of_payment; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + |
|
| 262 | + /** |
|
| 263 | + * @return float |
|
| 264 | + */ |
|
| 265 | + public function payment_amount() |
|
| 266 | + { |
|
| 267 | + return $this->_payment_amount; |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + |
|
| 271 | + /** |
|
| 272 | + * @param float $payment_amount |
|
| 273 | + * @throws EE_Error |
|
| 274 | + */ |
|
| 275 | + public function set_payment_amount($payment_amount) |
|
| 276 | + { |
|
| 277 | + $this->_payment_amount = (float) $payment_amount; |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + |
|
| 281 | + /** |
|
| 282 | + * @param string $next_step_html |
|
| 283 | + */ |
|
| 284 | + public function set_reg_step_html($next_step_html) |
|
| 285 | + { |
|
| 286 | + $this->_reg_step_html = $next_step_html; |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + |
|
| 290 | + /** |
|
| 291 | + * @return string |
|
| 292 | + */ |
|
| 293 | + public function reg_step_html() |
|
| 294 | + { |
|
| 295 | + return $this->_reg_step_html; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + |
|
| 299 | + /** |
|
| 300 | + * @param string $redirect_form |
|
| 301 | + */ |
|
| 302 | + public function set_redirect_form($redirect_form) |
|
| 303 | + { |
|
| 304 | + $this->_redirect_form = $redirect_form; |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + |
|
| 308 | + /** |
|
| 309 | + * @return string |
|
| 310 | + */ |
|
| 311 | + public function redirect_form() |
|
| 312 | + { |
|
| 313 | + return ! empty($this->_redirect_form) ? $this->_redirect_form : false; |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + |
|
| 317 | + /** |
|
| 318 | + * @param string $plz_select_method_of_payment |
|
| 319 | + */ |
|
| 320 | + public function set_plz_select_method_of_payment($plz_select_method_of_payment) |
|
| 321 | + { |
|
| 322 | + $this->_plz_select_method_of_payment = $plz_select_method_of_payment; |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + |
|
| 326 | + /** |
|
| 327 | + * @return string |
|
| 328 | + */ |
|
| 329 | + public function plz_select_method_of_payment() |
|
| 330 | + { |
|
| 331 | + return $this->_plz_select_method_of_payment; |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * @param string $redirect_url |
|
| 337 | + */ |
|
| 338 | + public function set_redirect_url($redirect_url) |
|
| 339 | + { |
|
| 340 | + $this->_redirect_url = $redirect_url; |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * @return string |
|
| 346 | + */ |
|
| 347 | + public function redirect_url() |
|
| 348 | + { |
|
| 349 | + return $this->_redirect_url; |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * @return string |
|
| 355 | + */ |
|
| 356 | + public function registration_time_limit() |
|
| 357 | + { |
|
| 358 | + return $this->_registration_time_limit; |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * @param string $registration_time_limit |
|
| 364 | + */ |
|
| 365 | + public function set_registration_time_limit($registration_time_limit) |
|
| 366 | + { |
|
| 367 | + $this->_registration_time_limit = $registration_time_limit; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + |
|
| 371 | + /** |
|
| 372 | + * @param array $return_data |
|
| 373 | + */ |
|
| 374 | + public function set_return_data($return_data) |
|
| 375 | + { |
|
| 376 | + $this->_return_data = array_merge($this->_return_data, $return_data); |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * @return array |
|
| 382 | + */ |
|
| 383 | + public function return_data() |
|
| 384 | + { |
|
| 385 | + return $this->_return_data; |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + |
|
| 389 | + /** |
|
| 390 | + * @param array $validation_rules |
|
| 391 | + */ |
|
| 392 | + public function add_validation_rules(array $validation_rules = array()) |
|
| 393 | + { |
|
| 394 | + if (is_array($validation_rules) && ! empty($validation_rules)) { |
|
| 395 | + $this->_validation_rules = array_merge($this->_validation_rules, $validation_rules); |
|
| 396 | + } |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + |
|
| 400 | + /** |
|
| 401 | + * @return array | bool |
|
| 402 | + */ |
|
| 403 | + public function validation_rules() |
|
| 404 | + { |
|
| 405 | + return ! empty($this->_validation_rules) ? $this->_validation_rules : false; |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + |
|
| 409 | + public function echoAndExit() |
|
| 410 | + { |
|
| 411 | + echo ($this); |
|
| 412 | + exit(); |
|
| 413 | + } |
|
| 414 | 414 | } |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | 'ee_read_checkins', |
| 40 | 40 | 'espresso_registrations_registration_checkins' |
| 41 | 41 | ) |
| 42 | - ? '<a href="' . $check_in_url . '"' |
|
| 43 | - . ' title="' . esc_attr__( |
|
| 42 | + ? '<a href="'.$check_in_url.'"' |
|
| 43 | + . ' title="'.esc_attr__( |
|
| 44 | 44 | 'The Check-In List allows you to easily toggle check-in status for this event', |
| 45 | 45 | 'event_espresso' |
| 46 | 46 | ) |
| 47 | - . '">' . esc_html__('View Check-ins', 'event_espresso') . '</a>' |
|
| 47 | + . '">'.esc_html__('View Check-ins', 'event_espresso').'</a>' |
|
| 48 | 48 | : esc_html__('View Check-ins', 'event_espresso'); |
| 49 | 49 | |
| 50 | 50 | return sprintf('%1$s %2$s', $date_linked, $this->row_actions($actions)); |
@@ -105,17 +105,17 @@ discard block |
||
| 105 | 105 | // add a "View Registrations" link that filters list by event AND datetime |
| 106 | 106 | $datetime_string .= $this->row_actions( |
| 107 | 107 | array( |
| 108 | - 'event_datetime_filter' => '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
| 108 | + 'event_datetime_filter' => '<a href="'.EE_Admin_Page::add_query_args_and_nonce( |
|
| 109 | 109 | array('event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()), |
| 110 | 110 | REG_ADMIN_URL |
| 111 | 111 | ) |
| 112 | - . '" title="' . sprintf( |
|
| 112 | + . '" title="'.sprintf( |
|
| 113 | 113 | esc_attr__( |
| 114 | 114 | 'Filter this list to only show registrations for this datetime %s', |
| 115 | 115 | 'event_espresso' |
| 116 | 116 | ), |
| 117 | 117 | $datetime->name() |
| 118 | - ) . '">' |
|
| 118 | + ).'">' |
|
| 119 | 119 | . esc_html__('View Registrations', 'event_espresso') |
| 120 | 120 | . '</a>', |
| 121 | 121 | ) |
@@ -12,117 +12,117 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class Extend_EE_Registrations_List_Table extends EE_Registrations_List_Table |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @param EE_Registration $item |
|
| 17 | - * @return string |
|
| 18 | - * @throws EE_Error |
|
| 19 | - * @throws InvalidArgumentException |
|
| 20 | - * @throws ReflectionException |
|
| 21 | - * @throws InvalidDataTypeException |
|
| 22 | - * @throws InvalidInterfaceException |
|
| 23 | - */ |
|
| 24 | - public function column__REG_date(EE_Registration $item) |
|
| 25 | - { |
|
| 26 | - $date_linked = parent::column__REG_date($item); |
|
| 27 | - $actions = array(); |
|
| 28 | - // Build row actions |
|
| 29 | - $check_in_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 30 | - 'action' => 'event_registrations', |
|
| 31 | - 'event_id' => $item->event_ID(), |
|
| 32 | - ), REG_ADMIN_URL); |
|
| 33 | - $actions['check_in'] = EE_Registry::instance()->CAP->current_user_can( |
|
| 34 | - 'ee_read_registration', |
|
| 35 | - 'espresso_registrations_registration_checkins', |
|
| 36 | - $item->ID() |
|
| 37 | - ) && EE_Registry::instance()->CAP->current_user_can( |
|
| 38 | - 'ee_read_checkins', |
|
| 39 | - 'espresso_registrations_registration_checkins' |
|
| 40 | - ) |
|
| 41 | - ? '<a href="' . $check_in_url . '"' |
|
| 42 | - . ' title="' . esc_attr__( |
|
| 43 | - 'The Check-In List allows you to easily toggle check-in status for this event', |
|
| 44 | - 'event_espresso' |
|
| 45 | - ) |
|
| 46 | - . '">' . esc_html__('View Check-ins', 'event_espresso') . '</a>' |
|
| 47 | - : esc_html__('View Check-ins', 'event_espresso'); |
|
| 15 | + /** |
|
| 16 | + * @param EE_Registration $item |
|
| 17 | + * @return string |
|
| 18 | + * @throws EE_Error |
|
| 19 | + * @throws InvalidArgumentException |
|
| 20 | + * @throws ReflectionException |
|
| 21 | + * @throws InvalidDataTypeException |
|
| 22 | + * @throws InvalidInterfaceException |
|
| 23 | + */ |
|
| 24 | + public function column__REG_date(EE_Registration $item) |
|
| 25 | + { |
|
| 26 | + $date_linked = parent::column__REG_date($item); |
|
| 27 | + $actions = array(); |
|
| 28 | + // Build row actions |
|
| 29 | + $check_in_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 30 | + 'action' => 'event_registrations', |
|
| 31 | + 'event_id' => $item->event_ID(), |
|
| 32 | + ), REG_ADMIN_URL); |
|
| 33 | + $actions['check_in'] = EE_Registry::instance()->CAP->current_user_can( |
|
| 34 | + 'ee_read_registration', |
|
| 35 | + 'espresso_registrations_registration_checkins', |
|
| 36 | + $item->ID() |
|
| 37 | + ) && EE_Registry::instance()->CAP->current_user_can( |
|
| 38 | + 'ee_read_checkins', |
|
| 39 | + 'espresso_registrations_registration_checkins' |
|
| 40 | + ) |
|
| 41 | + ? '<a href="' . $check_in_url . '"' |
|
| 42 | + . ' title="' . esc_attr__( |
|
| 43 | + 'The Check-In List allows you to easily toggle check-in status for this event', |
|
| 44 | + 'event_espresso' |
|
| 45 | + ) |
|
| 46 | + . '">' . esc_html__('View Check-ins', 'event_espresso') . '</a>' |
|
| 47 | + : esc_html__('View Check-ins', 'event_espresso'); |
|
| 48 | 48 | |
| 49 | - return sprintf('%1$s %2$s', $date_linked, $this->row_actions($actions)); |
|
| 50 | - } |
|
| 49 | + return sprintf('%1$s %2$s', $date_linked, $this->row_actions($actions)); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * column_default |
|
| 55 | - * |
|
| 56 | - * @param \EE_Registration $item |
|
| 57 | - * @return string |
|
| 58 | - * @throws EE_Error |
|
| 59 | - * @throws InvalidArgumentException |
|
| 60 | - * @throws InvalidDataTypeException |
|
| 61 | - * @throws InvalidInterfaceException |
|
| 62 | - * @throws ReflectionException |
|
| 63 | - */ |
|
| 64 | - public function column_DTT_EVT_start(EE_Registration $item) |
|
| 65 | - { |
|
| 66 | - $remove_defaults = array('default_where_conditions' => 'none'); |
|
| 67 | - $ticket = $item->ticket(); |
|
| 68 | - $datetimes = $ticket instanceof EE_Ticket ? $ticket->datetimes($remove_defaults) : array(); |
|
| 69 | - $EVT_ID = $item->event_ID(); |
|
| 70 | - $datetimes_for_display = array(); |
|
| 71 | - foreach ($datetimes as $datetime) { |
|
| 72 | - $datetime_string = ''; |
|
| 73 | - if ( |
|
| 74 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 75 | - 'ee_read_checkin', |
|
| 76 | - 'espresso_registrations_registration_checkins', |
|
| 77 | - $item->ID() |
|
| 78 | - ) |
|
| 79 | - ) { |
|
| 80 | - // open "a" tag and "href" |
|
| 81 | - $datetime_string .= '<a href="'; |
|
| 82 | - // checkin URL |
|
| 83 | - $datetime_string .= EE_Admin_Page::add_query_args_and_nonce( |
|
| 84 | - array( |
|
| 85 | - 'action' => 'event_registrations', |
|
| 86 | - 'event_id' => $EVT_ID, |
|
| 87 | - 'DTT_ID' => $datetime->ID(), |
|
| 88 | - ), |
|
| 89 | - REG_ADMIN_URL |
|
| 90 | - ); |
|
| 91 | - // close "href" |
|
| 92 | - $datetime_string .= '"'; |
|
| 93 | - // open "title" tag |
|
| 94 | - $datetime_string .= ' title="'; |
|
| 95 | - // link title text |
|
| 96 | - $datetime_string .= esc_attr__('View Checkins for this Event', 'event_espresso'); |
|
| 97 | - // close "title" tag and end of "a" tag opening |
|
| 98 | - $datetime_string .= '">'; |
|
| 99 | - // link text |
|
| 100 | - $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
| 101 | - // close "a" tag |
|
| 102 | - $datetime_string .= '</a>'; |
|
| 103 | - } else { |
|
| 104 | - $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
| 105 | - } |
|
| 106 | - // add a "View Registrations" link that filters list by event AND datetime |
|
| 107 | - $datetime_string .= $this->row_actions( |
|
| 108 | - array( |
|
| 109 | - 'event_datetime_filter' => '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
| 110 | - array('event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()), |
|
| 111 | - REG_ADMIN_URL |
|
| 112 | - ) |
|
| 113 | - . '" title="' . sprintf( |
|
| 114 | - esc_attr__( |
|
| 115 | - 'Filter this list to only show registrations for this datetime %s', |
|
| 116 | - 'event_espresso' |
|
| 117 | - ), |
|
| 118 | - $datetime->name() |
|
| 119 | - ) . '">' |
|
| 120 | - . esc_html__('View Registrations', 'event_espresso') |
|
| 121 | - . '</a>', |
|
| 122 | - ) |
|
| 123 | - ); |
|
| 124 | - $datetimes_for_display[] = $datetime_string; |
|
| 125 | - } |
|
| 126 | - return $this->generateDisplayForDateTimes($datetimes_for_display); |
|
| 127 | - } |
|
| 53 | + /** |
|
| 54 | + * column_default |
|
| 55 | + * |
|
| 56 | + * @param \EE_Registration $item |
|
| 57 | + * @return string |
|
| 58 | + * @throws EE_Error |
|
| 59 | + * @throws InvalidArgumentException |
|
| 60 | + * @throws InvalidDataTypeException |
|
| 61 | + * @throws InvalidInterfaceException |
|
| 62 | + * @throws ReflectionException |
|
| 63 | + */ |
|
| 64 | + public function column_DTT_EVT_start(EE_Registration $item) |
|
| 65 | + { |
|
| 66 | + $remove_defaults = array('default_where_conditions' => 'none'); |
|
| 67 | + $ticket = $item->ticket(); |
|
| 68 | + $datetimes = $ticket instanceof EE_Ticket ? $ticket->datetimes($remove_defaults) : array(); |
|
| 69 | + $EVT_ID = $item->event_ID(); |
|
| 70 | + $datetimes_for_display = array(); |
|
| 71 | + foreach ($datetimes as $datetime) { |
|
| 72 | + $datetime_string = ''; |
|
| 73 | + if ( |
|
| 74 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 75 | + 'ee_read_checkin', |
|
| 76 | + 'espresso_registrations_registration_checkins', |
|
| 77 | + $item->ID() |
|
| 78 | + ) |
|
| 79 | + ) { |
|
| 80 | + // open "a" tag and "href" |
|
| 81 | + $datetime_string .= '<a href="'; |
|
| 82 | + // checkin URL |
|
| 83 | + $datetime_string .= EE_Admin_Page::add_query_args_and_nonce( |
|
| 84 | + array( |
|
| 85 | + 'action' => 'event_registrations', |
|
| 86 | + 'event_id' => $EVT_ID, |
|
| 87 | + 'DTT_ID' => $datetime->ID(), |
|
| 88 | + ), |
|
| 89 | + REG_ADMIN_URL |
|
| 90 | + ); |
|
| 91 | + // close "href" |
|
| 92 | + $datetime_string .= '"'; |
|
| 93 | + // open "title" tag |
|
| 94 | + $datetime_string .= ' title="'; |
|
| 95 | + // link title text |
|
| 96 | + $datetime_string .= esc_attr__('View Checkins for this Event', 'event_espresso'); |
|
| 97 | + // close "title" tag and end of "a" tag opening |
|
| 98 | + $datetime_string .= '">'; |
|
| 99 | + // link text |
|
| 100 | + $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
| 101 | + // close "a" tag |
|
| 102 | + $datetime_string .= '</a>'; |
|
| 103 | + } else { |
|
| 104 | + $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
| 105 | + } |
|
| 106 | + // add a "View Registrations" link that filters list by event AND datetime |
|
| 107 | + $datetime_string .= $this->row_actions( |
|
| 108 | + array( |
|
| 109 | + 'event_datetime_filter' => '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
| 110 | + array('event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()), |
|
| 111 | + REG_ADMIN_URL |
|
| 112 | + ) |
|
| 113 | + . '" title="' . sprintf( |
|
| 114 | + esc_attr__( |
|
| 115 | + 'Filter this list to only show registrations for this datetime %s', |
|
| 116 | + 'event_espresso' |
|
| 117 | + ), |
|
| 118 | + $datetime->name() |
|
| 119 | + ) . '">' |
|
| 120 | + . esc_html__('View Registrations', 'event_espresso') |
|
| 121 | + . '</a>', |
|
| 122 | + ) |
|
| 123 | + ); |
|
| 124 | + $datetimes_for_display[] = $datetime_string; |
|
| 125 | + } |
|
| 126 | + return $this->generateDisplayForDateTimes($datetimes_for_display); |
|
| 127 | + } |
|
| 128 | 128 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $tax = 0; |
| 40 | 40 | $total_tax = 0; |
| 41 | 41 | // This first checks to see if the given ticket is taxable. |
| 42 | - if (! $ticket->get('TKT_taxable')) { |
|
| 42 | + if ( ! $ticket->get('TKT_taxable')) { |
|
| 43 | 43 | return $tax; |
| 44 | 44 | } |
| 45 | 45 | // get subtotal (notice we're only retrieving a subtotal if there isn't one given) |
@@ -80,8 +80,8 @@ discard block |
||
| 80 | 80 | public static function get_subtotal_for_admin(EE_Ticket $ticket) |
| 81 | 81 | { |
| 82 | 82 | $TKT_ID = $ticket->ID(); |
| 83 | - return isset(self::$_subtotal[ $TKT_ID ]) |
|
| 84 | - ? self::$_subtotal[ $TKT_ID ] |
|
| 83 | + return isset(self::$_subtotal[$TKT_ID]) |
|
| 84 | + ? self::$_subtotal[$TKT_ID] |
|
| 85 | 85 | : self::_get_subtotal_for_admin($ticket); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -9,138 +9,138 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class EE_Taxes extends EE_Base |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * This is used for when EE_Taxes is used statically by the admin |
|
| 14 | - * |
|
| 15 | - * @var array |
|
| 16 | - */ |
|
| 17 | - private static $_subtotal = array(); |
|
| 12 | + /** |
|
| 13 | + * This is used for when EE_Taxes is used statically by the admin |
|
| 14 | + * |
|
| 15 | + * @var array |
|
| 16 | + */ |
|
| 17 | + private static $_subtotal = array(); |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * This holds an array of EE_Price objects that are of PRT_ID == 4 (tax price types) |
|
| 21 | - * |
|
| 22 | - * @var EE_Price[] |
|
| 23 | - */ |
|
| 24 | - private static $_default_taxes = array(); |
|
| 19 | + /** |
|
| 20 | + * This holds an array of EE_Price objects that are of PRT_ID == 4 (tax price types) |
|
| 21 | + * |
|
| 22 | + * @var EE_Price[] |
|
| 23 | + */ |
|
| 24 | + private static $_default_taxes = array(); |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * This method simply calculates the total taxes for a given ticket (by pulling the prices attached to the ticket |
|
| 29 | - * and applying default taxes to it). Note: this is just an intermediary helper method added to facilitate quick |
|
| 30 | - * calc of taxes for tickets listed in the event editor. |
|
| 31 | - * |
|
| 32 | - * @param EE_Ticket $ticket incoming EE_Ticket |
|
| 33 | - * @return float total taxes to apply to ticket. |
|
| 34 | - * @throws \EE_Error |
|
| 35 | - */ |
|
| 36 | - public static function get_total_taxes_for_admin(EE_Ticket $ticket) |
|
| 37 | - { |
|
| 38 | - $tax = 0; |
|
| 39 | - $total_tax = 0; |
|
| 40 | - // This first checks to see if the given ticket is taxable. |
|
| 41 | - if (! $ticket->get('TKT_taxable')) { |
|
| 42 | - return $tax; |
|
| 43 | - } |
|
| 44 | - // get subtotal (notice we're only retrieving a subtotal if there isn't one given) |
|
| 45 | - $subtotal = self::get_subtotal_for_admin($ticket); |
|
| 46 | - // get taxes |
|
| 47 | - $taxes = self::get_taxes_for_admin(); |
|
| 48 | - // apply taxes to subtotal |
|
| 49 | - foreach ($taxes as $tax) { |
|
| 50 | - // assuming taxes are not cumulative |
|
| 51 | - $total_tax += $subtotal * $tax->get('PRC_amount') / 100; |
|
| 52 | - } |
|
| 53 | - return $total_tax; |
|
| 54 | - } |
|
| 27 | + /** |
|
| 28 | + * This method simply calculates the total taxes for a given ticket (by pulling the prices attached to the ticket |
|
| 29 | + * and applying default taxes to it). Note: this is just an intermediary helper method added to facilitate quick |
|
| 30 | + * calc of taxes for tickets listed in the event editor. |
|
| 31 | + * |
|
| 32 | + * @param EE_Ticket $ticket incoming EE_Ticket |
|
| 33 | + * @return float total taxes to apply to ticket. |
|
| 34 | + * @throws \EE_Error |
|
| 35 | + */ |
|
| 36 | + public static function get_total_taxes_for_admin(EE_Ticket $ticket) |
|
| 37 | + { |
|
| 38 | + $tax = 0; |
|
| 39 | + $total_tax = 0; |
|
| 40 | + // This first checks to see if the given ticket is taxable. |
|
| 41 | + if (! $ticket->get('TKT_taxable')) { |
|
| 42 | + return $tax; |
|
| 43 | + } |
|
| 44 | + // get subtotal (notice we're only retrieving a subtotal if there isn't one given) |
|
| 45 | + $subtotal = self::get_subtotal_for_admin($ticket); |
|
| 46 | + // get taxes |
|
| 47 | + $taxes = self::get_taxes_for_admin(); |
|
| 48 | + // apply taxes to subtotal |
|
| 49 | + foreach ($taxes as $tax) { |
|
| 50 | + // assuming taxes are not cumulative |
|
| 51 | + $total_tax += $subtotal * $tax->get('PRC_amount') / 100; |
|
| 52 | + } |
|
| 53 | + return $total_tax; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Gets the total percentage of tax that should be applied to taxable line items |
|
| 59 | - * |
|
| 60 | - * @return float the percentage of tax that should be added to taxable items |
|
| 61 | - * @throws \EE_Error |
|
| 62 | - * eg 20 for %20 tax (NOT 0.20, which |
|
| 63 | - */ |
|
| 64 | - public static function get_total_taxes_percentage() |
|
| 65 | - { |
|
| 66 | - $total_tax_percent = 0; |
|
| 67 | - foreach (self::get_taxes_for_admin() as $tax_price) { |
|
| 68 | - $total_tax_percent += $tax_price->get('PRC_amount'); |
|
| 69 | - } |
|
| 70 | - return $total_tax_percent; |
|
| 71 | - } |
|
| 57 | + /** |
|
| 58 | + * Gets the total percentage of tax that should be applied to taxable line items |
|
| 59 | + * |
|
| 60 | + * @return float the percentage of tax that should be added to taxable items |
|
| 61 | + * @throws \EE_Error |
|
| 62 | + * eg 20 for %20 tax (NOT 0.20, which |
|
| 63 | + */ |
|
| 64 | + public static function get_total_taxes_percentage() |
|
| 65 | + { |
|
| 66 | + $total_tax_percent = 0; |
|
| 67 | + foreach (self::get_taxes_for_admin() as $tax_price) { |
|
| 68 | + $total_tax_percent += $tax_price->get('PRC_amount'); |
|
| 69 | + } |
|
| 70 | + return $total_tax_percent; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @param EE_Ticket $ticket |
|
| 76 | - * @return float |
|
| 77 | - * @throws \EE_Error |
|
| 78 | - */ |
|
| 79 | - public static function get_subtotal_for_admin(EE_Ticket $ticket) |
|
| 80 | - { |
|
| 81 | - $TKT_ID = $ticket->ID(); |
|
| 82 | - return isset(self::$_subtotal[ $TKT_ID ]) |
|
| 83 | - ? self::$_subtotal[ $TKT_ID ] |
|
| 84 | - : self::_get_subtotal_for_admin($ticket); |
|
| 85 | - } |
|
| 74 | + /** |
|
| 75 | + * @param EE_Ticket $ticket |
|
| 76 | + * @return float |
|
| 77 | + * @throws \EE_Error |
|
| 78 | + */ |
|
| 79 | + public static function get_subtotal_for_admin(EE_Ticket $ticket) |
|
| 80 | + { |
|
| 81 | + $TKT_ID = $ticket->ID(); |
|
| 82 | + return isset(self::$_subtotal[ $TKT_ID ]) |
|
| 83 | + ? self::$_subtotal[ $TKT_ID ] |
|
| 84 | + : self::_get_subtotal_for_admin($ticket); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * simply take an incoming ticket and calculate the subtotal for the ticket |
|
| 90 | - * |
|
| 91 | - * @param EE_Ticket $ticket |
|
| 92 | - * @return float subtotal calculated from all EE_Price[] on Ticket. |
|
| 93 | - * @throws \EE_Error |
|
| 94 | - */ |
|
| 95 | - private static function _get_subtotal_for_admin(EE_Ticket $ticket) |
|
| 96 | - { |
|
| 97 | - $subtotal = 0; |
|
| 98 | - // get all prices |
|
| 99 | - $prices = $ticket->get_many_related( |
|
| 100 | - 'Price', |
|
| 101 | - array( |
|
| 102 | - 'default_where_conditions' => 'none', |
|
| 103 | - 'order_by' => array('PRC_order' => 'ASC'), |
|
| 104 | - ) |
|
| 105 | - ); |
|
| 106 | - // let's loop through them (base price is always the first item) |
|
| 107 | - foreach ($prices as $price) { |
|
| 108 | - if ($price instanceof EE_Price) { |
|
| 109 | - $price_type = $price->type_obj(); |
|
| 110 | - if ($price_type instanceof EE_Price_Type) { |
|
| 111 | - switch ($price->type_obj()->base_type()) { |
|
| 112 | - case 1: // base price |
|
| 113 | - case 3: // surcharges |
|
| 114 | - $subtotal += $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100 |
|
| 115 | - : $price->get('PRC_amount'); |
|
| 116 | - break; |
|
| 117 | - case 2: // discounts |
|
| 118 | - $subtotal -= $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100 |
|
| 119 | - : $price->get('PRC_amount'); |
|
| 120 | - break; |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - $TKT_ID = $ticket->ID(); |
|
| 126 | - self::$_subtotal = array($TKT_ID => $subtotal); |
|
| 127 | - return $subtotal; |
|
| 128 | - } |
|
| 88 | + /** |
|
| 89 | + * simply take an incoming ticket and calculate the subtotal for the ticket |
|
| 90 | + * |
|
| 91 | + * @param EE_Ticket $ticket |
|
| 92 | + * @return float subtotal calculated from all EE_Price[] on Ticket. |
|
| 93 | + * @throws \EE_Error |
|
| 94 | + */ |
|
| 95 | + private static function _get_subtotal_for_admin(EE_Ticket $ticket) |
|
| 96 | + { |
|
| 97 | + $subtotal = 0; |
|
| 98 | + // get all prices |
|
| 99 | + $prices = $ticket->get_many_related( |
|
| 100 | + 'Price', |
|
| 101 | + array( |
|
| 102 | + 'default_where_conditions' => 'none', |
|
| 103 | + 'order_by' => array('PRC_order' => 'ASC'), |
|
| 104 | + ) |
|
| 105 | + ); |
|
| 106 | + // let's loop through them (base price is always the first item) |
|
| 107 | + foreach ($prices as $price) { |
|
| 108 | + if ($price instanceof EE_Price) { |
|
| 109 | + $price_type = $price->type_obj(); |
|
| 110 | + if ($price_type instanceof EE_Price_Type) { |
|
| 111 | + switch ($price->type_obj()->base_type()) { |
|
| 112 | + case 1: // base price |
|
| 113 | + case 3: // surcharges |
|
| 114 | + $subtotal += $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100 |
|
| 115 | + : $price->get('PRC_amount'); |
|
| 116 | + break; |
|
| 117 | + case 2: // discounts |
|
| 118 | + $subtotal -= $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100 |
|
| 119 | + : $price->get('PRC_amount'); |
|
| 120 | + break; |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + $TKT_ID = $ticket->ID(); |
|
| 126 | + self::$_subtotal = array($TKT_ID => $subtotal); |
|
| 127 | + return $subtotal; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * get all default prices that are a Tax price type (PRT_ID = 4) and return |
|
| 133 | - * |
|
| 134 | - * @return EE_Price[] EE_Price objects that have PRT_ID == 4 |
|
| 135 | - * @throws \EE_Error |
|
| 136 | - */ |
|
| 137 | - public static function get_taxes_for_admin() |
|
| 138 | - { |
|
| 139 | - if (empty(self::$_default_taxes)) { |
|
| 140 | - self::$_default_taxes = EE_Registry::instance()->load_model('Price')->get_all( |
|
| 141 | - array(array('Price_Type.PBT_ID' => 4)) |
|
| 142 | - ); |
|
| 143 | - } |
|
| 144 | - return self::$_default_taxes; |
|
| 145 | - } |
|
| 131 | + /** |
|
| 132 | + * get all default prices that are a Tax price type (PRT_ID = 4) and return |
|
| 133 | + * |
|
| 134 | + * @return EE_Price[] EE_Price objects that have PRT_ID == 4 |
|
| 135 | + * @throws \EE_Error |
|
| 136 | + */ |
|
| 137 | + public static function get_taxes_for_admin() |
|
| 138 | + { |
|
| 139 | + if (empty(self::$_default_taxes)) { |
|
| 140 | + self::$_default_taxes = EE_Registry::instance()->load_model('Price')->get_all( |
|
| 141 | + array(array('Price_Type.PBT_ID' => 4)) |
|
| 142 | + ); |
|
| 143 | + } |
|
| 144 | + return self::$_default_taxes; |
|
| 145 | + } |
|
| 146 | 146 | } |