@@ -10,296 +10,296 @@ |
||
| 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()->click(MessagesPage::MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE); |
|
| 159 | - if ($expected_state_is_active) { |
|
| 160 | - $this->actor()->waitForText("The template for $context_string is currently active."); |
|
| 161 | - } else { |
|
| 162 | - $this->actor()->waitForText("The template for $context_string is currently inactive"); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Triggers saving the message template. |
|
| 169 | - * @param bool $and_close Use to indicate to click the Save and Close button. |
|
| 170 | - */ |
|
| 171 | - public function saveMessageTemplate($and_close = false) |
|
| 172 | - { |
|
| 173 | - $this->actor()->scrollTo(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR); |
|
| 174 | - if ($and_close) { |
|
| 175 | - $this->actor()->click('Save and Close'); |
|
| 176 | - } else { |
|
| 177 | - $this->actor()->click('Save'); |
|
| 178 | - } |
|
| 179 | - $this->actor()->waitForText('successfully updated'); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * This takes care of clicking the View Message icon for the given parameters. |
|
| 185 | - * Assumes you are already viewing the messages activity list table. |
|
| 186 | - * @param $message_type_label |
|
| 187 | - * @param $message_status |
|
| 188 | - * @param string $messenger |
|
| 189 | - * @param string $context |
|
| 190 | - * @param int $number_in_set |
|
| 191 | - */ |
|
| 192 | - public function viewMessageInMessagesListTableFor( |
|
| 193 | - $message_type_label, |
|
| 194 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
| 195 | - $messenger = 'Email', |
|
| 196 | - $context = 'Event Admin', |
|
| 197 | - $number_in_set = 1 |
|
| 198 | - ) { |
|
| 199 | - $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor( |
|
| 200 | - $message_type_label, |
|
| 201 | - $message_status, |
|
| 202 | - $messenger, |
|
| 203 | - $context, |
|
| 204 | - $number_in_set |
|
| 205 | - )); |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * Takes care of deleting a message matching the given parameters via the message activity list table. |
|
| 211 | - * Assumes you are already viewing the messages activity list table. |
|
| 212 | - * @param $message_type_label |
|
| 213 | - * @param $message_status |
|
| 214 | - * @param string $messenger |
|
| 215 | - * @param string $context |
|
| 216 | - * @param int $number_in_set |
|
| 217 | - */ |
|
| 218 | - public function deleteMessageInMessagesListTableFor( |
|
| 219 | - $message_type_label, |
|
| 220 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
| 221 | - $messenger = 'Email', |
|
| 222 | - $context = 'Event Admin', |
|
| 223 | - $number_in_set = 1 |
|
| 224 | - ) { |
|
| 225 | - $delete_action_selector = MessagesPage::messagesActivityListTableDeleteActionSelectorFor( |
|
| 226 | - $message_type_label, |
|
| 227 | - $message_status, |
|
| 228 | - $messenger, |
|
| 229 | - $context, |
|
| 230 | - $number_in_set |
|
| 231 | - ); |
|
| 232 | - $cell_selector = MessagesPage::messagesActivityListTableCellSelectorFor( |
|
| 233 | - 'to', |
|
| 234 | - $message_type_label, |
|
| 235 | - $message_status, |
|
| 236 | - $messenger, |
|
| 237 | - $context, |
|
| 238 | - '', |
|
| 239 | - $number_in_set |
|
| 240 | - ); |
|
| 241 | - $this->actor()->scrollTo($cell_selector, 0, -30); |
|
| 242 | - $this->actor()->moveMouseOver( |
|
| 243 | - $cell_selector, |
|
| 244 | - 5, |
|
| 245 | - 5 |
|
| 246 | - ); |
|
| 247 | - $this->actor()->waitForElementVisible( |
|
| 248 | - $delete_action_selector |
|
| 249 | - ); |
|
| 250 | - $this->actor()->click( |
|
| 251 | - $delete_action_selector |
|
| 252 | - ); |
|
| 253 | - $this->actor()->waitForText('successfully deleted', 20); |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - |
|
| 257 | - /** |
|
| 258 | - * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
| 259 | - * list table, this will take care of validating the given text is in that window. |
|
| 260 | - * @param string $text_to_view |
|
| 261 | - */ |
|
| 262 | - public function seeTextInViewMessageModal($text_to_view, $should_not_see = false) |
|
| 263 | - { |
|
| 264 | - $this->actor()->wait(2); |
|
| 265 | - $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
| 266 | - $this->actor()->switchToIframe('message-view-window'); |
|
| 267 | - $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view); |
|
| 268 | - $this->actor()->switchToIframe(); |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - |
|
| 272 | - /** |
|
| 273 | - * This returns the value for the link at the given selector in the message modal. |
|
| 274 | - * @param string $selector (any selector string accepted by WebDriver) |
|
| 275 | - */ |
|
| 276 | - public function observeLinkAtSelectorInMessageModal($selector) |
|
| 277 | - { |
|
| 278 | - $this->actor()->wait(2); |
|
| 279 | - $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
| 280 | - $this->actor()->switchToIframe('message-view-window'); |
|
| 281 | - $link = $this->actor()->observeLinkUrlAt($selector); |
|
| 282 | - $this->actor()->switchToIframe(); |
|
| 283 | - return $link; |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
| 289 | - * list table, this will take care of validating the given text is NOT that window. |
|
| 290 | - * @param string $text_to_view |
|
| 291 | - */ |
|
| 292 | - public function dontSeeTextInViewMessageModal($text_to_view) |
|
| 293 | - { |
|
| 294 | - $this->seeTextInViewMessageModal($text_to_view, true); |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - |
|
| 298 | - public function dismissMessageModal() |
|
| 299 | - { |
|
| 300 | - $this->actor()->executeJs('window.dialogHelper.closeModal()'); |
|
| 301 | - //this is needed otherwise phantom js gets stuck in the wrong context and any future element events will fail. |
|
| 302 | - $this->actor()->scrollTo('form#EE_Message_List_Table-table-frm'); |
|
| 303 | - $this->actor()->click('form#EE_Message_List_Table-table-frm'); |
|
| 304 | - } |
|
| 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()->click(MessagesPage::MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE); |
|
| 159 | + if ($expected_state_is_active) { |
|
| 160 | + $this->actor()->waitForText("The template for $context_string is currently active."); |
|
| 161 | + } else { |
|
| 162 | + $this->actor()->waitForText("The template for $context_string is currently inactive"); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Triggers saving the message template. |
|
| 169 | + * @param bool $and_close Use to indicate to click the Save and Close button. |
|
| 170 | + */ |
|
| 171 | + public function saveMessageTemplate($and_close = false) |
|
| 172 | + { |
|
| 173 | + $this->actor()->scrollTo(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR); |
|
| 174 | + if ($and_close) { |
|
| 175 | + $this->actor()->click('Save and Close'); |
|
| 176 | + } else { |
|
| 177 | + $this->actor()->click('Save'); |
|
| 178 | + } |
|
| 179 | + $this->actor()->waitForText('successfully updated'); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * This takes care of clicking the View Message icon for the given parameters. |
|
| 185 | + * Assumes you are already viewing the messages activity list table. |
|
| 186 | + * @param $message_type_label |
|
| 187 | + * @param $message_status |
|
| 188 | + * @param string $messenger |
|
| 189 | + * @param string $context |
|
| 190 | + * @param int $number_in_set |
|
| 191 | + */ |
|
| 192 | + public function viewMessageInMessagesListTableFor( |
|
| 193 | + $message_type_label, |
|
| 194 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
| 195 | + $messenger = 'Email', |
|
| 196 | + $context = 'Event Admin', |
|
| 197 | + $number_in_set = 1 |
|
| 198 | + ) { |
|
| 199 | + $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor( |
|
| 200 | + $message_type_label, |
|
| 201 | + $message_status, |
|
| 202 | + $messenger, |
|
| 203 | + $context, |
|
| 204 | + $number_in_set |
|
| 205 | + )); |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * Takes care of deleting a message matching the given parameters via the message activity list table. |
|
| 211 | + * Assumes you are already viewing the messages activity list table. |
|
| 212 | + * @param $message_type_label |
|
| 213 | + * @param $message_status |
|
| 214 | + * @param string $messenger |
|
| 215 | + * @param string $context |
|
| 216 | + * @param int $number_in_set |
|
| 217 | + */ |
|
| 218 | + public function deleteMessageInMessagesListTableFor( |
|
| 219 | + $message_type_label, |
|
| 220 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
| 221 | + $messenger = 'Email', |
|
| 222 | + $context = 'Event Admin', |
|
| 223 | + $number_in_set = 1 |
|
| 224 | + ) { |
|
| 225 | + $delete_action_selector = MessagesPage::messagesActivityListTableDeleteActionSelectorFor( |
|
| 226 | + $message_type_label, |
|
| 227 | + $message_status, |
|
| 228 | + $messenger, |
|
| 229 | + $context, |
|
| 230 | + $number_in_set |
|
| 231 | + ); |
|
| 232 | + $cell_selector = MessagesPage::messagesActivityListTableCellSelectorFor( |
|
| 233 | + 'to', |
|
| 234 | + $message_type_label, |
|
| 235 | + $message_status, |
|
| 236 | + $messenger, |
|
| 237 | + $context, |
|
| 238 | + '', |
|
| 239 | + $number_in_set |
|
| 240 | + ); |
|
| 241 | + $this->actor()->scrollTo($cell_selector, 0, -30); |
|
| 242 | + $this->actor()->moveMouseOver( |
|
| 243 | + $cell_selector, |
|
| 244 | + 5, |
|
| 245 | + 5 |
|
| 246 | + ); |
|
| 247 | + $this->actor()->waitForElementVisible( |
|
| 248 | + $delete_action_selector |
|
| 249 | + ); |
|
| 250 | + $this->actor()->click( |
|
| 251 | + $delete_action_selector |
|
| 252 | + ); |
|
| 253 | + $this->actor()->waitForText('successfully deleted', 20); |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + |
|
| 257 | + /** |
|
| 258 | + * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
| 259 | + * list table, this will take care of validating the given text is in that window. |
|
| 260 | + * @param string $text_to_view |
|
| 261 | + */ |
|
| 262 | + public function seeTextInViewMessageModal($text_to_view, $should_not_see = false) |
|
| 263 | + { |
|
| 264 | + $this->actor()->wait(2); |
|
| 265 | + $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
| 266 | + $this->actor()->switchToIframe('message-view-window'); |
|
| 267 | + $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view); |
|
| 268 | + $this->actor()->switchToIframe(); |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + |
|
| 272 | + /** |
|
| 273 | + * This returns the value for the link at the given selector in the message modal. |
|
| 274 | + * @param string $selector (any selector string accepted by WebDriver) |
|
| 275 | + */ |
|
| 276 | + public function observeLinkAtSelectorInMessageModal($selector) |
|
| 277 | + { |
|
| 278 | + $this->actor()->wait(2); |
|
| 279 | + $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
| 280 | + $this->actor()->switchToIframe('message-view-window'); |
|
| 281 | + $link = $this->actor()->observeLinkUrlAt($selector); |
|
| 282 | + $this->actor()->switchToIframe(); |
|
| 283 | + return $link; |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
| 289 | + * list table, this will take care of validating the given text is NOT that window. |
|
| 290 | + * @param string $text_to_view |
|
| 291 | + */ |
|
| 292 | + public function dontSeeTextInViewMessageModal($text_to_view) |
|
| 293 | + { |
|
| 294 | + $this->seeTextInViewMessageModal($text_to_view, true); |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + |
|
| 298 | + public function dismissMessageModal() |
|
| 299 | + { |
|
| 300 | + $this->actor()->executeJs('window.dialogHelper.closeModal()'); |
|
| 301 | + //this is needed otherwise phantom js gets stuck in the wrong context and any future element events will fail. |
|
| 302 | + $this->actor()->scrollTo('form#EE_Message_List_Table-table-frm'); |
|
| 303 | + $this->actor()->click('form#EE_Message_List_Table-table-frm'); |
|
| 304 | + } |
|
| 305 | 305 | } |
@@ -6,59 +6,59 @@ |
||
| 6 | 6 | |
| 7 | 7 | trait CountrySettingsAdmin |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Instructs the actor to browse to the country settings page. |
|
| 11 | - * Assumes the actor is already logged in. |
|
| 12 | - * @param string $additional_params |
|
| 13 | - */ |
|
| 14 | - public function amOnCountrySettingsAdminPage($additional_params = '') |
|
| 15 | - { |
|
| 16 | - $this->actor()->amOnAdminPage(CountrySettings::url($additional_params)); |
|
| 17 | - } |
|
| 9 | + /** |
|
| 10 | + * Instructs the actor to browse to the country settings page. |
|
| 11 | + * Assumes the actor is already logged in. |
|
| 12 | + * @param string $additional_params |
|
| 13 | + */ |
|
| 14 | + public function amOnCountrySettingsAdminPage($additional_params = '') |
|
| 15 | + { |
|
| 16 | + $this->actor()->amOnAdminPage(CountrySettings::url($additional_params)); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Instructs the actor to select the given decimal places radio option. |
|
| 22 | - * Assumes the actor is already on the country settings page. |
|
| 23 | - * @param string $decimal_places |
|
| 24 | - * @param string $country_code |
|
| 25 | - */ |
|
| 26 | - public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US') |
|
| 27 | - { |
|
| 28 | - $this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code)); |
|
| 29 | - } |
|
| 20 | + /** |
|
| 21 | + * Instructs the actor to select the given decimal places radio option. |
|
| 22 | + * Assumes the actor is already on the country settings page. |
|
| 23 | + * @param string $decimal_places |
|
| 24 | + * @param string $country_code |
|
| 25 | + */ |
|
| 26 | + public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US') |
|
| 27 | + { |
|
| 28 | + $this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code)); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Instructs the actor to select the given decimal mark radio option. |
|
| 34 | - * Assumes the actor is already on the country settings page. |
|
| 35 | - * @param string $decimal_mark |
|
| 36 | - */ |
|
| 37 | - public function setCurrencyDecimalMarkTo($decimal_mark = '.') |
|
| 38 | - { |
|
| 39 | - $this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark)); |
|
| 40 | - } |
|
| 32 | + /** |
|
| 33 | + * Instructs the actor to select the given decimal mark radio option. |
|
| 34 | + * Assumes the actor is already on the country settings page. |
|
| 35 | + * @param string $decimal_mark |
|
| 36 | + */ |
|
| 37 | + public function setCurrencyDecimalMarkTo($decimal_mark = '.') |
|
| 38 | + { |
|
| 39 | + $this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark)); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Instructs the actor to select the given thousands separator radio option. |
|
| 45 | - * Assumes the actor is already on the country settings page. |
|
| 46 | - * @param string $thousands_seperator |
|
| 47 | - */ |
|
| 48 | - public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',') |
|
| 49 | - { |
|
| 50 | - $this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator)); |
|
| 51 | - } |
|
| 43 | + /** |
|
| 44 | + * Instructs the actor to select the given thousands separator radio option. |
|
| 45 | + * Assumes the actor is already on the country settings page. |
|
| 46 | + * @param string $thousands_seperator |
|
| 47 | + */ |
|
| 48 | + public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',') |
|
| 49 | + { |
|
| 50 | + $this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator)); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Clicks the country settings submit button. |
|
| 56 | - * Assumes the actor is on the country settings admin page. |
|
| 57 | - */ |
|
| 58 | - public function saveCountrySettings() |
|
| 59 | - { |
|
| 60 | - $this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON); |
|
| 61 | - //no indicator on the page when stuff has been updated so just give a bit of time for it to finish. |
|
| 62 | - $this->actor()->wait(10); |
|
| 63 | - } |
|
| 54 | + /** |
|
| 55 | + * Clicks the country settings submit button. |
|
| 56 | + * Assumes the actor is on the country settings admin page. |
|
| 57 | + */ |
|
| 58 | + public function saveCountrySettings() |
|
| 59 | + { |
|
| 60 | + $this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON); |
|
| 61 | + //no indicator on the page when stuff has been updated so just give a bit of time for it to finish. |
|
| 62 | + $this->actor()->wait(10); |
|
| 63 | + } |
|
| 64 | 64 | } |
| 65 | 65 | \ No newline at end of file |
@@ -1,16 +1,16 @@ |
||
| 1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
| 2 | 2 | /** |
| 3 | - * |
|
| 4 | - * Class EE_SPCO_JSON_Response |
|
| 5 | - * |
|
| 6 | - * Description |
|
| 7 | - * |
|
| 8 | - * @package Event Espresso |
|
| 9 | - * @subpackage core |
|
| 10 | - * @author Brent Christensen |
|
| 11 | - * |
|
| 12 | - * |
|
| 13 | - */ |
|
| 3 | + * |
|
| 4 | + * Class EE_SPCO_JSON_Response |
|
| 5 | + * |
|
| 6 | + * Description |
|
| 7 | + * |
|
| 8 | + * @package Event Espresso |
|
| 9 | + * @subpackage core |
|
| 10 | + * @author Brent Christensen |
|
| 11 | + * |
|
| 12 | + * |
|
| 13 | + */ |
|
| 14 | 14 | class EE_SPCO_JSON_Response { |
| 15 | 15 | |
| 16 | 16 | /** |
@@ -21,26 +21,26 @@ |
||
| 21 | 21 | * |
| 22 | 22 | * |
| 23 | 23 | */ |
| 24 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
| 24 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 25 | 25 | exit('No direct script access allowed'); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | -class EEM_Extra_Join extends EEM_Base{ |
|
| 28 | +class EEM_Extra_Join extends EEM_Base { |
|
| 29 | 29 | // private instance of the Extra Join object |
| 30 | 30 | protected static $_instance = NULL; |
| 31 | 31 | |
| 32 | 32 | public function __construct($timezone = NULL) { |
| 33 | - $models_this_can_join = array_keys( EE_Registry::instance()->non_abstract_db_models ); |
|
| 33 | + $models_this_can_join = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
| 34 | 34 | $this->_tables = array( |
| 35 | - 'Extra_Join' => new EE_Primary_Table( 'esp_extra_join', 'EXJ_ID' ), |
|
| 35 | + 'Extra_Join' => new EE_Primary_Table('esp_extra_join', 'EXJ_ID'), |
|
| 36 | 36 | ); |
| 37 | 37 | $this->_fields = array( |
| 38 | 38 | 'Extra_Join' => array( |
| 39 | - 'EXJ_ID' => new EE_Primary_Key_Int_Field( 'EXJ_ID', __( 'Extra Join ID', 'event_espresso' ) ), |
|
| 40 | - 'EXJ_first_model_ID' => new EE_Foreign_Key_String_Field( 'EXJ_first_model_ID', __( 'First Model ID', 'event_espresso' ), true, 0, $models_this_can_join ), |
|
| 41 | - 'EXJ_first_model_name' => new EE_Any_Foreign_Model_Name_Field( 'EXJ_first_model_name', __( 'First Model Name', 'event_espresso'), true, '', $models_this_can_join ), |
|
| 42 | - 'EXJ_second_model_ID' => new EE_Foreign_Key_String_Field( 'EXJ_second_model_ID', __( 'Second Model ID', 'event_espresso' ), true, 0, $models_this_can_join ), |
|
| 43 | - 'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field( 'EXJ_second_model_name', __( 'Second Model Name', 'event_espresso'), true, '', $models_this_can_join ), |
|
| 39 | + 'EXJ_ID' => new EE_Primary_Key_Int_Field('EXJ_ID', __('Extra Join ID', 'event_espresso')), |
|
| 40 | + 'EXJ_first_model_ID' => new EE_Foreign_Key_String_Field('EXJ_first_model_ID', __('First Model ID', 'event_espresso'), true, 0, $models_this_can_join), |
|
| 41 | + 'EXJ_first_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_first_model_name', __('First Model Name', 'event_espresso'), true, '', $models_this_can_join), |
|
| 42 | + 'EXJ_second_model_ID' => new EE_Foreign_Key_String_Field('EXJ_second_model_ID', __('Second Model ID', 'event_espresso'), true, 0, $models_this_can_join), |
|
| 43 | + 'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_second_model_name', __('Second Model Name', 'event_espresso'), true, '', $models_this_can_join), |
|
| 44 | 44 | |
| 45 | 45 | ) |
| 46 | 46 | ); |
@@ -1,21 +1,21 @@ |
||
| 1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
| 2 | 2 | /** |
| 3 | - * |
|
| 4 | - * Class EEH_HTML |
|
| 5 | - * |
|
| 3 | + * |
|
| 4 | + * Class EEH_HTML |
|
| 5 | + * |
|
| 6 | 6 | * Sometimes when writing PHP you need to generate some standard HTML, |
| 7 | 7 | * but either not enough to warrant creating a template file, |
| 8 | 8 | * or the amount of PHP conditionals and/or loops peppered throughout the HTML |
| 9 | 9 | * just make it really ugly and difficult to read. |
| 10 | 10 | * This class simply adds a bunch of methods for generating basic HTML tags. |
| 11 | 11 | * Most of the methods have the same name as the HTML tag they generate, and most have the same set of parameters. |
| 12 | - * |
|
| 13 | - * @package Event Espresso |
|
| 14 | - * @subpackage core |
|
| 15 | - * @author Brent Christensen |
|
| 16 | - * |
|
| 17 | - * |
|
| 18 | - */ |
|
| 12 | + * |
|
| 13 | + * @package Event Espresso |
|
| 14 | + * @subpackage core |
|
| 15 | + * @author Brent Christensen |
|
| 16 | + * |
|
| 17 | + * |
|
| 18 | + */ |
|
| 19 | 19 | |
| 20 | 20 | class EEH_HTML { |
| 21 | 21 | |
@@ -12,8 +12,7 @@ |
||
| 12 | 12 | * DTO for passing data to a UpdateRegistrationAndTransactionAfterChangeCommandHandler |
| 13 | 13 | * |
| 14 | 14 | * @package Event Espresso |
| 15 | - |
|
| 16 | -*@author Brent Christensen |
|
| 15 | + *@author Brent Christensen |
|
| 17 | 16 | * |
| 18 | 17 | */ |
| 19 | 18 | class UpdateRegistrationAndTransactionAfterChangeCommand extends SingleRegistrationCommand |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | 14 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 15 | - exit('No direct script access allowed'); |
|
| 15 | + exit('No direct script access allowed'); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | |
@@ -20,54 +20,54 @@ discard block |
||
| 20 | 20 | class RestException extends \EE_Error |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @var array |
|
| 25 | - */ |
|
| 26 | - protected $wp_error_data = array(); |
|
| 23 | + /** |
|
| 24 | + * @var array |
|
| 25 | + */ |
|
| 26 | + protected $wp_error_data = array(); |
|
| 27 | 27 | |
| 28 | - protected $wp_error_code = ''; |
|
| 28 | + protected $wp_error_code = ''; |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | |
| 32 | - public function __construct($string_code, $message, $wp_error_data = array(), $previous = null) |
|
| 33 | - { |
|
| 34 | - if (is_array($wp_error_data) |
|
| 35 | - && isset($wp_error_data['status']) |
|
| 36 | - ) { |
|
| 37 | - $http_status_number = $wp_error_data['status']; |
|
| 38 | - } else { |
|
| 39 | - $http_status_number = 500; |
|
| 40 | - } |
|
| 41 | - parent::__construct( |
|
| 42 | - $message, |
|
| 43 | - $http_status_number, |
|
| 44 | - $previous |
|
| 45 | - ); |
|
| 46 | - $this->wp_error_data = $wp_error_data; |
|
| 47 | - $this->wp_error_code = $string_code; |
|
| 48 | - } |
|
| 32 | + public function __construct($string_code, $message, $wp_error_data = array(), $previous = null) |
|
| 33 | + { |
|
| 34 | + if (is_array($wp_error_data) |
|
| 35 | + && isset($wp_error_data['status']) |
|
| 36 | + ) { |
|
| 37 | + $http_status_number = $wp_error_data['status']; |
|
| 38 | + } else { |
|
| 39 | + $http_status_number = 500; |
|
| 40 | + } |
|
| 41 | + parent::__construct( |
|
| 42 | + $message, |
|
| 43 | + $http_status_number, |
|
| 44 | + $previous |
|
| 45 | + ); |
|
| 46 | + $this->wp_error_data = $wp_error_data; |
|
| 47 | + $this->wp_error_code = $string_code; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Array of data that may have been set during the constructor, intended for WP_Error's data |
|
| 54 | - * |
|
| 55 | - * @return array |
|
| 56 | - */ |
|
| 57 | - public function getData() |
|
| 58 | - { |
|
| 59 | - return $this->wp_error_data; |
|
| 60 | - } |
|
| 52 | + /** |
|
| 53 | + * Array of data that may have been set during the constructor, intended for WP_Error's data |
|
| 54 | + * |
|
| 55 | + * @return array |
|
| 56 | + */ |
|
| 57 | + public function getData() |
|
| 58 | + { |
|
| 59 | + return $this->wp_error_data; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | |
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Gets the error string |
|
| 66 | - * |
|
| 67 | - * @return string |
|
| 68 | - */ |
|
| 69 | - public function getStringCode() |
|
| 70 | - { |
|
| 71 | - return $this->wp_error_code; |
|
| 72 | - } |
|
| 64 | + /** |
|
| 65 | + * Gets the error string |
|
| 66 | + * |
|
| 67 | + * @return string |
|
| 68 | + */ |
|
| 69 | + public function getStringCode() |
|
| 70 | + { |
|
| 71 | + return $this->wp_error_code; |
|
| 72 | + } |
|
| 73 | 73 | } |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | * @author Mike Nelson |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 14 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 15 | 15 | exit('No direct script access allowed'); |
| 16 | 16 | } |
| 17 | 17 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | 19 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 20 | - exit('No direct script access allowed'); |
|
| 20 | + exit('No direct script access allowed'); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -25,62 +25,62 @@ discard block |
||
| 25 | 25 | class Registration extends Calculations_Base |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Calculates the checkin status for each datetime this registration has access to |
|
| 30 | - * |
|
| 31 | - * @param array $wpdb_row |
|
| 32 | - * @param \WP_REST_Request $request |
|
| 33 | - * @param Base $controller |
|
| 34 | - * @return array |
|
| 35 | - * @throws \EE_Error |
|
| 36 | - */ |
|
| 37 | - public static function datetimeCheckinStati($wpdb_row, $request, $controller) |
|
| 38 | - { |
|
| 39 | - if (is_array($wpdb_row) && isset($wpdb_row['Registration.REG_ID'])) { |
|
| 40 | - $reg = EEM_Registration::instance()->get_one_by_ID($wpdb_row['Registration.REG_ID']); |
|
| 41 | - } else { |
|
| 42 | - $reg = null; |
|
| 43 | - } |
|
| 44 | - if (! $reg instanceof EE_Registration |
|
| 45 | - ) { |
|
| 46 | - throw new \EE_Error( |
|
| 47 | - sprintf( |
|
| 48 | - __( |
|
| 49 | - // @codingStandardsIgnoreStart |
|
| 50 | - 'Cannot calculate datetime_checkin_stati because the registration with ID %1$s (from database row %2$s) was not found', |
|
| 51 | - // @codingStandardsIgnoreEnd |
|
| 52 | - 'event_espresso' |
|
| 53 | - ), |
|
| 54 | - $wpdb_row['Registration.REG_ID'], |
|
| 55 | - print_r($wpdb_row, true) |
|
| 56 | - ) |
|
| 57 | - ); |
|
| 58 | - } |
|
| 59 | - $datetime_ids = EEM_Datetime::instance()->get_col( |
|
| 60 | - array( |
|
| 61 | - array( |
|
| 62 | - 'Ticket.TKT_ID' => $reg->ticket_ID(), |
|
| 63 | - ), |
|
| 64 | - 'default_where_conditions' => \EEM_Base::default_where_conditions_minimum_all |
|
| 65 | - ) |
|
| 66 | - ); |
|
| 67 | - $checkin_stati = array(); |
|
| 68 | - foreach ($datetime_ids as $datetime_id) { |
|
| 69 | - $status = $reg->check_in_status_for_datetime($datetime_id); |
|
| 70 | - switch ($status) { |
|
| 71 | - case EE_Checkin::status_checked_out: |
|
| 72 | - $status_pretty = 'OUT'; |
|
| 73 | - break; |
|
| 74 | - case EE_Checkin::status_checked_in: |
|
| 75 | - $status_pretty = 'IN'; |
|
| 76 | - break; |
|
| 77 | - case EE_Checkin::status_checked_never: |
|
| 78 | - default: |
|
| 79 | - $status_pretty = 'NEVER'; |
|
| 80 | - break; |
|
| 81 | - } |
|
| 82 | - $checkin_stati[$datetime_id] = $status_pretty; |
|
| 83 | - } |
|
| 84 | - return $checkin_stati; |
|
| 85 | - } |
|
| 28 | + /** |
|
| 29 | + * Calculates the checkin status for each datetime this registration has access to |
|
| 30 | + * |
|
| 31 | + * @param array $wpdb_row |
|
| 32 | + * @param \WP_REST_Request $request |
|
| 33 | + * @param Base $controller |
|
| 34 | + * @return array |
|
| 35 | + * @throws \EE_Error |
|
| 36 | + */ |
|
| 37 | + public static function datetimeCheckinStati($wpdb_row, $request, $controller) |
|
| 38 | + { |
|
| 39 | + if (is_array($wpdb_row) && isset($wpdb_row['Registration.REG_ID'])) { |
|
| 40 | + $reg = EEM_Registration::instance()->get_one_by_ID($wpdb_row['Registration.REG_ID']); |
|
| 41 | + } else { |
|
| 42 | + $reg = null; |
|
| 43 | + } |
|
| 44 | + if (! $reg instanceof EE_Registration |
|
| 45 | + ) { |
|
| 46 | + throw new \EE_Error( |
|
| 47 | + sprintf( |
|
| 48 | + __( |
|
| 49 | + // @codingStandardsIgnoreStart |
|
| 50 | + 'Cannot calculate datetime_checkin_stati because the registration with ID %1$s (from database row %2$s) was not found', |
|
| 51 | + // @codingStandardsIgnoreEnd |
|
| 52 | + 'event_espresso' |
|
| 53 | + ), |
|
| 54 | + $wpdb_row['Registration.REG_ID'], |
|
| 55 | + print_r($wpdb_row, true) |
|
| 56 | + ) |
|
| 57 | + ); |
|
| 58 | + } |
|
| 59 | + $datetime_ids = EEM_Datetime::instance()->get_col( |
|
| 60 | + array( |
|
| 61 | + array( |
|
| 62 | + 'Ticket.TKT_ID' => $reg->ticket_ID(), |
|
| 63 | + ), |
|
| 64 | + 'default_where_conditions' => \EEM_Base::default_where_conditions_minimum_all |
|
| 65 | + ) |
|
| 66 | + ); |
|
| 67 | + $checkin_stati = array(); |
|
| 68 | + foreach ($datetime_ids as $datetime_id) { |
|
| 69 | + $status = $reg->check_in_status_for_datetime($datetime_id); |
|
| 70 | + switch ($status) { |
|
| 71 | + case EE_Checkin::status_checked_out: |
|
| 72 | + $status_pretty = 'OUT'; |
|
| 73 | + break; |
|
| 74 | + case EE_Checkin::status_checked_in: |
|
| 75 | + $status_pretty = 'IN'; |
|
| 76 | + break; |
|
| 77 | + case EE_Checkin::status_checked_never: |
|
| 78 | + default: |
|
| 79 | + $status_pretty = 'NEVER'; |
|
| 80 | + break; |
|
| 81 | + } |
|
| 82 | + $checkin_stati[$datetime_id] = $status_pretty; |
|
| 83 | + } |
|
| 84 | + return $checkin_stati; |
|
| 85 | + } |
|
| 86 | 86 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @author Mike Nelson |
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 19 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 20 | 20 | exit('No direct script access allowed'); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | } else { |
| 42 | 42 | $reg = null; |
| 43 | 43 | } |
| 44 | - if (! $reg instanceof EE_Registration |
|
| 44 | + if ( ! $reg instanceof EE_Registration |
|
| 45 | 45 | ) { |
| 46 | 46 | throw new \EE_Error( |
| 47 | 47 | sprintf( |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | */ |
| 16 | 16 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 17 | - exit('No direct script access allowed'); |
|
| 17 | + exit('No direct script access allowed'); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | |
@@ -22,41 +22,41 @@ discard block |
||
| 22 | 22 | class Base |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @param $required_permission |
|
| 27 | - * @param $attempted_calculation |
|
| 28 | - * @throws \EventEspresso\core\libraries\rest_api\RestException |
|
| 29 | - */ |
|
| 30 | - protected static function verifyCurrentUserCan($required_permission, $attempted_calculation) |
|
| 31 | - { |
|
| 32 | - if (! current_user_can($required_permission)) { |
|
| 33 | - throw new RestException( |
|
| 34 | - 'permission_denied', |
|
| 35 | - sprintf( |
|
| 36 | - __( |
|
| 37 | - // @codingStandardsIgnoreStart |
|
| 38 | - 'Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"', |
|
| 39 | - // @codingStandardsIgnoreEnd |
|
| 40 | - 'event_espresso' |
|
| 41 | - ), |
|
| 42 | - $attempted_calculation, |
|
| 43 | - EEH_Inflector::pluralize_and_lower(self::getResourceName()), |
|
| 44 | - $required_permission |
|
| 45 | - ) |
|
| 46 | - ); |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Gets the name of the resource of the called class |
|
| 54 | - * |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 57 | - public static function getResourceName() |
|
| 58 | - { |
|
| 59 | - $classname = get_called_class(); |
|
| 60 | - return substr($classname, strrpos($classname, '\\') + 1); |
|
| 61 | - } |
|
| 25 | + /** |
|
| 26 | + * @param $required_permission |
|
| 27 | + * @param $attempted_calculation |
|
| 28 | + * @throws \EventEspresso\core\libraries\rest_api\RestException |
|
| 29 | + */ |
|
| 30 | + protected static function verifyCurrentUserCan($required_permission, $attempted_calculation) |
|
| 31 | + { |
|
| 32 | + if (! current_user_can($required_permission)) { |
|
| 33 | + throw new RestException( |
|
| 34 | + 'permission_denied', |
|
| 35 | + sprintf( |
|
| 36 | + __( |
|
| 37 | + // @codingStandardsIgnoreStart |
|
| 38 | + 'Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"', |
|
| 39 | + // @codingStandardsIgnoreEnd |
|
| 40 | + 'event_espresso' |
|
| 41 | + ), |
|
| 42 | + $attempted_calculation, |
|
| 43 | + EEH_Inflector::pluralize_and_lower(self::getResourceName()), |
|
| 44 | + $required_permission |
|
| 45 | + ) |
|
| 46 | + ); |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Gets the name of the resource of the called class |
|
| 54 | + * |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | + public static function getResourceName() |
|
| 58 | + { |
|
| 59 | + $classname = get_called_class(); |
|
| 60 | + return substr($classname, strrpos($classname, '\\') + 1); |
|
| 61 | + } |
|
| 62 | 62 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * @author Mike Nelson |
| 14 | 14 | * |
| 15 | 15 | */ |
| 16 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 16 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 17 | 17 | exit('No direct script access allowed'); |
| 18 | 18 | } |
| 19 | 19 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | protected static function verifyCurrentUserCan($required_permission, $attempted_calculation) |
| 31 | 31 | { |
| 32 | - if (! current_user_can($required_permission)) { |
|
| 32 | + if ( ! current_user_can($required_permission)) { |
|
| 33 | 33 | throw new RestException( |
| 34 | 34 | 'permission_denied', |
| 35 | 35 | sprintf( |