@@ -34,139 +34,139 @@ |
||
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * the actual shortcode tag that gets registered with WordPress |
|
| 39 | - * |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 42 | - public function getTag() |
|
| 43 | - { |
|
| 44 | - return 'ESPRESSO_EVENTS'; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * the time in seconds to cache the results of the processShortcode() method |
|
| 51 | - * 0 means the processShortcode() results will NOT be cached at all |
|
| 52 | - * |
|
| 53 | - * @return int |
|
| 54 | - */ |
|
| 55 | - public function cacheExpiration() |
|
| 56 | - { |
|
| 57 | - return 0; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
| 64 | - * this may be required for shortcodes that utilize a corresponding module, |
|
| 65 | - * and need to enqueue assets for that module |
|
| 66 | - * |
|
| 67 | - * @return void |
|
| 68 | - */ |
|
| 69 | - public function initializeShortcode() |
|
| 70 | - { |
|
| 71 | - EED_Events_Archive::instance()->event_list(); |
|
| 72 | - $this->shortcodeHasBeenInitialized(); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * callback that runs when the shortcode is encountered in post content. |
|
| 79 | - * IMPORTANT !!! |
|
| 80 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
| 81 | - * |
|
| 82 | - * @param array $attributes |
|
| 83 | - * @return string |
|
| 84 | - */ |
|
| 85 | - public function processShortcode($attributes = array()) |
|
| 86 | - { |
|
| 87 | - // grab attributes and merge with defaults |
|
| 88 | - $attributes = $this->getAttributes($attributes); |
|
| 89 | - // make sure we use the_excerpt() |
|
| 90 | - add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true'); |
|
| 91 | - // apply query filters |
|
| 92 | - add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
| 93 | - // run the query |
|
| 94 | - global $wp_query; |
|
| 95 | - // yes we have to overwrite the main wp query, but it's ok... |
|
| 96 | - // we're going to reset it again below, so everything will be Hunky Dory (amazing album) |
|
| 97 | - $wp_query = new EventListQuery($attributes); |
|
| 98 | - // check what template is loaded and load filters accordingly |
|
| 99 | - EED_Events_Archive::instance()->template_include('loop-espresso_events.php'); |
|
| 100 | - // load our template |
|
| 101 | - $event_list = EEH_Template::locate_template( |
|
| 102 | - 'loop-espresso_events.php', |
|
| 103 | - array(), |
|
| 104 | - true, |
|
| 105 | - true |
|
| 106 | - ); |
|
| 107 | - // now reset the query and post data |
|
| 108 | - wp_reset_query(); |
|
| 109 | - wp_reset_postdata(); |
|
| 110 | - EED_Events_Archive::remove_all_events_archive_filters(); |
|
| 111 | - // remove query filters |
|
| 112 | - remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
| 113 | - // pull our content from the output buffer and return it |
|
| 114 | - return $event_list; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * merge incoming attributes with filtered defaults |
|
| 121 | - * |
|
| 122 | - * @param array $attributes |
|
| 123 | - * @return array |
|
| 124 | - */ |
|
| 125 | - private function getAttributes(array $attributes) |
|
| 126 | - { |
|
| 127 | - return array_merge( |
|
| 128 | - (array)apply_filters( |
|
| 129 | - 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', |
|
| 130 | - array( |
|
| 131 | - 'title' => '', |
|
| 132 | - 'limit' => 10, |
|
| 133 | - 'css_class' => '', |
|
| 134 | - 'show_expired' => false, |
|
| 135 | - 'month' => '', |
|
| 136 | - 'category_slug' => '', |
|
| 137 | - 'order_by' => 'start_date', |
|
| 138 | - 'sort' => 'ASC', |
|
| 139 | - 'show_title' => true, |
|
| 140 | - ) |
|
| 141 | - ), |
|
| 142 | - $attributes |
|
| 143 | - ); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * array for defining custom attribute sanitization callbacks, |
|
| 150 | - * where keys match keys in your attributes array, |
|
| 151 | - * and values represent the sanitization function you wish to be applied to that attribute. |
|
| 152 | - * So for example, if you had an integer attribute named "event_id" |
|
| 153 | - * that you wanted to be sanitized using absint(), |
|
| 154 | - * then you would pass the following for your $custom_sanitization array: |
|
| 155 | - * array('event_id' => 'absint') |
|
| 156 | - * |
|
| 157 | - * @return array |
|
| 158 | - */ |
|
| 159 | - protected function customAttributeSanitizationMap() |
|
| 160 | - { |
|
| 161 | - // the following get sanitized/whitelisted in EEH_Event_Query |
|
| 162 | - return array( |
|
| 163 | - 'category_slug' => 'skip_sanitization', |
|
| 164 | - 'show_expired' => 'skip_sanitization', |
|
| 165 | - 'order_by' => 'skip_sanitization', |
|
| 166 | - 'month' => 'skip_sanitization', |
|
| 167 | - 'sort' => 'skip_sanitization', |
|
| 168 | - ); |
|
| 169 | - } |
|
| 37 | + /** |
|
| 38 | + * the actual shortcode tag that gets registered with WordPress |
|
| 39 | + * |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | + public function getTag() |
|
| 43 | + { |
|
| 44 | + return 'ESPRESSO_EVENTS'; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * the time in seconds to cache the results of the processShortcode() method |
|
| 51 | + * 0 means the processShortcode() results will NOT be cached at all |
|
| 52 | + * |
|
| 53 | + * @return int |
|
| 54 | + */ |
|
| 55 | + public function cacheExpiration() |
|
| 56 | + { |
|
| 57 | + return 0; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
| 64 | + * this may be required for shortcodes that utilize a corresponding module, |
|
| 65 | + * and need to enqueue assets for that module |
|
| 66 | + * |
|
| 67 | + * @return void |
|
| 68 | + */ |
|
| 69 | + public function initializeShortcode() |
|
| 70 | + { |
|
| 71 | + EED_Events_Archive::instance()->event_list(); |
|
| 72 | + $this->shortcodeHasBeenInitialized(); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * callback that runs when the shortcode is encountered in post content. |
|
| 79 | + * IMPORTANT !!! |
|
| 80 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
| 81 | + * |
|
| 82 | + * @param array $attributes |
|
| 83 | + * @return string |
|
| 84 | + */ |
|
| 85 | + public function processShortcode($attributes = array()) |
|
| 86 | + { |
|
| 87 | + // grab attributes and merge with defaults |
|
| 88 | + $attributes = $this->getAttributes($attributes); |
|
| 89 | + // make sure we use the_excerpt() |
|
| 90 | + add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true'); |
|
| 91 | + // apply query filters |
|
| 92 | + add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
| 93 | + // run the query |
|
| 94 | + global $wp_query; |
|
| 95 | + // yes we have to overwrite the main wp query, but it's ok... |
|
| 96 | + // we're going to reset it again below, so everything will be Hunky Dory (amazing album) |
|
| 97 | + $wp_query = new EventListQuery($attributes); |
|
| 98 | + // check what template is loaded and load filters accordingly |
|
| 99 | + EED_Events_Archive::instance()->template_include('loop-espresso_events.php'); |
|
| 100 | + // load our template |
|
| 101 | + $event_list = EEH_Template::locate_template( |
|
| 102 | + 'loop-espresso_events.php', |
|
| 103 | + array(), |
|
| 104 | + true, |
|
| 105 | + true |
|
| 106 | + ); |
|
| 107 | + // now reset the query and post data |
|
| 108 | + wp_reset_query(); |
|
| 109 | + wp_reset_postdata(); |
|
| 110 | + EED_Events_Archive::remove_all_events_archive_filters(); |
|
| 111 | + // remove query filters |
|
| 112 | + remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
| 113 | + // pull our content from the output buffer and return it |
|
| 114 | + return $event_list; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * merge incoming attributes with filtered defaults |
|
| 121 | + * |
|
| 122 | + * @param array $attributes |
|
| 123 | + * @return array |
|
| 124 | + */ |
|
| 125 | + private function getAttributes(array $attributes) |
|
| 126 | + { |
|
| 127 | + return array_merge( |
|
| 128 | + (array)apply_filters( |
|
| 129 | + 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', |
|
| 130 | + array( |
|
| 131 | + 'title' => '', |
|
| 132 | + 'limit' => 10, |
|
| 133 | + 'css_class' => '', |
|
| 134 | + 'show_expired' => false, |
|
| 135 | + 'month' => '', |
|
| 136 | + 'category_slug' => '', |
|
| 137 | + 'order_by' => 'start_date', |
|
| 138 | + 'sort' => 'ASC', |
|
| 139 | + 'show_title' => true, |
|
| 140 | + ) |
|
| 141 | + ), |
|
| 142 | + $attributes |
|
| 143 | + ); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * array for defining custom attribute sanitization callbacks, |
|
| 150 | + * where keys match keys in your attributes array, |
|
| 151 | + * and values represent the sanitization function you wish to be applied to that attribute. |
|
| 152 | + * So for example, if you had an integer attribute named "event_id" |
|
| 153 | + * that you wanted to be sanitized using absint(), |
|
| 154 | + * then you would pass the following for your $custom_sanitization array: |
|
| 155 | + * array('event_id' => 'absint') |
|
| 156 | + * |
|
| 157 | + * @return array |
|
| 158 | + */ |
|
| 159 | + protected function customAttributeSanitizationMap() |
|
| 160 | + { |
|
| 161 | + // the following get sanitized/whitelisted in EEH_Event_Query |
|
| 162 | + return array( |
|
| 163 | + 'category_slug' => 'skip_sanitization', |
|
| 164 | + 'show_expired' => 'skip_sanitization', |
|
| 165 | + 'order_by' => 'skip_sanitization', |
|
| 166 | + 'month' => 'skip_sanitization', |
|
| 167 | + 'sort' => 'skip_sanitization', |
|
| 168 | + ); |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | 171 | |
| 172 | 172 | |
@@ -14,115 +14,115 @@ |
||
| 14 | 14 | { |
| 15 | 15 | |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * EE_Message_Template_Group_Collection constructor. |
|
| 19 | - */ |
|
| 20 | - public function __construct() |
|
| 21 | - { |
|
| 22 | - $this->interface = 'EE_Message_Template_Group'; |
|
| 23 | - } |
|
| 17 | + /** |
|
| 18 | + * EE_Message_Template_Group_Collection constructor. |
|
| 19 | + */ |
|
| 20 | + public function __construct() |
|
| 21 | + { |
|
| 22 | + $this->interface = 'EE_Message_Template_Group'; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Adds the Message Template Group object to the repository. |
|
| 28 | - * |
|
| 29 | - * @param $message_template_group |
|
| 30 | - * @param array|int $EVT_ID Some templates are specific to EVT, so this is provided as a way of |
|
| 31 | - * indexing the template by key. If this template is shared among multiple events then |
|
| 32 | - * include the events as an array. |
|
| 33 | - * @return bool |
|
| 34 | - */ |
|
| 35 | - public function add($message_template_group, $EVT_ID = array()) |
|
| 36 | - { |
|
| 37 | - $EVT_ID = is_array($EVT_ID) ? $EVT_ID : (array) $EVT_ID; |
|
| 38 | - if ($message_template_group instanceof $this->interface) { |
|
| 39 | - $data['key'] = $this->getKey( |
|
| 40 | - $message_template_group->messenger(), |
|
| 41 | - $message_template_group->message_type(), |
|
| 42 | - $EVT_ID |
|
| 43 | - ); |
|
| 44 | - return parent::add($message_template_group, $data); |
|
| 45 | - } |
|
| 46 | - return false; |
|
| 47 | - } |
|
| 26 | + /** |
|
| 27 | + * Adds the Message Template Group object to the repository. |
|
| 28 | + * |
|
| 29 | + * @param $message_template_group |
|
| 30 | + * @param array|int $EVT_ID Some templates are specific to EVT, so this is provided as a way of |
|
| 31 | + * indexing the template by key. If this template is shared among multiple events then |
|
| 32 | + * include the events as an array. |
|
| 33 | + * @return bool |
|
| 34 | + */ |
|
| 35 | + public function add($message_template_group, $EVT_ID = array()) |
|
| 36 | + { |
|
| 37 | + $EVT_ID = is_array($EVT_ID) ? $EVT_ID : (array) $EVT_ID; |
|
| 38 | + if ($message_template_group instanceof $this->interface) { |
|
| 39 | + $data['key'] = $this->getKey( |
|
| 40 | + $message_template_group->messenger(), |
|
| 41 | + $message_template_group->message_type(), |
|
| 42 | + $EVT_ID |
|
| 43 | + ); |
|
| 44 | + return parent::add($message_template_group, $data); |
|
| 45 | + } |
|
| 46 | + return false; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * This retrieves any EE_Message_Template_Group in the repo by its ID. |
|
| 52 | - * |
|
| 53 | - * @param $GRP_ID |
|
| 54 | - * @return EE_Message_Template_Group | null |
|
| 55 | - */ |
|
| 56 | - public function get_by_ID($GRP_ID) |
|
| 57 | - { |
|
| 58 | - $this->rewind(); |
|
| 59 | - while ($this->valid()) { |
|
| 60 | - if ($this->current()->ID() === $GRP_ID) { |
|
| 61 | - /** @var EE_Message_Template_Group $message_template_group */ |
|
| 62 | - $message_template_group = $this->current(); |
|
| 63 | - $this->rewind(); |
|
| 64 | - return $message_template_group; |
|
| 65 | - } |
|
| 66 | - $this->next(); |
|
| 67 | - } |
|
| 68 | - return null; |
|
| 69 | - } |
|
| 50 | + /** |
|
| 51 | + * This retrieves any EE_Message_Template_Group in the repo by its ID. |
|
| 52 | + * |
|
| 53 | + * @param $GRP_ID |
|
| 54 | + * @return EE_Message_Template_Group | null |
|
| 55 | + */ |
|
| 56 | + public function get_by_ID($GRP_ID) |
|
| 57 | + { |
|
| 58 | + $this->rewind(); |
|
| 59 | + while ($this->valid()) { |
|
| 60 | + if ($this->current()->ID() === $GRP_ID) { |
|
| 61 | + /** @var EE_Message_Template_Group $message_template_group */ |
|
| 62 | + $message_template_group = $this->current(); |
|
| 63 | + $this->rewind(); |
|
| 64 | + return $message_template_group; |
|
| 65 | + } |
|
| 66 | + $this->next(); |
|
| 67 | + } |
|
| 68 | + return null; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Generates a hash used to identify a given Message Template Group. |
|
| 74 | - * |
|
| 75 | - * @param string $messenger The EE_messenger->name |
|
| 76 | - * @param string $message_type The EE_message_type->name |
|
| 77 | - * @param int $EVT_ID Optional. If the template is for a specific EVT then that should be included. |
|
| 78 | - * @deprecated 4.9.40.rc.017 Use getKey instead. |
|
| 79 | - * @return string |
|
| 80 | - */ |
|
| 81 | - public function get_key($messenger, $message_type, $EVT_ID = 0) |
|
| 82 | - { |
|
| 83 | - $EVT_ID = (array) $EVT_ID; |
|
| 84 | - return $this->getKey($messenger, $message_type, $EVT_ID); |
|
| 85 | - } |
|
| 72 | + /** |
|
| 73 | + * Generates a hash used to identify a given Message Template Group. |
|
| 74 | + * |
|
| 75 | + * @param string $messenger The EE_messenger->name |
|
| 76 | + * @param string $message_type The EE_message_type->name |
|
| 77 | + * @param int $EVT_ID Optional. If the template is for a specific EVT then that should be included. |
|
| 78 | + * @deprecated 4.9.40.rc.017 Use getKey instead. |
|
| 79 | + * @return string |
|
| 80 | + */ |
|
| 81 | + public function get_key($messenger, $message_type, $EVT_ID = 0) |
|
| 82 | + { |
|
| 83 | + $EVT_ID = (array) $EVT_ID; |
|
| 84 | + return $this->getKey($messenger, $message_type, $EVT_ID); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Generates a hash used to identify a given Message Template Group |
|
| 90 | - * @param string $messenger The EE_messenger->name |
|
| 91 | - * @param string $message_type The EE_message_type->name |
|
| 92 | - * @param array $EVT_ID Optional. If the template is for a specific EVT_ID (or events) then that should |
|
| 93 | - * be included. |
|
| 94 | - * @since 4.9.40.rc.017 |
|
| 95 | - * @return string |
|
| 96 | - */ |
|
| 97 | - public function getKey($messenger, $message_type, array $EVT_ID = array()) |
|
| 98 | - { |
|
| 99 | - sort($EVT_ID); |
|
| 100 | - $EVT_ID = implode(',', array_unique($EVT_ID)); |
|
| 101 | - return md5($messenger . $message_type . $EVT_ID); |
|
| 102 | - } |
|
| 88 | + /** |
|
| 89 | + * Generates a hash used to identify a given Message Template Group |
|
| 90 | + * @param string $messenger The EE_messenger->name |
|
| 91 | + * @param string $message_type The EE_message_type->name |
|
| 92 | + * @param array $EVT_ID Optional. If the template is for a specific EVT_ID (or events) then that should |
|
| 93 | + * be included. |
|
| 94 | + * @since 4.9.40.rc.017 |
|
| 95 | + * @return string |
|
| 96 | + */ |
|
| 97 | + public function getKey($messenger, $message_type, array $EVT_ID = array()) |
|
| 98 | + { |
|
| 99 | + sort($EVT_ID); |
|
| 100 | + $EVT_ID = implode(',', array_unique($EVT_ID)); |
|
| 101 | + return md5($messenger . $message_type . $EVT_ID); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * This returns a saved EE_Message_Template_Group object if there is one in the repository indexed by a key matching |
|
| 107 | - * the given string. |
|
| 108 | - * |
|
| 109 | - * @param string $key @see EE_Message_Template_Group::get_key() to setup a key formatted for searching. |
|
| 110 | - * @return null|EE_Message_Template_Group |
|
| 111 | - */ |
|
| 112 | - public function get_by_key($key) |
|
| 113 | - { |
|
| 114 | - $this->rewind(); |
|
| 115 | - while ($this->valid()) { |
|
| 116 | - $data = $this->getInfo(); |
|
| 117 | - if (isset($data['key']) && $data['key'] === $key) { |
|
| 118 | - /** @var EE_Message_Template_Group $message_template_group */ |
|
| 119 | - $message_template_group = $this->current(); |
|
| 120 | - $this->rewind(); |
|
| 121 | - return $message_template_group; |
|
| 122 | - } |
|
| 123 | - $this->next(); |
|
| 124 | - } |
|
| 125 | - return null; |
|
| 126 | - } |
|
| 105 | + /** |
|
| 106 | + * This returns a saved EE_Message_Template_Group object if there is one in the repository indexed by a key matching |
|
| 107 | + * the given string. |
|
| 108 | + * |
|
| 109 | + * @param string $key @see EE_Message_Template_Group::get_key() to setup a key formatted for searching. |
|
| 110 | + * @return null|EE_Message_Template_Group |
|
| 111 | + */ |
|
| 112 | + public function get_by_key($key) |
|
| 113 | + { |
|
| 114 | + $this->rewind(); |
|
| 115 | + while ($this->valid()) { |
|
| 116 | + $data = $this->getInfo(); |
|
| 117 | + if (isset($data['key']) && $data['key'] === $key) { |
|
| 118 | + /** @var EE_Message_Template_Group $message_template_group */ |
|
| 119 | + $message_template_group = $this->current(); |
|
| 120 | + $this->rewind(); |
|
| 121 | + return $message_template_group; |
|
| 122 | + } |
|
| 123 | + $this->next(); |
|
| 124 | + } |
|
| 125 | + return null; |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | 128 | } |
@@ -98,7 +98,7 @@ |
||
| 98 | 98 | { |
| 99 | 99 | sort($EVT_ID); |
| 100 | 100 | $EVT_ID = implode(',', array_unique($EVT_ID)); |
| 101 | - return md5($messenger . $message_type . $EVT_ID); |
|
| 101 | + return md5($messenger.$message_type.$EVT_ID); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
@@ -14,8 +14,8 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | //need the MER plugin active for this test (we'll deactivate it after). |
| 16 | 16 | $I->ensurePluginActive( |
| 17 | - 'event-espresso-mer-multi-event-registration', |
|
| 18 | - 'activated' |
|
| 17 | + 'event-espresso-mer-multi-event-registration', |
|
| 18 | + 'activated' |
|
| 19 | 19 | ); |
| 20 | 20 | |
| 21 | 21 | //k now we need to make sure the registration multi-status message type is active because it isn't by default |
@@ -76,38 +76,38 @@ discard block |
||
| 76 | 76 | $I->loginAsAdmin(); |
| 77 | 77 | $I->amOnMessagesActivityListTablePage(); |
| 78 | 78 | $I->see( |
| 79 | - '[email protected]', |
|
| 80 | - MessagesAdmin::messagesActivityListTableCellSelectorFor( |
|
| 81 | - 'to', |
|
| 82 | - 'Registration Multi-status Summary', |
|
| 83 | - MessagesAdmin::MESSAGE_STATUS_SENT, |
|
| 84 | - '', |
|
| 85 | - 'Primary Registrant' |
|
| 86 | - ) |
|
| 79 | + '[email protected]', |
|
| 80 | + MessagesAdmin::messagesActivityListTableCellSelectorFor( |
|
| 81 | + 'to', |
|
| 82 | + 'Registration Multi-status Summary', |
|
| 83 | + MessagesAdmin::MESSAGE_STATUS_SENT, |
|
| 84 | + '', |
|
| 85 | + 'Primary Registrant' |
|
| 86 | + ) |
|
| 87 | 87 | ); |
| 88 | 88 | $I->see( |
| 89 | - '[email protected]', |
|
| 90 | - MessagesAdmin::messagesActivityListTableCellSelectorFor( |
|
| 91 | - 'to', |
|
| 92 | - 'Registration Multi-status Summary', |
|
| 93 | - MessagesAdmin::MESSAGE_STATUS_SENT |
|
| 94 | - ) |
|
| 89 | + '[email protected]', |
|
| 90 | + MessagesAdmin::messagesActivityListTableCellSelectorFor( |
|
| 91 | + 'to', |
|
| 92 | + 'Registration Multi-status Summary', |
|
| 93 | + MessagesAdmin::MESSAGE_STATUS_SENT |
|
| 94 | + ) |
|
| 95 | 95 | ); |
| 96 | 96 | //verify count |
| 97 | 97 | $I->verifyMatchingCountofTextInMessageActivityListTableFor( |
| 98 | - 1, |
|
| 99 | - '[email protected]', |
|
| 100 | - 'to', |
|
| 101 | - 'Registration Multi-status Summary', |
|
| 102 | - MessagesAdmin::MESSAGE_STATUS_SENT, |
|
| 103 | - 'Email', |
|
| 104 | - 'Primary Registrant' |
|
| 98 | + 1, |
|
| 99 | + '[email protected]', |
|
| 100 | + 'to', |
|
| 101 | + 'Registration Multi-status Summary', |
|
| 102 | + MessagesAdmin::MESSAGE_STATUS_SENT, |
|
| 103 | + 'Email', |
|
| 104 | + 'Primary Registrant' |
|
| 105 | 105 | ); |
| 106 | 106 | $I->verifyMatchingCountofTextInMessageActivityListTableFor( |
| 107 | - 1, |
|
| 108 | - '[email protected]', |
|
| 109 | - 'to', |
|
| 110 | - 'Registration Multi-status Summary' |
|
| 107 | + 1, |
|
| 108 | + '[email protected]', |
|
| 109 | + 'to', |
|
| 110 | + 'Registration Multi-status Summary' |
|
| 111 | 111 | ); |
| 112 | 112 | |
| 113 | 113 | //okay now let's do some registrations for just the first event and verify that registration multi-status summary is NOT |
@@ -137,25 +137,25 @@ discard block |
||
| 137 | 137 | $I->loginAsAdmin(); |
| 138 | 138 | $I->amOnMessagesActivityListTablePage(); |
| 139 | 139 | $I->dontSee( |
| 140 | - '[email protected]', |
|
| 141 | - MessagesAdmin::messagesActivityListTableCellSelectorFor( |
|
| 142 | - 'to', |
|
| 143 | - 'Registration Multi-status Summary', |
|
| 144 | - MessagesAdmin::MESSAGE_STATUS_SENT, |
|
| 145 | - '', |
|
| 146 | - 'Primary Registrant' |
|
| 147 | - ) |
|
| 140 | + '[email protected]', |
|
| 141 | + MessagesAdmin::messagesActivityListTableCellSelectorFor( |
|
| 142 | + 'to', |
|
| 143 | + 'Registration Multi-status Summary', |
|
| 144 | + MessagesAdmin::MESSAGE_STATUS_SENT, |
|
| 145 | + '', |
|
| 146 | + 'Primary Registrant' |
|
| 147 | + ) |
|
| 148 | 148 | ); |
| 149 | 149 | //there should still only be one admin multi-status summary thing. |
| 150 | 150 | $I->verifyMatchingCountofTextInMessageActivityListTableFor( |
| 151 | - 1, |
|
| 152 | - '[email protected]', |
|
| 153 | - 'to', |
|
| 154 | - 'Registration Multi-status Summary' |
|
| 151 | + 1, |
|
| 152 | + '[email protected]', |
|
| 153 | + 'to', |
|
| 154 | + 'Registration Multi-status Summary' |
|
| 155 | 155 | ); |
| 156 | 156 | |
| 157 | 157 | //deactivate MER plugin so its not active for future tests |
| 158 | 158 | $I->ensurePluginDeactivated( |
| 159 | - 'event-espresso-mer-multi-event-registration', |
|
| 160 | - 'Plugin deactivated' |
|
| 159 | + 'event-espresso-mer-multi-event-registration', |
|
| 160 | + 'Plugin deactivated' |
|
| 161 | 161 | ); |
| 162 | 162 | \ No newline at end of file |
@@ -13,1086 +13,1086 @@ |
||
| 13 | 13 | class EED_Messages extends EED_Module |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * This holds the EE_messages controller |
|
| 18 | - * |
|
| 19 | - * @deprecated 4.9.0 |
|
| 20 | - * @var EE_messages $_EEMSG |
|
| 21 | - */ |
|
| 22 | - protected static $_EEMSG; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @type EE_Message_Resource_Manager $_message_resource_manager |
|
| 26 | - */ |
|
| 27 | - protected static $_message_resource_manager; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * This holds the EE_Messages_Processor business class. |
|
| 31 | - * |
|
| 32 | - * @type EE_Messages_Processor |
|
| 33 | - */ |
|
| 34 | - protected static $_MSG_PROCESSOR; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * holds all the paths for various messages components. |
|
| 38 | - * Utilized by autoloader registry |
|
| 39 | - * |
|
| 40 | - * @var array |
|
| 41 | - */ |
|
| 42 | - protected static $_MSG_PATHS; |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * This will hold an array of messages template packs that are registered in the messages system. |
|
| 47 | - * Format is: |
|
| 48 | - * array( |
|
| 49 | - * 'template_pack_dbref' => EE_Messages_Template_Pack (instance) |
|
| 50 | - * ) |
|
| 51 | - * |
|
| 52 | - * @var EE_Messages_Template_Pack[] |
|
| 53 | - */ |
|
| 54 | - protected static $_TMP_PACKS = array(); |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @return EED_Messages |
|
| 59 | - */ |
|
| 60 | - public static function instance() |
|
| 61 | - { |
|
| 62 | - return parent::get_instance(__CLASS__); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
| 68 | - * |
|
| 69 | - * @since 4.5.0 |
|
| 70 | - * @return void |
|
| 71 | - */ |
|
| 72 | - public static function set_hooks() |
|
| 73 | - { |
|
| 74 | - //actions |
|
| 75 | - add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
| 76 | - add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
| 77 | - array('EED_Messages', 'maybe_registration'), 10, 2); |
|
| 78 | - //filters |
|
| 79 | - add_filter('FHEE__EE_Registration__receipt_url__receipt_url', |
|
| 80 | - array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
| 81 | - add_filter('FHEE__EE_Registration__invoice_url__invoice_url', |
|
| 82 | - array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
| 83 | - //register routes |
|
| 84 | - self::_register_routes(); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 89 | - * |
|
| 90 | - * @access public |
|
| 91 | - * @return void |
|
| 92 | - */ |
|
| 93 | - public static function set_hooks_admin() |
|
| 94 | - { |
|
| 95 | - //actions |
|
| 96 | - add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
| 97 | - add_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', |
|
| 98 | - array('EED_Messages', 'payment_reminder'), 10); |
|
| 99 | - add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
| 100 | - array('EED_Messages', 'maybe_registration'), 10, 3); |
|
| 101 | - add_action('AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
| 102 | - array('EED_Messages', 'send_newsletter_message'), 10, 2); |
|
| 103 | - add_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', |
|
| 104 | - array('EED_Messages', 'cancelled_registration'), 10); |
|
| 105 | - add_action('AHEE__EE_Admin_Page___process_admin_payment_notification', |
|
| 106 | - array('EED_Messages', 'process_admin_payment'), 10, 1); |
|
| 107 | - //filters |
|
| 108 | - add_filter('FHEE__EE_Admin_Page___process_resend_registration__success', |
|
| 109 | - array('EED_Messages', 'process_resend'), 10, 2); |
|
| 110 | - add_filter('FHEE__EE_Registration__receipt_url__receipt_url', |
|
| 111 | - array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
| 112 | - add_filter('FHEE__EE_Registration__invoice_url__invoice_url', |
|
| 113 | - array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * All the message triggers done by route go in here. |
|
| 119 | - * |
|
| 120 | - * @since 4.5.0 |
|
| 121 | - * @return void |
|
| 122 | - */ |
|
| 123 | - protected static function _register_routes() |
|
| 124 | - { |
|
| 125 | - EE_Config::register_route('msg_url_trigger', 'Messages', 'run'); |
|
| 126 | - EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request'); |
|
| 127 | - EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger'); |
|
| 128 | - EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger'); |
|
| 129 | - do_action('AHEE__EED_Messages___register_routes'); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * This is called when a browser display trigger is executed. |
|
| 135 | - * The browser display trigger is typically used when a already generated message is displayed directly in the |
|
| 136 | - * browser. |
|
| 137 | - * |
|
| 138 | - * @since 4.9.0 |
|
| 139 | - * @param WP $WP |
|
| 140 | - */ |
|
| 141 | - public function browser_trigger($WP) |
|
| 142 | - { |
|
| 143 | - //ensure controller is loaded |
|
| 144 | - self::_load_controller(); |
|
| 145 | - $token = EE_Registry::instance()->REQ->get('token'); |
|
| 146 | - try { |
|
| 147 | - $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager); |
|
| 148 | - self::$_MSG_PROCESSOR->generate_and_send_now($mtg); |
|
| 149 | - } catch (EE_Error $e) { |
|
| 150 | - $error_msg = __('Please note that a system message failed to send due to a technical issue.', |
|
| 151 | - 'event_espresso'); |
|
| 152 | - // add specific message for developers if WP_DEBUG in on |
|
| 153 | - $error_msg .= '||' . $e->getMessage(); |
|
| 154 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * This is called when a browser error trigger is executed. |
|
| 161 | - * When triggered this will grab the EE_Message matching the token in the request and use that to get the error |
|
| 162 | - * message and display it. |
|
| 163 | - * |
|
| 164 | - * @since 4.9.0 |
|
| 165 | - * @param $WP |
|
| 166 | - */ |
|
| 167 | - public function browser_error_trigger($WP) |
|
| 168 | - { |
|
| 169 | - $token = EE_Registry::instance()->REQ->get('token'); |
|
| 170 | - if ($token) { |
|
| 171 | - $message = EEM_Message::instance()->get_one_by_token($token); |
|
| 172 | - if ($message instanceof EE_Message) { |
|
| 173 | - header('HTTP/1.1 200 OK'); |
|
| 174 | - $error_msg = nl2br($message->error_message()); |
|
| 175 | - ?> |
|
| 16 | + /** |
|
| 17 | + * This holds the EE_messages controller |
|
| 18 | + * |
|
| 19 | + * @deprecated 4.9.0 |
|
| 20 | + * @var EE_messages $_EEMSG |
|
| 21 | + */ |
|
| 22 | + protected static $_EEMSG; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @type EE_Message_Resource_Manager $_message_resource_manager |
|
| 26 | + */ |
|
| 27 | + protected static $_message_resource_manager; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * This holds the EE_Messages_Processor business class. |
|
| 31 | + * |
|
| 32 | + * @type EE_Messages_Processor |
|
| 33 | + */ |
|
| 34 | + protected static $_MSG_PROCESSOR; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * holds all the paths for various messages components. |
|
| 38 | + * Utilized by autoloader registry |
|
| 39 | + * |
|
| 40 | + * @var array |
|
| 41 | + */ |
|
| 42 | + protected static $_MSG_PATHS; |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * This will hold an array of messages template packs that are registered in the messages system. |
|
| 47 | + * Format is: |
|
| 48 | + * array( |
|
| 49 | + * 'template_pack_dbref' => EE_Messages_Template_Pack (instance) |
|
| 50 | + * ) |
|
| 51 | + * |
|
| 52 | + * @var EE_Messages_Template_Pack[] |
|
| 53 | + */ |
|
| 54 | + protected static $_TMP_PACKS = array(); |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @return EED_Messages |
|
| 59 | + */ |
|
| 60 | + public static function instance() |
|
| 61 | + { |
|
| 62 | + return parent::get_instance(__CLASS__); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
| 68 | + * |
|
| 69 | + * @since 4.5.0 |
|
| 70 | + * @return void |
|
| 71 | + */ |
|
| 72 | + public static function set_hooks() |
|
| 73 | + { |
|
| 74 | + //actions |
|
| 75 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
| 76 | + add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
| 77 | + array('EED_Messages', 'maybe_registration'), 10, 2); |
|
| 78 | + //filters |
|
| 79 | + add_filter('FHEE__EE_Registration__receipt_url__receipt_url', |
|
| 80 | + array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
| 81 | + add_filter('FHEE__EE_Registration__invoice_url__invoice_url', |
|
| 82 | + array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
| 83 | + //register routes |
|
| 84 | + self::_register_routes(); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 89 | + * |
|
| 90 | + * @access public |
|
| 91 | + * @return void |
|
| 92 | + */ |
|
| 93 | + public static function set_hooks_admin() |
|
| 94 | + { |
|
| 95 | + //actions |
|
| 96 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
| 97 | + add_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', |
|
| 98 | + array('EED_Messages', 'payment_reminder'), 10); |
|
| 99 | + add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
| 100 | + array('EED_Messages', 'maybe_registration'), 10, 3); |
|
| 101 | + add_action('AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
| 102 | + array('EED_Messages', 'send_newsletter_message'), 10, 2); |
|
| 103 | + add_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', |
|
| 104 | + array('EED_Messages', 'cancelled_registration'), 10); |
|
| 105 | + add_action('AHEE__EE_Admin_Page___process_admin_payment_notification', |
|
| 106 | + array('EED_Messages', 'process_admin_payment'), 10, 1); |
|
| 107 | + //filters |
|
| 108 | + add_filter('FHEE__EE_Admin_Page___process_resend_registration__success', |
|
| 109 | + array('EED_Messages', 'process_resend'), 10, 2); |
|
| 110 | + add_filter('FHEE__EE_Registration__receipt_url__receipt_url', |
|
| 111 | + array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
| 112 | + add_filter('FHEE__EE_Registration__invoice_url__invoice_url', |
|
| 113 | + array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * All the message triggers done by route go in here. |
|
| 119 | + * |
|
| 120 | + * @since 4.5.0 |
|
| 121 | + * @return void |
|
| 122 | + */ |
|
| 123 | + protected static function _register_routes() |
|
| 124 | + { |
|
| 125 | + EE_Config::register_route('msg_url_trigger', 'Messages', 'run'); |
|
| 126 | + EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request'); |
|
| 127 | + EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger'); |
|
| 128 | + EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger'); |
|
| 129 | + do_action('AHEE__EED_Messages___register_routes'); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * This is called when a browser display trigger is executed. |
|
| 135 | + * The browser display trigger is typically used when a already generated message is displayed directly in the |
|
| 136 | + * browser. |
|
| 137 | + * |
|
| 138 | + * @since 4.9.0 |
|
| 139 | + * @param WP $WP |
|
| 140 | + */ |
|
| 141 | + public function browser_trigger($WP) |
|
| 142 | + { |
|
| 143 | + //ensure controller is loaded |
|
| 144 | + self::_load_controller(); |
|
| 145 | + $token = EE_Registry::instance()->REQ->get('token'); |
|
| 146 | + try { |
|
| 147 | + $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager); |
|
| 148 | + self::$_MSG_PROCESSOR->generate_and_send_now($mtg); |
|
| 149 | + } catch (EE_Error $e) { |
|
| 150 | + $error_msg = __('Please note that a system message failed to send due to a technical issue.', |
|
| 151 | + 'event_espresso'); |
|
| 152 | + // add specific message for developers if WP_DEBUG in on |
|
| 153 | + $error_msg .= '||' . $e->getMessage(); |
|
| 154 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * This is called when a browser error trigger is executed. |
|
| 161 | + * When triggered this will grab the EE_Message matching the token in the request and use that to get the error |
|
| 162 | + * message and display it. |
|
| 163 | + * |
|
| 164 | + * @since 4.9.0 |
|
| 165 | + * @param $WP |
|
| 166 | + */ |
|
| 167 | + public function browser_error_trigger($WP) |
|
| 168 | + { |
|
| 169 | + $token = EE_Registry::instance()->REQ->get('token'); |
|
| 170 | + if ($token) { |
|
| 171 | + $message = EEM_Message::instance()->get_one_by_token($token); |
|
| 172 | + if ($message instanceof EE_Message) { |
|
| 173 | + header('HTTP/1.1 200 OK'); |
|
| 174 | + $error_msg = nl2br($message->error_message()); |
|
| 175 | + ?> |
|
| 176 | 176 | <!DOCTYPE html> |
| 177 | 177 | <html> |
| 178 | 178 | <head></head> |
| 179 | 179 | <body> |
| 180 | 180 | <?php echo empty($error_msg) |
| 181 | - ? esc_html__('Unfortunately, we were unable to capture the error message for this message.', |
|
| 182 | - 'event_espresso') |
|
| 183 | - : wp_kses( |
|
| 184 | - $error_msg, |
|
| 185 | - array( |
|
| 186 | - 'a' => array( |
|
| 187 | - 'href' => array(), |
|
| 188 | - 'title' => array(), |
|
| 189 | - ), |
|
| 190 | - 'span' => array(), |
|
| 191 | - 'div' => array(), |
|
| 192 | - 'p' => array(), |
|
| 193 | - 'strong' => array(), |
|
| 194 | - 'em' => array(), |
|
| 195 | - 'br' => array(), |
|
| 196 | - ) |
|
| 197 | - ); ?> |
|
| 181 | + ? esc_html__('Unfortunately, we were unable to capture the error message for this message.', |
|
| 182 | + 'event_espresso') |
|
| 183 | + : wp_kses( |
|
| 184 | + $error_msg, |
|
| 185 | + array( |
|
| 186 | + 'a' => array( |
|
| 187 | + 'href' => array(), |
|
| 188 | + 'title' => array(), |
|
| 189 | + ), |
|
| 190 | + 'span' => array(), |
|
| 191 | + 'div' => array(), |
|
| 192 | + 'p' => array(), |
|
| 193 | + 'strong' => array(), |
|
| 194 | + 'em' => array(), |
|
| 195 | + 'br' => array(), |
|
| 196 | + ) |
|
| 197 | + ); ?> |
|
| 198 | 198 | </body> |
| 199 | 199 | </html> |
| 200 | 200 | <?php |
| 201 | - exit; |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - return; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * This runs when the msg_url_trigger route has initiated. |
|
| 210 | - * |
|
| 211 | - * @since 4.5.0 |
|
| 212 | - * @param WP $WP |
|
| 213 | - * @throws EE_Error |
|
| 214 | - * @return void |
|
| 215 | - */ |
|
| 216 | - public function run($WP) |
|
| 217 | - { |
|
| 218 | - //ensure controller is loaded |
|
| 219 | - self::_load_controller(); |
|
| 220 | - // attempt to process message |
|
| 221 | - try { |
|
| 222 | - /** @type EE_Message_To_Generate_From_Request $message_to_generate */ |
|
| 223 | - $message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
| 224 | - self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate); |
|
| 225 | - } catch (EE_Error $e) { |
|
| 226 | - $error_msg = __('Please note that a system message failed to send due to a technical issue.', |
|
| 227 | - 'event_espresso'); |
|
| 228 | - // add specific message for developers if WP_DEBUG in on |
|
| 229 | - $error_msg .= '||' . $e->getMessage(); |
|
| 230 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 231 | - } |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * This is triggered by the 'msg_cron_trigger' route. |
|
| 237 | - * |
|
| 238 | - * @param WP $WP |
|
| 239 | - */ |
|
| 240 | - public function execute_batch_request($WP) |
|
| 241 | - { |
|
| 242 | - $this->run_cron(); |
|
| 243 | - header('HTTP/1.1 200 OK'); |
|
| 244 | - exit(); |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * This gets executed on wp_cron jobs or when a batch request is initiated on its own separate non regular wp |
|
| 250 | - * request. |
|
| 251 | - */ |
|
| 252 | - public function run_cron() |
|
| 253 | - { |
|
| 254 | - self::_load_controller(); |
|
| 255 | - //get required vars |
|
| 256 | - $cron_type = EE_Registry::instance()->REQ->get('type'); |
|
| 257 | - $transient_key = EE_Registry::instance()->REQ->get('key'); |
|
| 258 | - |
|
| 259 | - //now let's verify transient, if not valid exit immediately |
|
| 260 | - if (! get_transient($transient_key)) { |
|
| 261 | - /** |
|
| 262 | - * trigger error so this gets in the error logs. This is important because it happens on a non-user request. |
|
| 263 | - */ |
|
| 264 | - trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso')); |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - //if made it here, lets' delete the transient to keep the db clean |
|
| 268 | - delete_transient($transient_key); |
|
| 269 | - |
|
| 270 | - if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) { |
|
| 271 | - |
|
| 272 | - $method = 'batch_' . $cron_type . '_from_queue'; |
|
| 273 | - if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
|
| 274 | - self::$_MSG_PROCESSOR->$method(); |
|
| 275 | - } else { |
|
| 276 | - //no matching task |
|
| 277 | - /** |
|
| 278 | - * trigger error so this gets in the error logs. This is important because it happens on a non user request. |
|
| 279 | - */ |
|
| 280 | - trigger_error(esc_attr(sprintf(__('There is no task corresponding to this route %s', 'event_espresso'), |
|
| 281 | - $cron_type))); |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - do_action('FHEE__EED_Messages__run_cron__end'); |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - |
|
| 289 | - /** |
|
| 290 | - * This is used to retrieve the template pack for the given name. |
|
| 291 | - * Retrieved packs are cached on the static $_TMP_PACKS array. If there is no class matching the given name then |
|
| 292 | - * the default template pack is returned. |
|
| 293 | - * |
|
| 294 | - * @deprecated 4.9.0 @see EEH_MSG_Template::get_template_pack() |
|
| 295 | - * @param string $template_pack_name This should correspond to the dbref of the template pack (which is also used |
|
| 296 | - * in generating the Pack class name). |
|
| 297 | - * @return EE_Messages_Template_Pack |
|
| 298 | - */ |
|
| 299 | - public static function get_template_pack($template_pack_name) |
|
| 300 | - { |
|
| 301 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 302 | - return EEH_MSG_Template::get_template_pack($template_pack_name); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * Retrieves an array of all template packs. |
|
| 308 | - * Array is in the format array( 'dbref' => EE_Messages_Template_Pack ) |
|
| 309 | - * |
|
| 310 | - * @deprecated 4.9.0 @see EEH_MSG_Template_Pack::get_template_pack_collection |
|
| 311 | - * @return EE_Messages_Template_Pack[] |
|
| 312 | - */ |
|
| 313 | - public static function get_template_packs() |
|
| 314 | - { |
|
| 315 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 316 | - |
|
| 317 | - //for backward compat, let's make sure this returns in the same format as originally. |
|
| 318 | - $template_pack_collection = EEH_MSG_Template::get_template_pack_collection(); |
|
| 319 | - $template_pack_collection->rewind(); |
|
| 320 | - $template_packs = array(); |
|
| 321 | - while ($template_pack_collection->valid()) { |
|
| 322 | - $template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current(); |
|
| 323 | - $template_pack_collection->next(); |
|
| 324 | - } |
|
| 325 | - return $template_packs; |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * This simply makes sure the autoloaders are registered for the EE_messages system. |
|
| 331 | - * |
|
| 332 | - * @since 4.5.0 |
|
| 333 | - * @return void |
|
| 334 | - */ |
|
| 335 | - public static function set_autoloaders() |
|
| 336 | - { |
|
| 337 | - if (empty(self::$_MSG_PATHS)) { |
|
| 338 | - self::_set_messages_paths(); |
|
| 339 | - foreach (self::$_MSG_PATHS as $path) { |
|
| 340 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path); |
|
| 341 | - } |
|
| 342 | - // add aliases |
|
| 343 | - EEH_Autoloader::add_alias('EE_messages', 'EE_messages'); |
|
| 344 | - EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger'); |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - |
|
| 349 | - /** |
|
| 350 | - * Take care of adding all the paths for the messages components to the $_MSG_PATHS property |
|
| 351 | - * for use by the Messages Autoloaders |
|
| 352 | - * |
|
| 353 | - * @since 4.5.0 |
|
| 354 | - * @return void. |
|
| 355 | - */ |
|
| 356 | - protected static function _set_messages_paths() |
|
| 357 | - { |
|
| 358 | - $dir_ref = array( |
|
| 359 | - 'messages/message_type', |
|
| 360 | - 'messages/messenger', |
|
| 361 | - 'messages/defaults', |
|
| 362 | - 'messages/defaults/email', |
|
| 363 | - 'messages/data_class', |
|
| 364 | - 'messages/validators', |
|
| 365 | - 'messages/validators/email', |
|
| 366 | - 'messages/validators/html', |
|
| 367 | - 'shortcodes', |
|
| 368 | - ); |
|
| 369 | - $paths = array(); |
|
| 370 | - foreach ($dir_ref as $index => $dir) { |
|
| 371 | - $paths[$index] = EE_LIBRARIES . $dir; |
|
| 372 | - } |
|
| 373 | - self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - |
|
| 377 | - /** |
|
| 378 | - * Takes care of loading dependencies |
|
| 379 | - * |
|
| 380 | - * @since 4.5.0 |
|
| 381 | - * @return void |
|
| 382 | - */ |
|
| 383 | - protected static function _load_controller() |
|
| 384 | - { |
|
| 385 | - if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
| 386 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
| 387 | - self::set_autoloaders(); |
|
| 388 | - self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
|
| 389 | - self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
| 390 | - self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 391 | - } |
|
| 392 | - } |
|
| 393 | - |
|
| 394 | - |
|
| 395 | - /** |
|
| 396 | - * @param EE_Transaction $transaction |
|
| 397 | - */ |
|
| 398 | - public static function payment_reminder(EE_Transaction $transaction) |
|
| 399 | - { |
|
| 400 | - self::_load_controller(); |
|
| 401 | - $data = array($transaction, null); |
|
| 402 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data); |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - |
|
| 406 | - /** |
|
| 407 | - * Any messages triggers for after successful gateway payments should go in here. |
|
| 408 | - * |
|
| 409 | - * @param EE_Transaction object |
|
| 410 | - * @param EE_Payment object |
|
| 411 | - * @return void |
|
| 412 | - */ |
|
| 413 | - public static function payment(EE_Transaction $transaction, EE_Payment $payment) |
|
| 414 | - { |
|
| 415 | - self::_load_controller(); |
|
| 416 | - $data = array($transaction, $payment); |
|
| 417 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 418 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
| 419 | - //if payment amount is less than 0 then switch to payment_refund message type. |
|
| 420 | - $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
|
| 421 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - |
|
| 425 | - /** |
|
| 426 | - * @param EE_Transaction $transaction |
|
| 427 | - */ |
|
| 428 | - public static function cancelled_registration(EE_Transaction $transaction) |
|
| 429 | - { |
|
| 430 | - self::_load_controller(); |
|
| 431 | - $data = array($transaction, null); |
|
| 432 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data); |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - |
|
| 436 | - /** |
|
| 437 | - * Trigger for Registration messages |
|
| 438 | - * Note that what registration message type is sent depends on what the reg status is for the registrations on the |
|
| 439 | - * incoming transaction. |
|
| 440 | - * |
|
| 441 | - * @param EE_Registration $registration |
|
| 442 | - * @param array $extra_details |
|
| 443 | - * @return void |
|
| 444 | - */ |
|
| 445 | - public static function maybe_registration(EE_Registration $registration, $extra_details = array()) |
|
| 446 | - { |
|
| 447 | - |
|
| 448 | - if (! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
| 449 | - //no messages please |
|
| 450 | - return; |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - |
|
| 454 | - //get all registrations so we make sure we send messages for the right status. |
|
| 455 | - $all_registrations = $registration->transaction()->registrations(); |
|
| 456 | - |
|
| 457 | - //cached array of statuses so we only trigger messages once per status. |
|
| 458 | - $statuses_sent = array(); |
|
| 459 | - self::_load_controller(); |
|
| 460 | - $mtgs = array(); |
|
| 461 | - |
|
| 462 | - //loop through registrations and trigger messages once per status. |
|
| 463 | - foreach ($all_registrations as $reg) { |
|
| 464 | - |
|
| 465 | - //already triggered? |
|
| 466 | - if (in_array($reg->status_ID(), $statuses_sent)) { |
|
| 467 | - continue; |
|
| 468 | - } |
|
| 469 | - |
|
| 470 | - $message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID()); |
|
| 471 | - $mtgs = array_merge( |
|
| 472 | - $mtgs, |
|
| 473 | - self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( |
|
| 474 | - $message_type, |
|
| 475 | - array($registration->transaction(), null, $reg->status_ID()) |
|
| 476 | - ) |
|
| 477 | - ); |
|
| 478 | - $statuses_sent[] = $reg->status_ID(); |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - if (count($statuses_sent) > 1) { |
|
| 482 | - $mtgs = array_merge( |
|
| 483 | - $mtgs, |
|
| 484 | - self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( |
|
| 485 | - 'registration_summary', |
|
| 486 | - array($registration->transaction(), null) |
|
| 487 | - ) |
|
| 488 | - ); |
|
| 489 | - } |
|
| 490 | - |
|
| 491 | - //batch queue and initiate request |
|
| 492 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs); |
|
| 493 | - self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
|
| 494 | - } |
|
| 495 | - |
|
| 496 | - |
|
| 497 | - /** |
|
| 498 | - * This is a helper method used to very whether a registration notification should be sent or |
|
| 499 | - * not. Prevents duplicate notifications going out for registration context notifications. |
|
| 500 | - * |
|
| 501 | - * @param EE_Registration $registration [description] |
|
| 502 | - * @param array $extra_details [description] |
|
| 503 | - * @return bool true = send away, false = nope halt the presses. |
|
| 504 | - */ |
|
| 505 | - protected static function _verify_registration_notification_send( |
|
| 506 | - EE_Registration $registration, |
|
| 507 | - $extra_details = array() |
|
| 508 | - ) { |
|
| 509 | - //self::log( |
|
| 510 | - // __CLASS__, __FUNCTION__, __LINE__, |
|
| 511 | - // $registration->transaction(), |
|
| 512 | - // array( '$extra_details' => $extra_details ) |
|
| 513 | - //); |
|
| 514 | - // currently only using this to send messages for the primary registrant |
|
| 515 | - if (! $registration->is_primary_registrant()) { |
|
| 516 | - return false; |
|
| 517 | - } |
|
| 518 | - // first we check if we're in admin and not doing front ajax |
|
| 519 | - if (is_admin() && ! EE_FRONT_AJAX) { |
|
| 520 | - //make sure appropriate admin params are set for sending messages |
|
| 521 | - if (empty($_REQUEST['txn_reg_status_change']['send_notifications']) || ! absint($_REQUEST['txn_reg_status_change']['send_notifications'])) { |
|
| 522 | - //no messages sent please. |
|
| 523 | - return false; |
|
| 524 | - } |
|
| 525 | - } else { |
|
| 526 | - // frontend request (either regular or via AJAX) |
|
| 527 | - // TXN is NOT finalized ? |
|
| 528 | - if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
| 529 | - return false; |
|
| 530 | - } |
|
| 531 | - // return visit but nothing changed ??? |
|
| 532 | - if ( |
|
| 533 | - isset($extra_details['revisit'], $extra_details['status_updates']) && |
|
| 534 | - $extra_details['revisit'] && ! $extra_details['status_updates'] |
|
| 535 | - ) { |
|
| 536 | - return false; |
|
| 537 | - } |
|
| 538 | - // NOT sending messages && reg status is something other than "Not-Approved" |
|
| 539 | - if ( |
|
| 540 | - ! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) && |
|
| 541 | - $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
| 542 | - ) { |
|
| 543 | - return false; |
|
| 544 | - } |
|
| 545 | - } |
|
| 546 | - // release the kraken |
|
| 547 | - return true; |
|
| 548 | - } |
|
| 549 | - |
|
| 550 | - |
|
| 551 | - /** |
|
| 552 | - * Simply returns an array indexed by Registration Status ID and the related message_type name associated with that |
|
| 553 | - * status id. |
|
| 554 | - * |
|
| 555 | - * @deprecated 4.9.0 Use EEH_MSG_Template::reg_status_to_message_type_array() |
|
| 556 | - * or EEH_MSG_Template::convert_reg_status_to_message_type |
|
| 557 | - * @param string $reg_status |
|
| 558 | - * @return array |
|
| 559 | - */ |
|
| 560 | - protected static function _get_reg_status_array($reg_status = '') |
|
| 561 | - { |
|
| 562 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 563 | - return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
| 564 | - ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
| 565 | - : EEH_MSG_Template::reg_status_to_message_type_array(); |
|
| 566 | - } |
|
| 567 | - |
|
| 568 | - |
|
| 569 | - /** |
|
| 570 | - * Simply returns the payment message type for the given payment status. |
|
| 571 | - * |
|
| 572 | - * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array |
|
| 573 | - * or EEH_MSG_Template::convert_payment_status_to_message_type |
|
| 574 | - * @param string $payment_status The payment status being matched. |
|
| 575 | - * @return string|bool The payment message type slug matching the status or false if no match. |
|
| 576 | - */ |
|
| 577 | - protected static function _get_payment_message_type($payment_status) |
|
| 578 | - { |
|
| 579 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 580 | - return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
| 581 | - ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
| 582 | - : false; |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - |
|
| 586 | - /** |
|
| 587 | - * Message triggers for a resending already sent message(s) (via EE_Message list table) |
|
| 588 | - * |
|
| 589 | - * @access public |
|
| 590 | - * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages |
|
| 591 | - * @return bool success/fail |
|
| 592 | - */ |
|
| 593 | - public static function process_resend($req_data) |
|
| 594 | - { |
|
| 595 | - self::_load_controller(); |
|
| 596 | - |
|
| 597 | - //if $msgID in this request then skip to the new resend_message |
|
| 598 | - if (EE_Registry::instance()->REQ->get('MSG_ID')) { |
|
| 599 | - return self::resend_message(); |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - //make sure any incoming request data is set on the REQ so that it gets picked up later. |
|
| 603 | - $req_data = (array)$req_data; |
|
| 604 | - foreach ($req_data as $request_key => $request_value) { |
|
| 605 | - EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
| 606 | - } |
|
| 607 | - |
|
| 608 | - if (! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()) { |
|
| 609 | - return false; |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - try { |
|
| 613 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send); |
|
| 614 | - self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
|
| 615 | - } catch (EE_Error $e) { |
|
| 616 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 617 | - return false; |
|
| 618 | - } |
|
| 619 | - EE_Error::add_success( |
|
| 620 | - __('Messages have been successfully queued for generation and sending.', 'event_espresso') |
|
| 621 | - ); |
|
| 622 | - return true; //everything got queued. |
|
| 623 | - } |
|
| 624 | - |
|
| 625 | - |
|
| 626 | - /** |
|
| 627 | - * Message triggers for a resending already sent message(s) (via EE_Message list table) |
|
| 628 | - * |
|
| 629 | - * @return bool |
|
| 630 | - */ |
|
| 631 | - public static function resend_message() |
|
| 632 | - { |
|
| 633 | - self::_load_controller(); |
|
| 634 | - |
|
| 635 | - $msgID = EE_Registry::instance()->REQ->get('MSG_ID'); |
|
| 636 | - if (! $msgID) { |
|
| 637 | - EE_Error::add_error(__('Something went wrong because there is no "MSG_ID" value in the request', |
|
| 638 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 639 | - return false; |
|
| 640 | - } |
|
| 641 | - |
|
| 642 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array)$msgID); |
|
| 643 | - |
|
| 644 | - //setup success message. |
|
| 645 | - $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
| 646 | - EE_Error::add_success(sprintf( |
|
| 647 | - _n( |
|
| 648 | - 'There was %d message queued for resending.', |
|
| 649 | - 'There were %d messages queued for resending.', |
|
| 650 | - $count_ready_for_resend, |
|
| 651 | - 'event_espresso' |
|
| 652 | - ), |
|
| 653 | - $count_ready_for_resend |
|
| 654 | - )); |
|
| 655 | - return true; |
|
| 656 | - } |
|
| 657 | - |
|
| 658 | - |
|
| 659 | - /** |
|
| 660 | - * Message triggers for manual payment applied by admin |
|
| 661 | - * |
|
| 662 | - * @param EE_Payment $payment EE_payment object |
|
| 663 | - * @return bool success/fail |
|
| 664 | - */ |
|
| 665 | - public static function process_admin_payment(EE_Payment $payment) |
|
| 666 | - { |
|
| 667 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 668 | - //we need to get the transaction object |
|
| 669 | - $transaction = $payment->transaction(); |
|
| 670 | - if ($transaction instanceof EE_Transaction) { |
|
| 671 | - $data = array($transaction, $payment); |
|
| 672 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
| 673 | - |
|
| 674 | - //if payment amount is less than 0 then switch to payment_refund message type. |
|
| 675 | - $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
|
| 676 | - |
|
| 677 | - //if payment_refund is selected, but the status is NOT accepted. Then change message type to false so NO message notification goes out. |
|
| 678 | - $message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved ? false : $message_type; |
|
| 679 | - |
|
| 680 | - self::_load_controller(); |
|
| 681 | - |
|
| 682 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
| 683 | - |
|
| 684 | - //get count of queued for generation |
|
| 685 | - $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(array( |
|
| 686 | - EEM_Message::status_incomplete, |
|
| 687 | - EEM_Message::status_idle, |
|
| 688 | - )); |
|
| 689 | - |
|
| 690 | - if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) { |
|
| 691 | - add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
| 692 | - return true; |
|
| 693 | - } else { |
|
| 694 | - $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::instance()->stati_indicating_failed_sending()); |
|
| 695 | - /** |
|
| 696 | - * Verify that there are actually errors. If not then we return a success message because the queue might have been emptied due to successful |
|
| 697 | - * IMMEDIATE generation. |
|
| 698 | - */ |
|
| 699 | - if ($count_failed > 0) { |
|
| 700 | - EE_Error::add_error(sprintf( |
|
| 701 | - _n( |
|
| 702 | - 'The payment notification generation failed.', |
|
| 703 | - '%d payment notifications failed being sent.', |
|
| 704 | - $count_failed, |
|
| 705 | - 'event_espresso' |
|
| 706 | - ), |
|
| 707 | - $count_failed |
|
| 708 | - ), __FILE__, __FUNCTION__, __LINE__); |
|
| 709 | - |
|
| 710 | - return false; |
|
| 711 | - } else { |
|
| 712 | - add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
| 713 | - return true; |
|
| 714 | - } |
|
| 715 | - } |
|
| 716 | - } else { |
|
| 717 | - EE_Error::add_error( |
|
| 718 | - 'Unable to generate the payment notification because the given value for the transaction is invalid.', |
|
| 719 | - 'event_espresso' |
|
| 720 | - ); |
|
| 721 | - return false; |
|
| 722 | - } |
|
| 723 | - } |
|
| 724 | - |
|
| 725 | - |
|
| 726 | - /** |
|
| 727 | - * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send_with_registrations trigger |
|
| 728 | - * |
|
| 729 | - * @since 4.3.0 |
|
| 730 | - * @param EE_Registration[] $registrations an array of EE_Registration objects |
|
| 731 | - * @param int $grp_id a specific message template group id. |
|
| 732 | - * @return void |
|
| 733 | - */ |
|
| 734 | - public static function send_newsletter_message($registrations, $grp_id) |
|
| 735 | - { |
|
| 736 | - //make sure mtp is id and set it in the EE_Request Handler later messages setup. |
|
| 737 | - EE_Registry::instance()->REQ->set('GRP_ID', (int)$grp_id); |
|
| 738 | - self::_load_controller(); |
|
| 739 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations); |
|
| 740 | - } |
|
| 741 | - |
|
| 742 | - |
|
| 743 | - /** |
|
| 744 | - * Callback for FHEE__EE_Registration__invoice_url__invoice_url or FHEE__EE_Registration__receipt_url__receipt_url |
|
| 745 | - * |
|
| 746 | - * @since 4.3.0 |
|
| 747 | - * @param string $registration_message_trigger_url |
|
| 748 | - * @param EE_Registration $registration |
|
| 749 | - * @param string $messenger |
|
| 750 | - * @param string $message_type |
|
| 751 | - * @return string |
|
| 752 | - */ |
|
| 753 | - public static function registration_message_trigger_url( |
|
| 754 | - $registration_message_trigger_url, |
|
| 755 | - EE_Registration $registration, |
|
| 756 | - $messenger = 'html', |
|
| 757 | - $message_type = 'invoice' |
|
| 758 | - ) { |
|
| 759 | - // whitelist $messenger |
|
| 760 | - switch ($messenger) { |
|
| 761 | - case 'pdf' : |
|
| 762 | - $sending_messenger = 'pdf'; |
|
| 763 | - $generating_messenger = 'html'; |
|
| 764 | - break; |
|
| 765 | - case 'html' : |
|
| 766 | - default : |
|
| 767 | - $sending_messenger = 'html'; |
|
| 768 | - $generating_messenger = 'html'; |
|
| 769 | - break; |
|
| 770 | - } |
|
| 771 | - // whitelist $message_type |
|
| 772 | - switch ($message_type) { |
|
| 773 | - case 'receipt' : |
|
| 774 | - $message_type = 'receipt'; |
|
| 775 | - break; |
|
| 776 | - case 'invoice' : |
|
| 777 | - default : |
|
| 778 | - $message_type = 'invoice'; |
|
| 779 | - break; |
|
| 780 | - } |
|
| 781 | - // verify that both the messenger AND the message type are active |
|
| 782 | - if (EEH_MSG_Template::is_messenger_active($sending_messenger) && EEH_MSG_Template::is_mt_active($message_type)) { |
|
| 783 | - //need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?) |
|
| 784 | - $template_query_params = array( |
|
| 785 | - 'MTP_is_active' => true, |
|
| 786 | - 'MTP_messenger' => $generating_messenger, |
|
| 787 | - 'MTP_message_type' => $message_type, |
|
| 788 | - 'Event.EVT_ID' => $registration->event_ID(), |
|
| 789 | - ); |
|
| 790 | - //get the message template group. |
|
| 791 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
| 792 | - //if we don't have an EE_Message_Template_Group then return |
|
| 793 | - if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
| 794 | - // remove EVT_ID from query params so that global templates get picked up |
|
| 795 | - unset($template_query_params['Event.EVT_ID']); |
|
| 796 | - //get global template as the fallback |
|
| 797 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
| 798 | - } |
|
| 799 | - //if we don't have an EE_Message_Template_Group then return |
|
| 800 | - if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
| 801 | - return ''; |
|
| 802 | - } |
|
| 803 | - // generate the URL |
|
| 804 | - $registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger( |
|
| 805 | - $sending_messenger, |
|
| 806 | - $generating_messenger, |
|
| 807 | - 'purchaser', |
|
| 808 | - $message_type, |
|
| 809 | - $registration, |
|
| 810 | - $msg_template_group->ID(), |
|
| 811 | - $registration->transaction_ID() |
|
| 812 | - ); |
|
| 813 | - |
|
| 814 | - } |
|
| 815 | - return $registration_message_trigger_url; |
|
| 816 | - } |
|
| 817 | - |
|
| 818 | - |
|
| 819 | - /** |
|
| 820 | - * Use to generate and return a message preview! |
|
| 821 | - * |
|
| 822 | - * @param string $type This should correspond with a valid message type |
|
| 823 | - * @param string $context This should correspond with a valid context for the message type |
|
| 824 | - * @param string $messenger This should correspond with a valid messenger. |
|
| 825 | - * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular |
|
| 826 | - * preview |
|
| 827 | - * @return string|bool The body of the message or if send is requested, sends. |
|
| 828 | - */ |
|
| 829 | - public static function preview_message($type, $context, $messenger, $send = false) |
|
| 830 | - { |
|
| 831 | - self::_load_controller(); |
|
| 832 | - $mtg = new EE_Message_To_Generate( |
|
| 833 | - $messenger, |
|
| 834 | - $type, |
|
| 835 | - array(), |
|
| 836 | - $context, |
|
| 837 | - true |
|
| 838 | - ); |
|
| 839 | - $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg, $send); |
|
| 840 | - if ($generated_preview_queue instanceof EE_Messages_Queue) { |
|
| 841 | - return $generated_preview_queue->get_message_repository()->current()->content(); |
|
| 842 | - } else { |
|
| 843 | - return $generated_preview_queue; |
|
| 844 | - } |
|
| 845 | - } |
|
| 846 | - |
|
| 847 | - |
|
| 848 | - /** |
|
| 849 | - * This is a method that allows for sending a message using a messenger matching the string given and the provided |
|
| 850 | - * EE_Message_Queue object. The EE_Message_Queue object is used to create a single aggregate EE_Message via the |
|
| 851 | - * content found in the EE_Message objects in the queue. |
|
| 852 | - * |
|
| 853 | - * @since 4.9.0 |
|
| 854 | - * @param string $messenger a string matching a valid active messenger in the system |
|
| 855 | - * @param string $message_type Although it seems contrary to the name of the method, a message |
|
| 856 | - * type name is still required to send along the message type to the |
|
| 857 | - * messenger because this is used for determining what specific |
|
| 858 | - * variations might be loaded for the generated message. |
|
| 859 | - * @param EE_Messages_Queue $queue |
|
| 860 | - * @param string $custom_subject Can be used to set what the custom subject string will be on the |
|
| 861 | - * aggregate EE_Message object. |
|
| 862 | - * @return bool success or fail. |
|
| 863 | - */ |
|
| 864 | - public static function send_message_with_messenger_only( |
|
| 865 | - $messenger, |
|
| 866 | - $message_type, |
|
| 867 | - EE_Messages_Queue $queue, |
|
| 868 | - $custom_subject = '' |
|
| 869 | - ) { |
|
| 870 | - self::_load_controller(); |
|
| 871 | - /** @type EE_Message_To_Generate_From_Queue $message_to_generate */ |
|
| 872 | - $message_to_generate = EE_Registry::instance()->load_lib( |
|
| 873 | - 'Message_To_Generate_From_Queue', |
|
| 874 | - array( |
|
| 875 | - $messenger, |
|
| 876 | - $message_type, |
|
| 877 | - $queue, |
|
| 878 | - $custom_subject, |
|
| 879 | - ) |
|
| 880 | - ); |
|
| 881 | - return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate); |
|
| 882 | - } |
|
| 883 | - |
|
| 884 | - |
|
| 885 | - /** |
|
| 886 | - * Generates Messages immediately for EE_Message IDs (but only for the correct status for generation) |
|
| 887 | - * |
|
| 888 | - * @since 4.9.0 |
|
| 889 | - * @param array $message_ids An array of message ids |
|
| 890 | - * @return bool | EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated |
|
| 891 | - * messages. |
|
| 892 | - */ |
|
| 893 | - public static function generate_now($message_ids) |
|
| 894 | - { |
|
| 895 | - self::_load_controller(); |
|
| 896 | - $messages = EEM_Message::instance()->get_all( |
|
| 897 | - array( |
|
| 898 | - 0 => array( |
|
| 899 | - 'MSG_ID' => array('IN', $message_ids), |
|
| 900 | - 'STS_ID' => EEM_Message::status_incomplete, |
|
| 901 | - ), |
|
| 902 | - ) |
|
| 903 | - ); |
|
| 904 | - $generated_queue = false; |
|
| 905 | - if ($messages) { |
|
| 906 | - $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
|
| 907 | - } |
|
| 908 | - |
|
| 909 | - if (! $generated_queue instanceof EE_Messages_Queue) { |
|
| 910 | - EE_Error::add_error( |
|
| 911 | - __('The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.', |
|
| 912 | - 'event_espresso'), |
|
| 913 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 914 | - ); |
|
| 915 | - } |
|
| 916 | - return $generated_queue; |
|
| 917 | - } |
|
| 918 | - |
|
| 919 | - |
|
| 920 | - /** |
|
| 921 | - * Sends messages immediately for the incoming message_ids that have the status of EEM_Message::status_resend or, |
|
| 922 | - * EEM_Message::status_idle |
|
| 923 | - * |
|
| 924 | - * @since 4.9.0 |
|
| 925 | - * @param $message_ids |
|
| 926 | - * @return bool | EE_Messages_Queue false if no messages sent. |
|
| 927 | - */ |
|
| 928 | - public static function send_now($message_ids) |
|
| 929 | - { |
|
| 930 | - self::_load_controller(); |
|
| 931 | - $messages = EEM_Message::instance()->get_all( |
|
| 932 | - array( |
|
| 933 | - 0 => array( |
|
| 934 | - 'MSG_ID' => array('IN', $message_ids), |
|
| 935 | - 'STS_ID' => array( |
|
| 936 | - 'IN', |
|
| 937 | - array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry), |
|
| 938 | - ), |
|
| 939 | - ), |
|
| 940 | - ) |
|
| 941 | - ); |
|
| 942 | - $sent_queue = false; |
|
| 943 | - if ($messages) { |
|
| 944 | - $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
|
| 945 | - } |
|
| 946 | - |
|
| 947 | - if (! $sent_queue instanceof EE_Messages_Queue) { |
|
| 948 | - EE_Error::add_error( |
|
| 949 | - __('The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.', |
|
| 950 | - 'event_espresso'), |
|
| 951 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 952 | - ); |
|
| 953 | - } else { |
|
| 954 | - //can count how many sent by using the messages in the queue |
|
| 955 | - $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent()); |
|
| 956 | - if ($sent_count > 0) { |
|
| 957 | - EE_Error::add_success( |
|
| 958 | - sprintf( |
|
| 959 | - _n( |
|
| 960 | - 'There was %d message successfully sent.', |
|
| 961 | - 'There were %d messages successfully sent.', |
|
| 962 | - $sent_count, |
|
| 963 | - 'event_espresso' |
|
| 964 | - ), |
|
| 965 | - $sent_count |
|
| 966 | - ) |
|
| 967 | - ); |
|
| 968 | - } else { |
|
| 969 | - EE_Error::overwrite_errors(); |
|
| 970 | - EE_Error::add_error( |
|
| 971 | - __('No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error. |
|
| 201 | + exit; |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + return; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * This runs when the msg_url_trigger route has initiated. |
|
| 210 | + * |
|
| 211 | + * @since 4.5.0 |
|
| 212 | + * @param WP $WP |
|
| 213 | + * @throws EE_Error |
|
| 214 | + * @return void |
|
| 215 | + */ |
|
| 216 | + public function run($WP) |
|
| 217 | + { |
|
| 218 | + //ensure controller is loaded |
|
| 219 | + self::_load_controller(); |
|
| 220 | + // attempt to process message |
|
| 221 | + try { |
|
| 222 | + /** @type EE_Message_To_Generate_From_Request $message_to_generate */ |
|
| 223 | + $message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
| 224 | + self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate); |
|
| 225 | + } catch (EE_Error $e) { |
|
| 226 | + $error_msg = __('Please note that a system message failed to send due to a technical issue.', |
|
| 227 | + 'event_espresso'); |
|
| 228 | + // add specific message for developers if WP_DEBUG in on |
|
| 229 | + $error_msg .= '||' . $e->getMessage(); |
|
| 230 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * This is triggered by the 'msg_cron_trigger' route. |
|
| 237 | + * |
|
| 238 | + * @param WP $WP |
|
| 239 | + */ |
|
| 240 | + public function execute_batch_request($WP) |
|
| 241 | + { |
|
| 242 | + $this->run_cron(); |
|
| 243 | + header('HTTP/1.1 200 OK'); |
|
| 244 | + exit(); |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * This gets executed on wp_cron jobs or when a batch request is initiated on its own separate non regular wp |
|
| 250 | + * request. |
|
| 251 | + */ |
|
| 252 | + public function run_cron() |
|
| 253 | + { |
|
| 254 | + self::_load_controller(); |
|
| 255 | + //get required vars |
|
| 256 | + $cron_type = EE_Registry::instance()->REQ->get('type'); |
|
| 257 | + $transient_key = EE_Registry::instance()->REQ->get('key'); |
|
| 258 | + |
|
| 259 | + //now let's verify transient, if not valid exit immediately |
|
| 260 | + if (! get_transient($transient_key)) { |
|
| 261 | + /** |
|
| 262 | + * trigger error so this gets in the error logs. This is important because it happens on a non-user request. |
|
| 263 | + */ |
|
| 264 | + trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso')); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + //if made it here, lets' delete the transient to keep the db clean |
|
| 268 | + delete_transient($transient_key); |
|
| 269 | + |
|
| 270 | + if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) { |
|
| 271 | + |
|
| 272 | + $method = 'batch_' . $cron_type . '_from_queue'; |
|
| 273 | + if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
|
| 274 | + self::$_MSG_PROCESSOR->$method(); |
|
| 275 | + } else { |
|
| 276 | + //no matching task |
|
| 277 | + /** |
|
| 278 | + * trigger error so this gets in the error logs. This is important because it happens on a non user request. |
|
| 279 | + */ |
|
| 280 | + trigger_error(esc_attr(sprintf(__('There is no task corresponding to this route %s', 'event_espresso'), |
|
| 281 | + $cron_type))); |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + do_action('FHEE__EED_Messages__run_cron__end'); |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * This is used to retrieve the template pack for the given name. |
|
| 291 | + * Retrieved packs are cached on the static $_TMP_PACKS array. If there is no class matching the given name then |
|
| 292 | + * the default template pack is returned. |
|
| 293 | + * |
|
| 294 | + * @deprecated 4.9.0 @see EEH_MSG_Template::get_template_pack() |
|
| 295 | + * @param string $template_pack_name This should correspond to the dbref of the template pack (which is also used |
|
| 296 | + * in generating the Pack class name). |
|
| 297 | + * @return EE_Messages_Template_Pack |
|
| 298 | + */ |
|
| 299 | + public static function get_template_pack($template_pack_name) |
|
| 300 | + { |
|
| 301 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 302 | + return EEH_MSG_Template::get_template_pack($template_pack_name); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * Retrieves an array of all template packs. |
|
| 308 | + * Array is in the format array( 'dbref' => EE_Messages_Template_Pack ) |
|
| 309 | + * |
|
| 310 | + * @deprecated 4.9.0 @see EEH_MSG_Template_Pack::get_template_pack_collection |
|
| 311 | + * @return EE_Messages_Template_Pack[] |
|
| 312 | + */ |
|
| 313 | + public static function get_template_packs() |
|
| 314 | + { |
|
| 315 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 316 | + |
|
| 317 | + //for backward compat, let's make sure this returns in the same format as originally. |
|
| 318 | + $template_pack_collection = EEH_MSG_Template::get_template_pack_collection(); |
|
| 319 | + $template_pack_collection->rewind(); |
|
| 320 | + $template_packs = array(); |
|
| 321 | + while ($template_pack_collection->valid()) { |
|
| 322 | + $template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current(); |
|
| 323 | + $template_pack_collection->next(); |
|
| 324 | + } |
|
| 325 | + return $template_packs; |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + |
|
| 329 | + /** |
|
| 330 | + * This simply makes sure the autoloaders are registered for the EE_messages system. |
|
| 331 | + * |
|
| 332 | + * @since 4.5.0 |
|
| 333 | + * @return void |
|
| 334 | + */ |
|
| 335 | + public static function set_autoloaders() |
|
| 336 | + { |
|
| 337 | + if (empty(self::$_MSG_PATHS)) { |
|
| 338 | + self::_set_messages_paths(); |
|
| 339 | + foreach (self::$_MSG_PATHS as $path) { |
|
| 340 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path); |
|
| 341 | + } |
|
| 342 | + // add aliases |
|
| 343 | + EEH_Autoloader::add_alias('EE_messages', 'EE_messages'); |
|
| 344 | + EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger'); |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + |
|
| 349 | + /** |
|
| 350 | + * Take care of adding all the paths for the messages components to the $_MSG_PATHS property |
|
| 351 | + * for use by the Messages Autoloaders |
|
| 352 | + * |
|
| 353 | + * @since 4.5.0 |
|
| 354 | + * @return void. |
|
| 355 | + */ |
|
| 356 | + protected static function _set_messages_paths() |
|
| 357 | + { |
|
| 358 | + $dir_ref = array( |
|
| 359 | + 'messages/message_type', |
|
| 360 | + 'messages/messenger', |
|
| 361 | + 'messages/defaults', |
|
| 362 | + 'messages/defaults/email', |
|
| 363 | + 'messages/data_class', |
|
| 364 | + 'messages/validators', |
|
| 365 | + 'messages/validators/email', |
|
| 366 | + 'messages/validators/html', |
|
| 367 | + 'shortcodes', |
|
| 368 | + ); |
|
| 369 | + $paths = array(); |
|
| 370 | + foreach ($dir_ref as $index => $dir) { |
|
| 371 | + $paths[$index] = EE_LIBRARIES . $dir; |
|
| 372 | + } |
|
| 373 | + self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * Takes care of loading dependencies |
|
| 379 | + * |
|
| 380 | + * @since 4.5.0 |
|
| 381 | + * @return void |
|
| 382 | + */ |
|
| 383 | + protected static function _load_controller() |
|
| 384 | + { |
|
| 385 | + if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
| 386 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
| 387 | + self::set_autoloaders(); |
|
| 388 | + self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
|
| 389 | + self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
| 390 | + self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 391 | + } |
|
| 392 | + } |
|
| 393 | + |
|
| 394 | + |
|
| 395 | + /** |
|
| 396 | + * @param EE_Transaction $transaction |
|
| 397 | + */ |
|
| 398 | + public static function payment_reminder(EE_Transaction $transaction) |
|
| 399 | + { |
|
| 400 | + self::_load_controller(); |
|
| 401 | + $data = array($transaction, null); |
|
| 402 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data); |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + |
|
| 406 | + /** |
|
| 407 | + * Any messages triggers for after successful gateway payments should go in here. |
|
| 408 | + * |
|
| 409 | + * @param EE_Transaction object |
|
| 410 | + * @param EE_Payment object |
|
| 411 | + * @return void |
|
| 412 | + */ |
|
| 413 | + public static function payment(EE_Transaction $transaction, EE_Payment $payment) |
|
| 414 | + { |
|
| 415 | + self::_load_controller(); |
|
| 416 | + $data = array($transaction, $payment); |
|
| 417 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 418 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
| 419 | + //if payment amount is less than 0 then switch to payment_refund message type. |
|
| 420 | + $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
|
| 421 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + |
|
| 425 | + /** |
|
| 426 | + * @param EE_Transaction $transaction |
|
| 427 | + */ |
|
| 428 | + public static function cancelled_registration(EE_Transaction $transaction) |
|
| 429 | + { |
|
| 430 | + self::_load_controller(); |
|
| 431 | + $data = array($transaction, null); |
|
| 432 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data); |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + |
|
| 436 | + /** |
|
| 437 | + * Trigger for Registration messages |
|
| 438 | + * Note that what registration message type is sent depends on what the reg status is for the registrations on the |
|
| 439 | + * incoming transaction. |
|
| 440 | + * |
|
| 441 | + * @param EE_Registration $registration |
|
| 442 | + * @param array $extra_details |
|
| 443 | + * @return void |
|
| 444 | + */ |
|
| 445 | + public static function maybe_registration(EE_Registration $registration, $extra_details = array()) |
|
| 446 | + { |
|
| 447 | + |
|
| 448 | + if (! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
| 449 | + //no messages please |
|
| 450 | + return; |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + |
|
| 454 | + //get all registrations so we make sure we send messages for the right status. |
|
| 455 | + $all_registrations = $registration->transaction()->registrations(); |
|
| 456 | + |
|
| 457 | + //cached array of statuses so we only trigger messages once per status. |
|
| 458 | + $statuses_sent = array(); |
|
| 459 | + self::_load_controller(); |
|
| 460 | + $mtgs = array(); |
|
| 461 | + |
|
| 462 | + //loop through registrations and trigger messages once per status. |
|
| 463 | + foreach ($all_registrations as $reg) { |
|
| 464 | + |
|
| 465 | + //already triggered? |
|
| 466 | + if (in_array($reg->status_ID(), $statuses_sent)) { |
|
| 467 | + continue; |
|
| 468 | + } |
|
| 469 | + |
|
| 470 | + $message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID()); |
|
| 471 | + $mtgs = array_merge( |
|
| 472 | + $mtgs, |
|
| 473 | + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( |
|
| 474 | + $message_type, |
|
| 475 | + array($registration->transaction(), null, $reg->status_ID()) |
|
| 476 | + ) |
|
| 477 | + ); |
|
| 478 | + $statuses_sent[] = $reg->status_ID(); |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + if (count($statuses_sent) > 1) { |
|
| 482 | + $mtgs = array_merge( |
|
| 483 | + $mtgs, |
|
| 484 | + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( |
|
| 485 | + 'registration_summary', |
|
| 486 | + array($registration->transaction(), null) |
|
| 487 | + ) |
|
| 488 | + ); |
|
| 489 | + } |
|
| 490 | + |
|
| 491 | + //batch queue and initiate request |
|
| 492 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs); |
|
| 493 | + self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
|
| 494 | + } |
|
| 495 | + |
|
| 496 | + |
|
| 497 | + /** |
|
| 498 | + * This is a helper method used to very whether a registration notification should be sent or |
|
| 499 | + * not. Prevents duplicate notifications going out for registration context notifications. |
|
| 500 | + * |
|
| 501 | + * @param EE_Registration $registration [description] |
|
| 502 | + * @param array $extra_details [description] |
|
| 503 | + * @return bool true = send away, false = nope halt the presses. |
|
| 504 | + */ |
|
| 505 | + protected static function _verify_registration_notification_send( |
|
| 506 | + EE_Registration $registration, |
|
| 507 | + $extra_details = array() |
|
| 508 | + ) { |
|
| 509 | + //self::log( |
|
| 510 | + // __CLASS__, __FUNCTION__, __LINE__, |
|
| 511 | + // $registration->transaction(), |
|
| 512 | + // array( '$extra_details' => $extra_details ) |
|
| 513 | + //); |
|
| 514 | + // currently only using this to send messages for the primary registrant |
|
| 515 | + if (! $registration->is_primary_registrant()) { |
|
| 516 | + return false; |
|
| 517 | + } |
|
| 518 | + // first we check if we're in admin and not doing front ajax |
|
| 519 | + if (is_admin() && ! EE_FRONT_AJAX) { |
|
| 520 | + //make sure appropriate admin params are set for sending messages |
|
| 521 | + if (empty($_REQUEST['txn_reg_status_change']['send_notifications']) || ! absint($_REQUEST['txn_reg_status_change']['send_notifications'])) { |
|
| 522 | + //no messages sent please. |
|
| 523 | + return false; |
|
| 524 | + } |
|
| 525 | + } else { |
|
| 526 | + // frontend request (either regular or via AJAX) |
|
| 527 | + // TXN is NOT finalized ? |
|
| 528 | + if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
| 529 | + return false; |
|
| 530 | + } |
|
| 531 | + // return visit but nothing changed ??? |
|
| 532 | + if ( |
|
| 533 | + isset($extra_details['revisit'], $extra_details['status_updates']) && |
|
| 534 | + $extra_details['revisit'] && ! $extra_details['status_updates'] |
|
| 535 | + ) { |
|
| 536 | + return false; |
|
| 537 | + } |
|
| 538 | + // NOT sending messages && reg status is something other than "Not-Approved" |
|
| 539 | + if ( |
|
| 540 | + ! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) && |
|
| 541 | + $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
| 542 | + ) { |
|
| 543 | + return false; |
|
| 544 | + } |
|
| 545 | + } |
|
| 546 | + // release the kraken |
|
| 547 | + return true; |
|
| 548 | + } |
|
| 549 | + |
|
| 550 | + |
|
| 551 | + /** |
|
| 552 | + * Simply returns an array indexed by Registration Status ID and the related message_type name associated with that |
|
| 553 | + * status id. |
|
| 554 | + * |
|
| 555 | + * @deprecated 4.9.0 Use EEH_MSG_Template::reg_status_to_message_type_array() |
|
| 556 | + * or EEH_MSG_Template::convert_reg_status_to_message_type |
|
| 557 | + * @param string $reg_status |
|
| 558 | + * @return array |
|
| 559 | + */ |
|
| 560 | + protected static function _get_reg_status_array($reg_status = '') |
|
| 561 | + { |
|
| 562 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 563 | + return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
| 564 | + ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
| 565 | + : EEH_MSG_Template::reg_status_to_message_type_array(); |
|
| 566 | + } |
|
| 567 | + |
|
| 568 | + |
|
| 569 | + /** |
|
| 570 | + * Simply returns the payment message type for the given payment status. |
|
| 571 | + * |
|
| 572 | + * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array |
|
| 573 | + * or EEH_MSG_Template::convert_payment_status_to_message_type |
|
| 574 | + * @param string $payment_status The payment status being matched. |
|
| 575 | + * @return string|bool The payment message type slug matching the status or false if no match. |
|
| 576 | + */ |
|
| 577 | + protected static function _get_payment_message_type($payment_status) |
|
| 578 | + { |
|
| 579 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 580 | + return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
| 581 | + ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
| 582 | + : false; |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + |
|
| 586 | + /** |
|
| 587 | + * Message triggers for a resending already sent message(s) (via EE_Message list table) |
|
| 588 | + * |
|
| 589 | + * @access public |
|
| 590 | + * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages |
|
| 591 | + * @return bool success/fail |
|
| 592 | + */ |
|
| 593 | + public static function process_resend($req_data) |
|
| 594 | + { |
|
| 595 | + self::_load_controller(); |
|
| 596 | + |
|
| 597 | + //if $msgID in this request then skip to the new resend_message |
|
| 598 | + if (EE_Registry::instance()->REQ->get('MSG_ID')) { |
|
| 599 | + return self::resend_message(); |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + //make sure any incoming request data is set on the REQ so that it gets picked up later. |
|
| 603 | + $req_data = (array)$req_data; |
|
| 604 | + foreach ($req_data as $request_key => $request_value) { |
|
| 605 | + EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
| 606 | + } |
|
| 607 | + |
|
| 608 | + if (! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()) { |
|
| 609 | + return false; |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + try { |
|
| 613 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send); |
|
| 614 | + self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
|
| 615 | + } catch (EE_Error $e) { |
|
| 616 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 617 | + return false; |
|
| 618 | + } |
|
| 619 | + EE_Error::add_success( |
|
| 620 | + __('Messages have been successfully queued for generation and sending.', 'event_espresso') |
|
| 621 | + ); |
|
| 622 | + return true; //everything got queued. |
|
| 623 | + } |
|
| 624 | + |
|
| 625 | + |
|
| 626 | + /** |
|
| 627 | + * Message triggers for a resending already sent message(s) (via EE_Message list table) |
|
| 628 | + * |
|
| 629 | + * @return bool |
|
| 630 | + */ |
|
| 631 | + public static function resend_message() |
|
| 632 | + { |
|
| 633 | + self::_load_controller(); |
|
| 634 | + |
|
| 635 | + $msgID = EE_Registry::instance()->REQ->get('MSG_ID'); |
|
| 636 | + if (! $msgID) { |
|
| 637 | + EE_Error::add_error(__('Something went wrong because there is no "MSG_ID" value in the request', |
|
| 638 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 639 | + return false; |
|
| 640 | + } |
|
| 641 | + |
|
| 642 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array)$msgID); |
|
| 643 | + |
|
| 644 | + //setup success message. |
|
| 645 | + $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
| 646 | + EE_Error::add_success(sprintf( |
|
| 647 | + _n( |
|
| 648 | + 'There was %d message queued for resending.', |
|
| 649 | + 'There were %d messages queued for resending.', |
|
| 650 | + $count_ready_for_resend, |
|
| 651 | + 'event_espresso' |
|
| 652 | + ), |
|
| 653 | + $count_ready_for_resend |
|
| 654 | + )); |
|
| 655 | + return true; |
|
| 656 | + } |
|
| 657 | + |
|
| 658 | + |
|
| 659 | + /** |
|
| 660 | + * Message triggers for manual payment applied by admin |
|
| 661 | + * |
|
| 662 | + * @param EE_Payment $payment EE_payment object |
|
| 663 | + * @return bool success/fail |
|
| 664 | + */ |
|
| 665 | + public static function process_admin_payment(EE_Payment $payment) |
|
| 666 | + { |
|
| 667 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 668 | + //we need to get the transaction object |
|
| 669 | + $transaction = $payment->transaction(); |
|
| 670 | + if ($transaction instanceof EE_Transaction) { |
|
| 671 | + $data = array($transaction, $payment); |
|
| 672 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
| 673 | + |
|
| 674 | + //if payment amount is less than 0 then switch to payment_refund message type. |
|
| 675 | + $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
|
| 676 | + |
|
| 677 | + //if payment_refund is selected, but the status is NOT accepted. Then change message type to false so NO message notification goes out. |
|
| 678 | + $message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved ? false : $message_type; |
|
| 679 | + |
|
| 680 | + self::_load_controller(); |
|
| 681 | + |
|
| 682 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
| 683 | + |
|
| 684 | + //get count of queued for generation |
|
| 685 | + $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(array( |
|
| 686 | + EEM_Message::status_incomplete, |
|
| 687 | + EEM_Message::status_idle, |
|
| 688 | + )); |
|
| 689 | + |
|
| 690 | + if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) { |
|
| 691 | + add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
| 692 | + return true; |
|
| 693 | + } else { |
|
| 694 | + $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::instance()->stati_indicating_failed_sending()); |
|
| 695 | + /** |
|
| 696 | + * Verify that there are actually errors. If not then we return a success message because the queue might have been emptied due to successful |
|
| 697 | + * IMMEDIATE generation. |
|
| 698 | + */ |
|
| 699 | + if ($count_failed > 0) { |
|
| 700 | + EE_Error::add_error(sprintf( |
|
| 701 | + _n( |
|
| 702 | + 'The payment notification generation failed.', |
|
| 703 | + '%d payment notifications failed being sent.', |
|
| 704 | + $count_failed, |
|
| 705 | + 'event_espresso' |
|
| 706 | + ), |
|
| 707 | + $count_failed |
|
| 708 | + ), __FILE__, __FUNCTION__, __LINE__); |
|
| 709 | + |
|
| 710 | + return false; |
|
| 711 | + } else { |
|
| 712 | + add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
| 713 | + return true; |
|
| 714 | + } |
|
| 715 | + } |
|
| 716 | + } else { |
|
| 717 | + EE_Error::add_error( |
|
| 718 | + 'Unable to generate the payment notification because the given value for the transaction is invalid.', |
|
| 719 | + 'event_espresso' |
|
| 720 | + ); |
|
| 721 | + return false; |
|
| 722 | + } |
|
| 723 | + } |
|
| 724 | + |
|
| 725 | + |
|
| 726 | + /** |
|
| 727 | + * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send_with_registrations trigger |
|
| 728 | + * |
|
| 729 | + * @since 4.3.0 |
|
| 730 | + * @param EE_Registration[] $registrations an array of EE_Registration objects |
|
| 731 | + * @param int $grp_id a specific message template group id. |
|
| 732 | + * @return void |
|
| 733 | + */ |
|
| 734 | + public static function send_newsletter_message($registrations, $grp_id) |
|
| 735 | + { |
|
| 736 | + //make sure mtp is id and set it in the EE_Request Handler later messages setup. |
|
| 737 | + EE_Registry::instance()->REQ->set('GRP_ID', (int)$grp_id); |
|
| 738 | + self::_load_controller(); |
|
| 739 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations); |
|
| 740 | + } |
|
| 741 | + |
|
| 742 | + |
|
| 743 | + /** |
|
| 744 | + * Callback for FHEE__EE_Registration__invoice_url__invoice_url or FHEE__EE_Registration__receipt_url__receipt_url |
|
| 745 | + * |
|
| 746 | + * @since 4.3.0 |
|
| 747 | + * @param string $registration_message_trigger_url |
|
| 748 | + * @param EE_Registration $registration |
|
| 749 | + * @param string $messenger |
|
| 750 | + * @param string $message_type |
|
| 751 | + * @return string |
|
| 752 | + */ |
|
| 753 | + public static function registration_message_trigger_url( |
|
| 754 | + $registration_message_trigger_url, |
|
| 755 | + EE_Registration $registration, |
|
| 756 | + $messenger = 'html', |
|
| 757 | + $message_type = 'invoice' |
|
| 758 | + ) { |
|
| 759 | + // whitelist $messenger |
|
| 760 | + switch ($messenger) { |
|
| 761 | + case 'pdf' : |
|
| 762 | + $sending_messenger = 'pdf'; |
|
| 763 | + $generating_messenger = 'html'; |
|
| 764 | + break; |
|
| 765 | + case 'html' : |
|
| 766 | + default : |
|
| 767 | + $sending_messenger = 'html'; |
|
| 768 | + $generating_messenger = 'html'; |
|
| 769 | + break; |
|
| 770 | + } |
|
| 771 | + // whitelist $message_type |
|
| 772 | + switch ($message_type) { |
|
| 773 | + case 'receipt' : |
|
| 774 | + $message_type = 'receipt'; |
|
| 775 | + break; |
|
| 776 | + case 'invoice' : |
|
| 777 | + default : |
|
| 778 | + $message_type = 'invoice'; |
|
| 779 | + break; |
|
| 780 | + } |
|
| 781 | + // verify that both the messenger AND the message type are active |
|
| 782 | + if (EEH_MSG_Template::is_messenger_active($sending_messenger) && EEH_MSG_Template::is_mt_active($message_type)) { |
|
| 783 | + //need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?) |
|
| 784 | + $template_query_params = array( |
|
| 785 | + 'MTP_is_active' => true, |
|
| 786 | + 'MTP_messenger' => $generating_messenger, |
|
| 787 | + 'MTP_message_type' => $message_type, |
|
| 788 | + 'Event.EVT_ID' => $registration->event_ID(), |
|
| 789 | + ); |
|
| 790 | + //get the message template group. |
|
| 791 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
| 792 | + //if we don't have an EE_Message_Template_Group then return |
|
| 793 | + if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
| 794 | + // remove EVT_ID from query params so that global templates get picked up |
|
| 795 | + unset($template_query_params['Event.EVT_ID']); |
|
| 796 | + //get global template as the fallback |
|
| 797 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
| 798 | + } |
|
| 799 | + //if we don't have an EE_Message_Template_Group then return |
|
| 800 | + if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
| 801 | + return ''; |
|
| 802 | + } |
|
| 803 | + // generate the URL |
|
| 804 | + $registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger( |
|
| 805 | + $sending_messenger, |
|
| 806 | + $generating_messenger, |
|
| 807 | + 'purchaser', |
|
| 808 | + $message_type, |
|
| 809 | + $registration, |
|
| 810 | + $msg_template_group->ID(), |
|
| 811 | + $registration->transaction_ID() |
|
| 812 | + ); |
|
| 813 | + |
|
| 814 | + } |
|
| 815 | + return $registration_message_trigger_url; |
|
| 816 | + } |
|
| 817 | + |
|
| 818 | + |
|
| 819 | + /** |
|
| 820 | + * Use to generate and return a message preview! |
|
| 821 | + * |
|
| 822 | + * @param string $type This should correspond with a valid message type |
|
| 823 | + * @param string $context This should correspond with a valid context for the message type |
|
| 824 | + * @param string $messenger This should correspond with a valid messenger. |
|
| 825 | + * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular |
|
| 826 | + * preview |
|
| 827 | + * @return string|bool The body of the message or if send is requested, sends. |
|
| 828 | + */ |
|
| 829 | + public static function preview_message($type, $context, $messenger, $send = false) |
|
| 830 | + { |
|
| 831 | + self::_load_controller(); |
|
| 832 | + $mtg = new EE_Message_To_Generate( |
|
| 833 | + $messenger, |
|
| 834 | + $type, |
|
| 835 | + array(), |
|
| 836 | + $context, |
|
| 837 | + true |
|
| 838 | + ); |
|
| 839 | + $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg, $send); |
|
| 840 | + if ($generated_preview_queue instanceof EE_Messages_Queue) { |
|
| 841 | + return $generated_preview_queue->get_message_repository()->current()->content(); |
|
| 842 | + } else { |
|
| 843 | + return $generated_preview_queue; |
|
| 844 | + } |
|
| 845 | + } |
|
| 846 | + |
|
| 847 | + |
|
| 848 | + /** |
|
| 849 | + * This is a method that allows for sending a message using a messenger matching the string given and the provided |
|
| 850 | + * EE_Message_Queue object. The EE_Message_Queue object is used to create a single aggregate EE_Message via the |
|
| 851 | + * content found in the EE_Message objects in the queue. |
|
| 852 | + * |
|
| 853 | + * @since 4.9.0 |
|
| 854 | + * @param string $messenger a string matching a valid active messenger in the system |
|
| 855 | + * @param string $message_type Although it seems contrary to the name of the method, a message |
|
| 856 | + * type name is still required to send along the message type to the |
|
| 857 | + * messenger because this is used for determining what specific |
|
| 858 | + * variations might be loaded for the generated message. |
|
| 859 | + * @param EE_Messages_Queue $queue |
|
| 860 | + * @param string $custom_subject Can be used to set what the custom subject string will be on the |
|
| 861 | + * aggregate EE_Message object. |
|
| 862 | + * @return bool success or fail. |
|
| 863 | + */ |
|
| 864 | + public static function send_message_with_messenger_only( |
|
| 865 | + $messenger, |
|
| 866 | + $message_type, |
|
| 867 | + EE_Messages_Queue $queue, |
|
| 868 | + $custom_subject = '' |
|
| 869 | + ) { |
|
| 870 | + self::_load_controller(); |
|
| 871 | + /** @type EE_Message_To_Generate_From_Queue $message_to_generate */ |
|
| 872 | + $message_to_generate = EE_Registry::instance()->load_lib( |
|
| 873 | + 'Message_To_Generate_From_Queue', |
|
| 874 | + array( |
|
| 875 | + $messenger, |
|
| 876 | + $message_type, |
|
| 877 | + $queue, |
|
| 878 | + $custom_subject, |
|
| 879 | + ) |
|
| 880 | + ); |
|
| 881 | + return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate); |
|
| 882 | + } |
|
| 883 | + |
|
| 884 | + |
|
| 885 | + /** |
|
| 886 | + * Generates Messages immediately for EE_Message IDs (but only for the correct status for generation) |
|
| 887 | + * |
|
| 888 | + * @since 4.9.0 |
|
| 889 | + * @param array $message_ids An array of message ids |
|
| 890 | + * @return bool | EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated |
|
| 891 | + * messages. |
|
| 892 | + */ |
|
| 893 | + public static function generate_now($message_ids) |
|
| 894 | + { |
|
| 895 | + self::_load_controller(); |
|
| 896 | + $messages = EEM_Message::instance()->get_all( |
|
| 897 | + array( |
|
| 898 | + 0 => array( |
|
| 899 | + 'MSG_ID' => array('IN', $message_ids), |
|
| 900 | + 'STS_ID' => EEM_Message::status_incomplete, |
|
| 901 | + ), |
|
| 902 | + ) |
|
| 903 | + ); |
|
| 904 | + $generated_queue = false; |
|
| 905 | + if ($messages) { |
|
| 906 | + $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
|
| 907 | + } |
|
| 908 | + |
|
| 909 | + if (! $generated_queue instanceof EE_Messages_Queue) { |
|
| 910 | + EE_Error::add_error( |
|
| 911 | + __('The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.', |
|
| 912 | + 'event_espresso'), |
|
| 913 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 914 | + ); |
|
| 915 | + } |
|
| 916 | + return $generated_queue; |
|
| 917 | + } |
|
| 918 | + |
|
| 919 | + |
|
| 920 | + /** |
|
| 921 | + * Sends messages immediately for the incoming message_ids that have the status of EEM_Message::status_resend or, |
|
| 922 | + * EEM_Message::status_idle |
|
| 923 | + * |
|
| 924 | + * @since 4.9.0 |
|
| 925 | + * @param $message_ids |
|
| 926 | + * @return bool | EE_Messages_Queue false if no messages sent. |
|
| 927 | + */ |
|
| 928 | + public static function send_now($message_ids) |
|
| 929 | + { |
|
| 930 | + self::_load_controller(); |
|
| 931 | + $messages = EEM_Message::instance()->get_all( |
|
| 932 | + array( |
|
| 933 | + 0 => array( |
|
| 934 | + 'MSG_ID' => array('IN', $message_ids), |
|
| 935 | + 'STS_ID' => array( |
|
| 936 | + 'IN', |
|
| 937 | + array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry), |
|
| 938 | + ), |
|
| 939 | + ), |
|
| 940 | + ) |
|
| 941 | + ); |
|
| 942 | + $sent_queue = false; |
|
| 943 | + if ($messages) { |
|
| 944 | + $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
|
| 945 | + } |
|
| 946 | + |
|
| 947 | + if (! $sent_queue instanceof EE_Messages_Queue) { |
|
| 948 | + EE_Error::add_error( |
|
| 949 | + __('The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.', |
|
| 950 | + 'event_espresso'), |
|
| 951 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 952 | + ); |
|
| 953 | + } else { |
|
| 954 | + //can count how many sent by using the messages in the queue |
|
| 955 | + $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent()); |
|
| 956 | + if ($sent_count > 0) { |
|
| 957 | + EE_Error::add_success( |
|
| 958 | + sprintf( |
|
| 959 | + _n( |
|
| 960 | + 'There was %d message successfully sent.', |
|
| 961 | + 'There were %d messages successfully sent.', |
|
| 962 | + $sent_count, |
|
| 963 | + 'event_espresso' |
|
| 964 | + ), |
|
| 965 | + $sent_count |
|
| 966 | + ) |
|
| 967 | + ); |
|
| 968 | + } else { |
|
| 969 | + EE_Error::overwrite_errors(); |
|
| 970 | + EE_Error::add_error( |
|
| 971 | + __('No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error. |
|
| 972 | 972 | If there was an error, you can look at the messages in the message activity list table for any error messages.', |
| 973 | - 'event_espresso'), |
|
| 974 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 975 | - ); |
|
| 976 | - } |
|
| 977 | - } |
|
| 978 | - return $sent_queue; |
|
| 979 | - } |
|
| 980 | - |
|
| 981 | - |
|
| 982 | - /** |
|
| 983 | - * This will queue the incoming message ids for resending. |
|
| 984 | - * Note, only message_ids corresponding to messages with the status of EEM_Message::sent will be queued. |
|
| 985 | - * |
|
| 986 | - * @since 4.9.0 |
|
| 987 | - * @param array $message_ids An array of EE_Message IDs |
|
| 988 | - * @return bool true means messages were successfully queued for resending, false means none were queued for |
|
| 989 | - * resending. |
|
| 990 | - */ |
|
| 991 | - public static function queue_for_resending($message_ids) |
|
| 992 | - { |
|
| 993 | - self::_load_controller(); |
|
| 994 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids); |
|
| 995 | - |
|
| 996 | - //get queue and count |
|
| 997 | - $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
| 998 | - |
|
| 999 | - if ( |
|
| 1000 | - $queue_count > 0 |
|
| 1001 | - ) { |
|
| 1002 | - EE_Error::add_success( |
|
| 1003 | - sprintf( |
|
| 1004 | - _n( |
|
| 1005 | - '%d message successfully queued for resending.', |
|
| 1006 | - '%d messages successfully queued for resending.', |
|
| 1007 | - $queue_count, |
|
| 1008 | - 'event_espresso' |
|
| 1009 | - ), |
|
| 1010 | - $queue_count |
|
| 1011 | - ) |
|
| 1012 | - ); |
|
| 1013 | - /** |
|
| 1014 | - * @see filter usage in EE_Messages_Queue::initiate_request_by_priority |
|
| 1015 | - */ |
|
| 1016 | - } elseif ( |
|
| 1017 | - apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true) |
|
| 1018 | - || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
| 1019 | - ) { |
|
| 1020 | - $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent); |
|
| 1021 | - if ($queue_count > 0) { |
|
| 1022 | - EE_Error::add_success( |
|
| 1023 | - sprintf( |
|
| 1024 | - _n( |
|
| 1025 | - '%d message successfully sent.', |
|
| 1026 | - '%d messages successfully sent.', |
|
| 1027 | - $queue_count, |
|
| 1028 | - 'event_espresso' |
|
| 1029 | - ), |
|
| 1030 | - $queue_count |
|
| 1031 | - ) |
|
| 1032 | - ); |
|
| 1033 | - } else { |
|
| 1034 | - EE_Error::add_error( |
|
| 1035 | - __('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', |
|
| 1036 | - 'event_espresso'), |
|
| 1037 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 1038 | - ); |
|
| 1039 | - } |
|
| 1040 | - } else { |
|
| 1041 | - EE_Error::add_error( |
|
| 1042 | - __('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', |
|
| 1043 | - 'event_espresso'), |
|
| 1044 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 1045 | - ); |
|
| 1046 | - } |
|
| 1047 | - return (bool)$queue_count; |
|
| 1048 | - } |
|
| 1049 | - |
|
| 1050 | - |
|
| 1051 | - /** |
|
| 1052 | - * debug |
|
| 1053 | - * |
|
| 1054 | - * @param string $class |
|
| 1055 | - * @param string $func |
|
| 1056 | - * @param string $line |
|
| 1057 | - * @param \EE_Transaction $transaction |
|
| 1058 | - * @param array $info |
|
| 1059 | - * @param bool $display_request |
|
| 1060 | - */ |
|
| 1061 | - protected static function log( |
|
| 1062 | - $class = '', |
|
| 1063 | - $func = '', |
|
| 1064 | - $line = '', |
|
| 1065 | - EE_Transaction $transaction, |
|
| 1066 | - $info = array(), |
|
| 1067 | - $display_request = false |
|
| 1068 | - ) { |
|
| 1069 | - if (WP_DEBUG && false) { |
|
| 1070 | - if ($transaction instanceof EE_Transaction) { |
|
| 1071 | - // don't serialize objects |
|
| 1072 | - $info = EEH_Debug_Tools::strip_objects($info); |
|
| 1073 | - $info['TXN_status'] = $transaction->status_ID(); |
|
| 1074 | - $info['TXN_reg_steps'] = $transaction->reg_steps(); |
|
| 1075 | - if ($transaction->ID()) { |
|
| 1076 | - $index = 'EE_Transaction: ' . $transaction->ID(); |
|
| 1077 | - EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
| 1078 | - } |
|
| 1079 | - } |
|
| 1080 | - } |
|
| 1081 | - |
|
| 1082 | - } |
|
| 1083 | - |
|
| 1084 | - |
|
| 1085 | - /** |
|
| 1086 | - * Resets all the static properties in this class when called. |
|
| 1087 | - */ |
|
| 1088 | - public static function reset() |
|
| 1089 | - { |
|
| 1090 | - self::$_EEMSG = null; |
|
| 1091 | - self::$_message_resource_manager = null; |
|
| 1092 | - self::$_MSG_PROCESSOR = null; |
|
| 1093 | - self::$_MSG_PATHS = null; |
|
| 1094 | - self::$_TMP_PACKS = array(); |
|
| 1095 | - } |
|
| 973 | + 'event_espresso'), |
|
| 974 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 975 | + ); |
|
| 976 | + } |
|
| 977 | + } |
|
| 978 | + return $sent_queue; |
|
| 979 | + } |
|
| 980 | + |
|
| 981 | + |
|
| 982 | + /** |
|
| 983 | + * This will queue the incoming message ids for resending. |
|
| 984 | + * Note, only message_ids corresponding to messages with the status of EEM_Message::sent will be queued. |
|
| 985 | + * |
|
| 986 | + * @since 4.9.0 |
|
| 987 | + * @param array $message_ids An array of EE_Message IDs |
|
| 988 | + * @return bool true means messages were successfully queued for resending, false means none were queued for |
|
| 989 | + * resending. |
|
| 990 | + */ |
|
| 991 | + public static function queue_for_resending($message_ids) |
|
| 992 | + { |
|
| 993 | + self::_load_controller(); |
|
| 994 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids); |
|
| 995 | + |
|
| 996 | + //get queue and count |
|
| 997 | + $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
| 998 | + |
|
| 999 | + if ( |
|
| 1000 | + $queue_count > 0 |
|
| 1001 | + ) { |
|
| 1002 | + EE_Error::add_success( |
|
| 1003 | + sprintf( |
|
| 1004 | + _n( |
|
| 1005 | + '%d message successfully queued for resending.', |
|
| 1006 | + '%d messages successfully queued for resending.', |
|
| 1007 | + $queue_count, |
|
| 1008 | + 'event_espresso' |
|
| 1009 | + ), |
|
| 1010 | + $queue_count |
|
| 1011 | + ) |
|
| 1012 | + ); |
|
| 1013 | + /** |
|
| 1014 | + * @see filter usage in EE_Messages_Queue::initiate_request_by_priority |
|
| 1015 | + */ |
|
| 1016 | + } elseif ( |
|
| 1017 | + apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true) |
|
| 1018 | + || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
| 1019 | + ) { |
|
| 1020 | + $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent); |
|
| 1021 | + if ($queue_count > 0) { |
|
| 1022 | + EE_Error::add_success( |
|
| 1023 | + sprintf( |
|
| 1024 | + _n( |
|
| 1025 | + '%d message successfully sent.', |
|
| 1026 | + '%d messages successfully sent.', |
|
| 1027 | + $queue_count, |
|
| 1028 | + 'event_espresso' |
|
| 1029 | + ), |
|
| 1030 | + $queue_count |
|
| 1031 | + ) |
|
| 1032 | + ); |
|
| 1033 | + } else { |
|
| 1034 | + EE_Error::add_error( |
|
| 1035 | + __('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', |
|
| 1036 | + 'event_espresso'), |
|
| 1037 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 1038 | + ); |
|
| 1039 | + } |
|
| 1040 | + } else { |
|
| 1041 | + EE_Error::add_error( |
|
| 1042 | + __('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', |
|
| 1043 | + 'event_espresso'), |
|
| 1044 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 1045 | + ); |
|
| 1046 | + } |
|
| 1047 | + return (bool)$queue_count; |
|
| 1048 | + } |
|
| 1049 | + |
|
| 1050 | + |
|
| 1051 | + /** |
|
| 1052 | + * debug |
|
| 1053 | + * |
|
| 1054 | + * @param string $class |
|
| 1055 | + * @param string $func |
|
| 1056 | + * @param string $line |
|
| 1057 | + * @param \EE_Transaction $transaction |
|
| 1058 | + * @param array $info |
|
| 1059 | + * @param bool $display_request |
|
| 1060 | + */ |
|
| 1061 | + protected static function log( |
|
| 1062 | + $class = '', |
|
| 1063 | + $func = '', |
|
| 1064 | + $line = '', |
|
| 1065 | + EE_Transaction $transaction, |
|
| 1066 | + $info = array(), |
|
| 1067 | + $display_request = false |
|
| 1068 | + ) { |
|
| 1069 | + if (WP_DEBUG && false) { |
|
| 1070 | + if ($transaction instanceof EE_Transaction) { |
|
| 1071 | + // don't serialize objects |
|
| 1072 | + $info = EEH_Debug_Tools::strip_objects($info); |
|
| 1073 | + $info['TXN_status'] = $transaction->status_ID(); |
|
| 1074 | + $info['TXN_reg_steps'] = $transaction->reg_steps(); |
|
| 1075 | + if ($transaction->ID()) { |
|
| 1076 | + $index = 'EE_Transaction: ' . $transaction->ID(); |
|
| 1077 | + EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
| 1078 | + } |
|
| 1079 | + } |
|
| 1080 | + } |
|
| 1081 | + |
|
| 1082 | + } |
|
| 1083 | + |
|
| 1084 | + |
|
| 1085 | + /** |
|
| 1086 | + * Resets all the static properties in this class when called. |
|
| 1087 | + */ |
|
| 1088 | + public static function reset() |
|
| 1089 | + { |
|
| 1090 | + self::$_EEMSG = null; |
|
| 1091 | + self::$_message_resource_manager = null; |
|
| 1092 | + self::$_MSG_PROCESSOR = null; |
|
| 1093 | + self::$_MSG_PATHS = null; |
|
| 1094 | + self::$_TMP_PACKS = array(); |
|
| 1095 | + } |
|
| 1096 | 1096 | |
| 1097 | 1097 | } |
| 1098 | 1098 | // End of file EED_Messages.module.php |
@@ -17,254 +17,252 @@ |
||
| 17 | 17 | class TableManager extends \EE_Base |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var TableAnalysis $table_analysis |
|
| 22 | - */ |
|
| 23 | - private $table_analysis; |
|
| 24 | - |
|
| 25 | - |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * TableManager constructor. |
|
| 29 | - * |
|
| 30 | - * @param TableAnalysis $TableAnalysis |
|
| 31 | - */ |
|
| 32 | - public function __construct(TableAnalysis $TableAnalysis) |
|
| 33 | - { |
|
| 34 | - $this->table_analysis = $TableAnalysis; |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Gets the injected table analyzer, or throws an exception |
|
| 41 | - * |
|
| 42 | - * @return TableAnalysis |
|
| 43 | - * @throws \EE_Error |
|
| 44 | - */ |
|
| 45 | - protected function getTableAnalysis() |
|
| 46 | - { |
|
| 47 | - if ($this->table_analysis instanceof TableAnalysis) { |
|
| 48 | - return $this->table_analysis; |
|
| 49 | - } else { |
|
| 50 | - throw new \EE_Error( |
|
| 51 | - sprintf( |
|
| 52 | - __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
| 53 | - get_class($this) |
|
| 54 | - ) |
|
| 55 | - ); |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @param string $table_name which can optionally start with $wpdb->prefix or not |
|
| 63 | - * @param string $column_name |
|
| 64 | - * @param string $column_info |
|
| 65 | - * @return bool|false|int |
|
| 66 | - */ |
|
| 67 | - public function addColumn($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') |
|
| 68 | - { |
|
| 69 | - if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', false)) { |
|
| 70 | - return false; |
|
| 71 | - } |
|
| 72 | - global $wpdb; |
|
| 73 | - $full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
| 74 | - $columns = $this->getTableColumns($table_name); |
|
| 75 | - if ( ! in_array($column_name, $columns)) { |
|
| 76 | - $alter_query = "ALTER TABLE {$full_table_name} ADD {$column_name} {$column_info}"; |
|
| 77 | - return $wpdb->query($alter_query); |
|
| 78 | - } |
|
| 79 | - return true; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * Gets the name of all columns on the table. $table_name can |
|
| 86 | - * optionally start with $wpdb->prefix or not |
|
| 87 | - * |
|
| 88 | - * @global \wpdb $wpdb |
|
| 89 | - * @param string $table_name |
|
| 90 | - * @return array |
|
| 91 | - */ |
|
| 92 | - public function getTableColumns($table_name) |
|
| 93 | - { |
|
| 94 | - global $wpdb; |
|
| 95 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
| 96 | - $field_array = array(); |
|
| 97 | - if ( ! empty($table_name)) { |
|
| 98 | - $columns = $wpdb->get_results("SHOW COLUMNS FROM {$table_name} "); |
|
| 99 | - if ($columns !== false) { |
|
| 100 | - foreach ($columns as $column) { |
|
| 101 | - $field_array[] = $column->Field; |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - return $field_array; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Drops the specified table from the database. $table_name can |
|
| 112 | - * optionally start with $wpdb->prefix or not |
|
| 113 | - * |
|
| 114 | - * @global \wpdb $wpdb |
|
| 115 | - * @param string $table_name |
|
| 116 | - * @return int |
|
| 117 | - */ |
|
| 118 | - public function dropTable($table_name) |
|
| 119 | - { |
|
| 120 | - global $wpdb; |
|
| 121 | - if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
| 122 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
| 123 | - return $wpdb->query("DROP TABLE IF EXISTS {$table_name}"); |
|
| 124 | - } |
|
| 125 | - return 0; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * Drops all the tables mentioned in a single MYSQL query. Double-checks |
|
| 132 | - * each table name provided has a wpdb prefix attached, and that it exists. |
|
| 133 | - * Returns the list actually deleted |
|
| 134 | - * |
|
| 135 | - * @global WPDB $wpdb |
|
| 136 | - * @param array $table_names |
|
| 137 | - * @return array of table names which we deleted |
|
| 138 | - */ |
|
| 139 | - public function dropTables($table_names) |
|
| 140 | - { |
|
| 141 | - $tables_to_delete = array(); |
|
| 142 | - foreach ($table_names as $table_name) { |
|
| 143 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
| 144 | - if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
| 145 | - $tables_to_delete[$table_name] = $table_name; |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - if( ! empty( $tables_to_delete ) ) { |
|
| 149 | - global $wpdb; |
|
| 150 | - //make sure we only have a unique strings in the array. |
|
| 151 | - $tables_to_delete = array_unique($tables_to_delete); |
|
| 152 | - $wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete)); |
|
| 153 | - } |
|
| 154 | - return $tables_to_delete; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * Drops the specified index from the specified table. $table_name can |
|
| 161 | - * optionally start with $wpdb->prefix or not |
|
| 162 | - |
|
| 163 | - * |
|
| 20 | + /** |
|
| 21 | + * @var TableAnalysis $table_analysis |
|
| 22 | + */ |
|
| 23 | + private $table_analysis; |
|
| 24 | + |
|
| 25 | + |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * TableManager constructor. |
|
| 29 | + * |
|
| 30 | + * @param TableAnalysis $TableAnalysis |
|
| 31 | + */ |
|
| 32 | + public function __construct(TableAnalysis $TableAnalysis) |
|
| 33 | + { |
|
| 34 | + $this->table_analysis = $TableAnalysis; |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Gets the injected table analyzer, or throws an exception |
|
| 41 | + * |
|
| 42 | + * @return TableAnalysis |
|
| 43 | + * @throws \EE_Error |
|
| 44 | + */ |
|
| 45 | + protected function getTableAnalysis() |
|
| 46 | + { |
|
| 47 | + if ($this->table_analysis instanceof TableAnalysis) { |
|
| 48 | + return $this->table_analysis; |
|
| 49 | + } else { |
|
| 50 | + throw new \EE_Error( |
|
| 51 | + sprintf( |
|
| 52 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
| 53 | + get_class($this) |
|
| 54 | + ) |
|
| 55 | + ); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @param string $table_name which can optionally start with $wpdb->prefix or not |
|
| 63 | + * @param string $column_name |
|
| 64 | + * @param string $column_info |
|
| 65 | + * @return bool|false|int |
|
| 66 | + */ |
|
| 67 | + public function addColumn($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') |
|
| 68 | + { |
|
| 69 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', false)) { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 72 | + global $wpdb; |
|
| 73 | + $full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
| 74 | + $columns = $this->getTableColumns($table_name); |
|
| 75 | + if ( ! in_array($column_name, $columns)) { |
|
| 76 | + $alter_query = "ALTER TABLE {$full_table_name} ADD {$column_name} {$column_info}"; |
|
| 77 | + return $wpdb->query($alter_query); |
|
| 78 | + } |
|
| 79 | + return true; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * Gets the name of all columns on the table. $table_name can |
|
| 86 | + * optionally start with $wpdb->prefix or not |
|
| 87 | + * |
|
| 88 | + * @global \wpdb $wpdb |
|
| 89 | + * @param string $table_name |
|
| 90 | + * @return array |
|
| 91 | + */ |
|
| 92 | + public function getTableColumns($table_name) |
|
| 93 | + { |
|
| 94 | + global $wpdb; |
|
| 95 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
| 96 | + $field_array = array(); |
|
| 97 | + if ( ! empty($table_name)) { |
|
| 98 | + $columns = $wpdb->get_results("SHOW COLUMNS FROM {$table_name} "); |
|
| 99 | + if ($columns !== false) { |
|
| 100 | + foreach ($columns as $column) { |
|
| 101 | + $field_array[] = $column->Field; |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + return $field_array; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Drops the specified table from the database. $table_name can |
|
| 112 | + * optionally start with $wpdb->prefix or not |
|
| 113 | + * |
|
| 114 | + * @global \wpdb $wpdb |
|
| 115 | + * @param string $table_name |
|
| 116 | + * @return int |
|
| 117 | + */ |
|
| 118 | + public function dropTable($table_name) |
|
| 119 | + { |
|
| 120 | + global $wpdb; |
|
| 121 | + if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
| 122 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
| 123 | + return $wpdb->query("DROP TABLE IF EXISTS {$table_name}"); |
|
| 124 | + } |
|
| 125 | + return 0; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * Drops all the tables mentioned in a single MYSQL query. Double-checks |
|
| 132 | + * each table name provided has a wpdb prefix attached, and that it exists. |
|
| 133 | + * Returns the list actually deleted |
|
| 134 | + * |
|
| 135 | + * @global WPDB $wpdb |
|
| 136 | + * @param array $table_names |
|
| 137 | + * @return array of table names which we deleted |
|
| 138 | + */ |
|
| 139 | + public function dropTables($table_names) |
|
| 140 | + { |
|
| 141 | + $tables_to_delete = array(); |
|
| 142 | + foreach ($table_names as $table_name) { |
|
| 143 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
| 144 | + if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
| 145 | + $tables_to_delete[$table_name] = $table_name; |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + if( ! empty( $tables_to_delete ) ) { |
|
| 149 | + global $wpdb; |
|
| 150 | + //make sure we only have a unique strings in the array. |
|
| 151 | + $tables_to_delete = array_unique($tables_to_delete); |
|
| 152 | + $wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete)); |
|
| 153 | + } |
|
| 154 | + return $tables_to_delete; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * Drops the specified index from the specified table. $table_name can |
|
| 161 | + * optionally start with $wpdb->prefix or not |
|
| 162 | + * |
|
| 164 | 163 | *@global \wpdb $wpdb |
| 165 | - * @param string $table_name |
|
| 166 | - * @param string $index_name |
|
| 167 | - * @return int the number of indexes dropped. False if there was a datbase error |
|
| 168 | - */ |
|
| 169 | - public function dropIndex($table_name, $index_name) |
|
| 170 | - { |
|
| 171 | - if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', false)) { |
|
| 172 | - return 0; |
|
| 173 | - } |
|
| 174 | - global $wpdb; |
|
| 175 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
| 176 | - $index_exists_query = "SHOW INDEX FROM {$table_name} WHERE key_name = '{$index_name}'"; |
|
| 177 | - if ( |
|
| 178 | - $this->getTableAnalysis()->tableExists($table_name) |
|
| 179 | - && $wpdb->get_var($index_exists_query) |
|
| 180 | - === $table_name //using get_var with the $index_exists_query returns the table's name |
|
| 181 | - ) { |
|
| 182 | - return $wpdb->query("ALTER TABLE {$table_name} DROP INDEX {$index_name}"); |
|
| 183 | - } |
|
| 184 | - return 0; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * Just creates the requested table. $table_name can |
|
| 191 | - * optionally start with $wpdb->prefix or not |
|
| 192 | - |
|
| 193 | - * |
|
| 164 | + * @param string $table_name |
|
| 165 | + * @param string $index_name |
|
| 166 | + * @return int the number of indexes dropped. False if there was a datbase error |
|
| 167 | + */ |
|
| 168 | + public function dropIndex($table_name, $index_name) |
|
| 169 | + { |
|
| 170 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', false)) { |
|
| 171 | + return 0; |
|
| 172 | + } |
|
| 173 | + global $wpdb; |
|
| 174 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
| 175 | + $index_exists_query = "SHOW INDEX FROM {$table_name} WHERE key_name = '{$index_name}'"; |
|
| 176 | + if ( |
|
| 177 | + $this->getTableAnalysis()->tableExists($table_name) |
|
| 178 | + && $wpdb->get_var($index_exists_query) |
|
| 179 | + === $table_name //using get_var with the $index_exists_query returns the table's name |
|
| 180 | + ) { |
|
| 181 | + return $wpdb->query("ALTER TABLE {$table_name} DROP INDEX {$index_name}"); |
|
| 182 | + } |
|
| 183 | + return 0; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Just creates the requested table. $table_name can |
|
| 190 | + * optionally start with $wpdb->prefix or not |
|
| 191 | + * |
|
| 194 | 192 | *@param string $table_name |
| 195 | - * @param string $create_sql defining the table's columns and indexes |
|
| 196 | - * @param string $engine (no need to specify "ENGINE=", that's implied) |
|
| 197 | - * @return void |
|
| 198 | - * @throws \EE_Error |
|
| 199 | - */ |
|
| 200 | - public function createTable($table_name, $create_sql, $engine = 'MyISAM') |
|
| 201 | - { |
|
| 202 | - // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
|
| 203 | - if (preg_match('((((.*?))(,\s))+)', $create_sql, $valid_column_data)) { |
|
| 204 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
| 205 | - /** @var \wpdb $wpdb */ |
|
| 206 | - global $wpdb; |
|
| 207 | - $SQL = "CREATE TABLE {$table_name} ( {$create_sql} ) ENGINE={$engine} " . $wpdb->get_charset_collate(); |
|
| 208 | - |
|
| 209 | - //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
|
| 210 | - //happened. And then we can choose to tell the end user |
|
| 211 | - $old_show_errors_policy = $wpdb->show_errors(true); |
|
| 212 | - $old_error_suppression_policy = $wpdb->suppress_errors(false); |
|
| 213 | - ob_start(); |
|
| 214 | - dbDelta($SQL); |
|
| 215 | - $output = ob_get_contents(); |
|
| 216 | - ob_end_clean(); |
|
| 217 | - $wpdb->show_errors($old_show_errors_policy); |
|
| 218 | - $wpdb->suppress_errors($old_error_suppression_policy); |
|
| 219 | - if ( ! empty($output)) { |
|
| 220 | - throw new \EE_Error($output); |
|
| 221 | - } |
|
| 222 | - } else { |
|
| 223 | - throw new \EE_Error( |
|
| 224 | - sprintf( |
|
| 225 | - __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', |
|
| 226 | - 'event_espresso'), |
|
| 227 | - '<br />', |
|
| 228 | - $create_sql |
|
| 229 | - ) |
|
| 230 | - ); |
|
| 231 | - } |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - |
|
| 236 | - /** |
|
| 237 | - * Drops the specified index if it's size differs from $desired_index_size. |
|
| 238 | - * WordPress' dbdelta method doesn't automatically change index sizes, so this |
|
| 239 | - * method can be used to only drop the index if needed, and afterwards dbdelta can be used as normal. |
|
| 240 | - * If the table doesn't exist, or it exists but the index does not, or returns false |
|
| 241 | - * |
|
| 242 | - * @param string $table_name |
|
| 243 | - * @param string $index_name |
|
| 244 | - * @param string $column_name if none is provided, we assume the column name matches the index (often true in EE) |
|
| 245 | - * @param string|int $desired_index_size defaults to TableAnalysis::index_col_size, the max for utf8mb4. |
|
| 246 | - * @return bool whether an index was dropped or not |
|
| 247 | - * @throws /EE_Error if table analysis object isn't defined |
|
| 248 | - */ |
|
| 249 | - public function dropIndexIfSizeNot($table_name, $index_name, $column_name = null, $desired_index_size = TableAnalysis::INDEX_COLUMN_SIZE) |
|
| 250 | - { |
|
| 251 | - if($column_name === null){ |
|
| 252 | - $column_name = $index_name; |
|
| 253 | - } |
|
| 254 | - if(!$this->getTableAnalysis()->tableExists($table_name)){ |
|
| 255 | - return false; |
|
| 256 | - } |
|
| 257 | - $index_entries = $this->getTableAnalysis()->showIndexes($table_name,$index_name); |
|
| 258 | - if(empty($index_entries)){ |
|
| 259 | - return false; |
|
| 260 | - } |
|
| 261 | - foreach($index_entries as $index_entry){ |
|
| 262 | - if( $column_name === $index_entry->Column_name |
|
| 263 | - && (string)$desired_index_size !== $index_entry->Sub_part){ |
|
| 264 | - return $this->dropIndex($table_name,$index_name); |
|
| 265 | - } |
|
| 266 | - } |
|
| 267 | - return false; |
|
| 268 | - } |
|
| 193 | + * @param string $create_sql defining the table's columns and indexes |
|
| 194 | + * @param string $engine (no need to specify "ENGINE=", that's implied) |
|
| 195 | + * @return void |
|
| 196 | + * @throws \EE_Error |
|
| 197 | + */ |
|
| 198 | + public function createTable($table_name, $create_sql, $engine = 'MyISAM') |
|
| 199 | + { |
|
| 200 | + // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
|
| 201 | + if (preg_match('((((.*?))(,\s))+)', $create_sql, $valid_column_data)) { |
|
| 202 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
| 203 | + /** @var \wpdb $wpdb */ |
|
| 204 | + global $wpdb; |
|
| 205 | + $SQL = "CREATE TABLE {$table_name} ( {$create_sql} ) ENGINE={$engine} " . $wpdb->get_charset_collate(); |
|
| 206 | + |
|
| 207 | + //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
|
| 208 | + //happened. And then we can choose to tell the end user |
|
| 209 | + $old_show_errors_policy = $wpdb->show_errors(true); |
|
| 210 | + $old_error_suppression_policy = $wpdb->suppress_errors(false); |
|
| 211 | + ob_start(); |
|
| 212 | + dbDelta($SQL); |
|
| 213 | + $output = ob_get_contents(); |
|
| 214 | + ob_end_clean(); |
|
| 215 | + $wpdb->show_errors($old_show_errors_policy); |
|
| 216 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
| 217 | + if ( ! empty($output)) { |
|
| 218 | + throw new \EE_Error($output); |
|
| 219 | + } |
|
| 220 | + } else { |
|
| 221 | + throw new \EE_Error( |
|
| 222 | + sprintf( |
|
| 223 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', |
|
| 224 | + 'event_espresso'), |
|
| 225 | + '<br />', |
|
| 226 | + $create_sql |
|
| 227 | + ) |
|
| 228 | + ); |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * Drops the specified index if it's size differs from $desired_index_size. |
|
| 236 | + * WordPress' dbdelta method doesn't automatically change index sizes, so this |
|
| 237 | + * method can be used to only drop the index if needed, and afterwards dbdelta can be used as normal. |
|
| 238 | + * If the table doesn't exist, or it exists but the index does not, or returns false |
|
| 239 | + * |
|
| 240 | + * @param string $table_name |
|
| 241 | + * @param string $index_name |
|
| 242 | + * @param string $column_name if none is provided, we assume the column name matches the index (often true in EE) |
|
| 243 | + * @param string|int $desired_index_size defaults to TableAnalysis::index_col_size, the max for utf8mb4. |
|
| 244 | + * @return bool whether an index was dropped or not |
|
| 245 | + * @throws /EE_Error if table analysis object isn't defined |
|
| 246 | + */ |
|
| 247 | + public function dropIndexIfSizeNot($table_name, $index_name, $column_name = null, $desired_index_size = TableAnalysis::INDEX_COLUMN_SIZE) |
|
| 248 | + { |
|
| 249 | + if($column_name === null){ |
|
| 250 | + $column_name = $index_name; |
|
| 251 | + } |
|
| 252 | + if(!$this->getTableAnalysis()->tableExists($table_name)){ |
|
| 253 | + return false; |
|
| 254 | + } |
|
| 255 | + $index_entries = $this->getTableAnalysis()->showIndexes($table_name,$index_name); |
|
| 256 | + if(empty($index_entries)){ |
|
| 257 | + return false; |
|
| 258 | + } |
|
| 259 | + foreach($index_entries as $index_entry){ |
|
| 260 | + if( $column_name === $index_entry->Column_name |
|
| 261 | + && (string)$desired_index_size !== $index_entry->Sub_part){ |
|
| 262 | + return $this->dropIndex($table_name,$index_name); |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + return false; |
|
| 266 | + } |
|
| 269 | 267 | |
| 270 | 268 | } |
@@ -145,11 +145,11 @@ discard block |
||
| 145 | 145 | $tables_to_delete[$table_name] = $table_name; |
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | - if( ! empty( $tables_to_delete ) ) { |
|
| 148 | + if ( ! empty($tables_to_delete)) { |
|
| 149 | 149 | global $wpdb; |
| 150 | 150 | //make sure we only have a unique strings in the array. |
| 151 | 151 | $tables_to_delete = array_unique($tables_to_delete); |
| 152 | - $wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete)); |
|
| 152 | + $wpdb->query('DROP TABLE '.implode(', ', $tables_to_delete)); |
|
| 153 | 153 | } |
| 154 | 154 | return $tables_to_delete; |
| 155 | 155 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
| 205 | 205 | /** @var \wpdb $wpdb */ |
| 206 | 206 | global $wpdb; |
| 207 | - $SQL = "CREATE TABLE {$table_name} ( {$create_sql} ) ENGINE={$engine} " . $wpdb->get_charset_collate(); |
|
| 207 | + $SQL = "CREATE TABLE {$table_name} ( {$create_sql} ) ENGINE={$engine} ".$wpdb->get_charset_collate(); |
|
| 208 | 208 | |
| 209 | 209 | //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
| 210 | 210 | //happened. And then we can choose to tell the end user |
@@ -248,20 +248,20 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | public function dropIndexIfSizeNot($table_name, $index_name, $column_name = null, $desired_index_size = TableAnalysis::INDEX_COLUMN_SIZE) |
| 250 | 250 | { |
| 251 | - if($column_name === null){ |
|
| 251 | + if ($column_name === null) { |
|
| 252 | 252 | $column_name = $index_name; |
| 253 | 253 | } |
| 254 | - if(!$this->getTableAnalysis()->tableExists($table_name)){ |
|
| 254 | + if ( ! $this->getTableAnalysis()->tableExists($table_name)) { |
|
| 255 | 255 | return false; |
| 256 | 256 | } |
| 257 | - $index_entries = $this->getTableAnalysis()->showIndexes($table_name,$index_name); |
|
| 258 | - if(empty($index_entries)){ |
|
| 257 | + $index_entries = $this->getTableAnalysis()->showIndexes($table_name, $index_name); |
|
| 258 | + if (empty($index_entries)) { |
|
| 259 | 259 | return false; |
| 260 | 260 | } |
| 261 | - foreach($index_entries as $index_entry){ |
|
| 262 | - if( $column_name === $index_entry->Column_name |
|
| 263 | - && (string)$desired_index_size !== $index_entry->Sub_part){ |
|
| 264 | - return $this->dropIndex($table_name,$index_name); |
|
| 261 | + foreach ($index_entries as $index_entry) { |
|
| 262 | + if ($column_name === $index_entry->Column_name |
|
| 263 | + && (string) $desired_index_size !== $index_entry->Sub_part) { |
|
| 264 | + return $this->dropIndex($table_name, $index_name); |
|
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | return false; |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | // when adding a new registration... |
| 70 | 70 | if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') { |
| 71 | 71 | EE_System::do_not_cache(); |
| 72 | - if (! isset($this->_req_data['processing_registration']) |
|
| 72 | + if ( ! isset($this->_req_data['processing_registration']) |
|
| 73 | 73 | || absint($this->_req_data['processing_registration']) !== 1 |
| 74 | 74 | ) { |
| 75 | 75 | // and it's NOT the attendee information reg step |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | //style |
| 578 | 578 | wp_register_style( |
| 579 | 579 | 'espresso_reg', |
| 580 | - REG_ASSETS_URL . 'espresso_registrations_admin.css', |
|
| 580 | + REG_ASSETS_URL.'espresso_registrations_admin.css', |
|
| 581 | 581 | array('ee-admin-css'), |
| 582 | 582 | EVENT_ESPRESSO_VERSION |
| 583 | 583 | ); |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | //script |
| 586 | 586 | wp_register_script( |
| 587 | 587 | 'espresso_reg', |
| 588 | - REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
| 588 | + REG_ASSETS_URL.'espresso_registrations_admin.js', |
|
| 589 | 589 | array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), |
| 590 | 590 | EVENT_ESPRESSO_VERSION, |
| 591 | 591 | true |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | wp_deregister_style('espresso_reg'); |
| 624 | 624 | wp_register_style( |
| 625 | 625 | 'espresso_att', |
| 626 | - REG_ASSETS_URL . 'espresso_attendees_admin.css', |
|
| 626 | + REG_ASSETS_URL.'espresso_attendees_admin.css', |
|
| 627 | 627 | array('ee-admin-css'), |
| 628 | 628 | EVENT_ESPRESSO_VERSION |
| 629 | 629 | ); |
@@ -635,7 +635,7 @@ discard block |
||
| 635 | 635 | { |
| 636 | 636 | wp_register_script( |
| 637 | 637 | 'ee-spco-for-admin', |
| 638 | - REG_ASSETS_URL . 'spco_for_admin.js', |
|
| 638 | + REG_ASSETS_URL.'spco_for_admin.js', |
|
| 639 | 639 | array('underscore', 'jquery'), |
| 640 | 640 | EVENT_ESPRESSO_VERSION, |
| 641 | 641 | true |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
| 769 | 769 | ), |
| 770 | 770 | ); |
| 771 | - $this->_views['trash'] = array( |
|
| 771 | + $this->_views['trash'] = array( |
|
| 772 | 772 | 'slug' => 'trash', |
| 773 | 773 | 'label' => esc_html__('Trash', 'event_espresso'), |
| 774 | 774 | 'count' => 0, |
@@ -857,7 +857,7 @@ discard block |
||
| 857 | 857 | } |
| 858 | 858 | $sc_items = array( |
| 859 | 859 | 'approved_status' => array( |
| 860 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 860 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
| 861 | 861 | 'desc' => EEH_Template::pretty_status( |
| 862 | 862 | EEM_Registration::status_id_approved, |
| 863 | 863 | false, |
@@ -865,7 +865,7 @@ discard block |
||
| 865 | 865 | ), |
| 866 | 866 | ), |
| 867 | 867 | 'pending_status' => array( |
| 868 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 868 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
| 869 | 869 | 'desc' => EEH_Template::pretty_status( |
| 870 | 870 | EEM_Registration::status_id_pending_payment, |
| 871 | 871 | false, |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | ), |
| 874 | 874 | ), |
| 875 | 875 | 'wait_list' => array( |
| 876 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 876 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list, |
|
| 877 | 877 | 'desc' => EEH_Template::pretty_status( |
| 878 | 878 | EEM_Registration::status_id_wait_list, |
| 879 | 879 | false, |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | ), |
| 882 | 882 | ), |
| 883 | 883 | 'incomplete_status' => array( |
| 884 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
| 884 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete, |
|
| 885 | 885 | 'desc' => EEH_Template::pretty_status( |
| 886 | 886 | EEM_Registration::status_id_incomplete, |
| 887 | 887 | false, |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | ), |
| 890 | 890 | ), |
| 891 | 891 | 'not_approved' => array( |
| 892 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 892 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
| 893 | 893 | 'desc' => EEH_Template::pretty_status( |
| 894 | 894 | EEM_Registration::status_id_not_approved, |
| 895 | 895 | false, |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | ), |
| 898 | 898 | ), |
| 899 | 899 | 'declined_status' => array( |
| 900 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 900 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
| 901 | 901 | 'desc' => EEH_Template::pretty_status( |
| 902 | 902 | EEM_Registration::status_id_declined, |
| 903 | 903 | false, |
@@ -905,7 +905,7 @@ discard block |
||
| 905 | 905 | ), |
| 906 | 906 | ), |
| 907 | 907 | 'cancelled_status' => array( |
| 908 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 908 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
| 909 | 909 | 'desc' => EEH_Template::pretty_status( |
| 910 | 910 | EEM_Registration::status_id_cancelled, |
| 911 | 911 | false, |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | 'espresso_registrations_new_registration', |
| 935 | 935 | $EVT_ID |
| 936 | 936 | )) { |
| 937 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 937 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
| 938 | 938 | 'new_registration', |
| 939 | 939 | 'add-registrant', |
| 940 | 940 | array('event_id' => $EVT_ID), |
@@ -974,7 +974,7 @@ discard block |
||
| 974 | 974 | $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
| 975 | 975 | $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
| 976 | 976 | $this->_template_args['admin_page_header'] .= $datetime->name(); |
| 977 | - $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
| 977 | + $this->_template_args['admin_page_header'] .= ' ( '.$datetime->start_date().' )'; |
|
| 978 | 978 | $this->_template_args['admin_page_header'] .= '</span></h3>'; |
| 979 | 979 | } |
| 980 | 980 | } |
@@ -1074,7 +1074,7 @@ discard block |
||
| 1074 | 1074 | 'caps' => EEM_Registration::caps_read_admin, |
| 1075 | 1075 | 'default_where_conditions' => 'this_model_only', |
| 1076 | 1076 | ); |
| 1077 | - if (! $count) { |
|
| 1077 | + if ( ! $count) { |
|
| 1078 | 1078 | $query_params = array_merge( |
| 1079 | 1079 | $query_params, |
| 1080 | 1080 | $this->_get_orderby_for_registrations_query(), |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | protected function _add_event_id_to_where_conditions(array $request) |
| 1096 | 1096 | { |
| 1097 | 1097 | $where = array(); |
| 1098 | - if (! empty($request['event_id'])) { |
|
| 1098 | + if ( ! empty($request['event_id'])) { |
|
| 1099 | 1099 | $where['EVT_ID'] = absint($request['event_id']); |
| 1100 | 1100 | } |
| 1101 | 1101 | return $where; |
@@ -1111,7 +1111,7 @@ discard block |
||
| 1111 | 1111 | protected function _add_category_id_to_where_conditions(array $request) |
| 1112 | 1112 | { |
| 1113 | 1113 | $where = array(); |
| 1114 | - if (! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) { |
|
| 1114 | + if ( ! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) { |
|
| 1115 | 1115 | $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']); |
| 1116 | 1116 | } |
| 1117 | 1117 | return $where; |
@@ -1127,10 +1127,10 @@ discard block |
||
| 1127 | 1127 | protected function _add_datetime_id_to_where_conditions(array $request) |
| 1128 | 1128 | { |
| 1129 | 1129 | $where = array(); |
| 1130 | - if (! empty($request['datetime_id'])) { |
|
| 1130 | + if ( ! empty($request['datetime_id'])) { |
|
| 1131 | 1131 | $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']); |
| 1132 | 1132 | } |
| 1133 | - if (! empty($request['DTT_ID'])) { |
|
| 1133 | + if ( ! empty($request['DTT_ID'])) { |
|
| 1134 | 1134 | $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']); |
| 1135 | 1135 | } |
| 1136 | 1136 | return $where; |
@@ -1156,7 +1156,7 @@ discard block |
||
| 1156 | 1156 | * If not filtering by specified status, then we show all registrations excluding incomplete registrations |
| 1157 | 1157 | * UNLESS viewing trashed registrations. |
| 1158 | 1158 | */ |
| 1159 | - if (! empty($registration_status)) { |
|
| 1159 | + if ( ! empty($registration_status)) { |
|
| 1160 | 1160 | $where['STS_ID'] = $registration_status; |
| 1161 | 1161 | } else { |
| 1162 | 1162 | //make sure we exclude incomplete registrations, but only if not trashed. |
@@ -1196,12 +1196,12 @@ discard block |
||
| 1196 | 1196 | array( |
| 1197 | 1197 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1198 | 1198 | 'REG_date', |
| 1199 | - $now . ' 00:00:00', |
|
| 1199 | + $now.' 00:00:00', |
|
| 1200 | 1200 | 'Y-m-d H:i:s' |
| 1201 | 1201 | ), |
| 1202 | 1202 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1203 | 1203 | 'REG_date', |
| 1204 | - $now . ' 23:59:59', |
|
| 1204 | + $now.' 23:59:59', |
|
| 1205 | 1205 | 'Y-m-d H:i:s' |
| 1206 | 1206 | ), |
| 1207 | 1207 | ), |
@@ -1214,12 +1214,12 @@ discard block |
||
| 1214 | 1214 | array( |
| 1215 | 1215 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1216 | 1216 | 'REG_date', |
| 1217 | - $current_year_and_month . '-01 00:00:00', |
|
| 1217 | + $current_year_and_month.'-01 00:00:00', |
|
| 1218 | 1218 | 'Y-m-d H:i:s' |
| 1219 | 1219 | ), |
| 1220 | 1220 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1221 | 1221 | 'REG_date', |
| 1222 | - $current_year_and_month . '-' . $days_this_month . ' 23:59:59', |
|
| 1222 | + $current_year_and_month.'-'.$days_this_month.' 23:59:59', |
|
| 1223 | 1223 | 'Y-m-d H:i:s' |
| 1224 | 1224 | ), |
| 1225 | 1225 | ), |
@@ -1234,18 +1234,18 @@ discard block |
||
| 1234 | 1234 | : ''; |
| 1235 | 1235 | //if there is not a month or year then we can't go further |
| 1236 | 1236 | if ($month_requested && $year_requested) { |
| 1237 | - $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01')); |
|
| 1237 | + $days_in_month = date('t', strtotime($year_requested.'-'.$month_requested.'-'.'01')); |
|
| 1238 | 1238 | $where['REG_date'] = array( |
| 1239 | 1239 | 'BETWEEN', |
| 1240 | 1240 | array( |
| 1241 | 1241 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1242 | 1242 | 'REG_date', |
| 1243 | - $year_requested . '-' . $month_requested . '-01 00:00:00', |
|
| 1243 | + $year_requested.'-'.$month_requested.'-01 00:00:00', |
|
| 1244 | 1244 | 'Y-m-d H:i:s' |
| 1245 | 1245 | ), |
| 1246 | 1246 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1247 | 1247 | 'REG_date', |
| 1248 | - $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59', |
|
| 1248 | + $year_requested.'-'.$month_requested.'-'.$days_in_month.' 23:59:59', |
|
| 1249 | 1249 | 'Y-m-d H:i:s' |
| 1250 | 1250 | ), |
| 1251 | 1251 | ), |
@@ -1265,8 +1265,8 @@ discard block |
||
| 1265 | 1265 | protected function _add_search_to_where_conditions(array $request) |
| 1266 | 1266 | { |
| 1267 | 1267 | $where = array(); |
| 1268 | - if (! empty($request['s'])) { |
|
| 1269 | - $search_string = '%' . sanitize_text_field($request['s']) . '%'; |
|
| 1268 | + if ( ! empty($request['s'])) { |
|
| 1269 | + $search_string = '%'.sanitize_text_field($request['s']).'%'; |
|
| 1270 | 1270 | $where['OR*search_conditions'] = array( |
| 1271 | 1271 | 'Event.EVT_name' => array('LIKE', $search_string), |
| 1272 | 1272 | 'Event.EVT_desc' => array('LIKE', $search_string), |
@@ -1379,7 +1379,7 @@ discard block |
||
| 1379 | 1379 | : $per_page; |
| 1380 | 1380 | |
| 1381 | 1381 | //-1 means return all results so get out if that's set. |
| 1382 | - if ((int)$per_page === -1) { |
|
| 1382 | + if ((int) $per_page === -1) { |
|
| 1383 | 1383 | return array(); |
| 1384 | 1384 | } |
| 1385 | 1385 | $per_page = absint($per_page); |
@@ -1432,7 +1432,7 @@ discard block |
||
| 1432 | 1432 | ), |
| 1433 | 1433 | REG_ADMIN_URL |
| 1434 | 1434 | ); |
| 1435 | - $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1435 | + $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1436 | 1436 | array( |
| 1437 | 1437 | 'action' => 'default', |
| 1438 | 1438 | 'EVT_ID' => $event_id, |
@@ -1440,7 +1440,7 @@ discard block |
||
| 1440 | 1440 | ), |
| 1441 | 1441 | admin_url('admin.php') |
| 1442 | 1442 | ); |
| 1443 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1443 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1444 | 1444 | array( |
| 1445 | 1445 | 'page' => 'espresso_events', |
| 1446 | 1446 | 'action' => 'edit', |
@@ -1449,12 +1449,12 @@ discard block |
||
| 1449 | 1449 | admin_url('admin.php') |
| 1450 | 1450 | ); |
| 1451 | 1451 | //next and previous links |
| 1452 | - $next_reg = $this->_registration->next( |
|
| 1452 | + $next_reg = $this->_registration->next( |
|
| 1453 | 1453 | null, |
| 1454 | 1454 | array(), |
| 1455 | 1455 | 'REG_ID' |
| 1456 | 1456 | ); |
| 1457 | - $this->_template_args['next_registration'] = $next_reg |
|
| 1457 | + $this->_template_args['next_registration'] = $next_reg |
|
| 1458 | 1458 | ? $this->_next_link( |
| 1459 | 1459 | EE_Admin_Page::add_query_args_and_nonce( |
| 1460 | 1460 | array( |
@@ -1466,7 +1466,7 @@ discard block |
||
| 1466 | 1466 | 'dashicons dashicons-arrow-right ee-icon-size-22' |
| 1467 | 1467 | ) |
| 1468 | 1468 | : ''; |
| 1469 | - $previous_reg = $this->_registration->previous( |
|
| 1469 | + $previous_reg = $this->_registration->previous( |
|
| 1470 | 1470 | null, |
| 1471 | 1471 | array(), |
| 1472 | 1472 | 'REG_ID' |
@@ -1484,7 +1484,7 @@ discard block |
||
| 1484 | 1484 | ) |
| 1485 | 1485 | : ''; |
| 1486 | 1486 | // grab header |
| 1487 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
| 1487 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php'; |
|
| 1488 | 1488 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
| 1489 | 1489 | $this->_template_args['admin_page_header'] = EEH_Template::display_template( |
| 1490 | 1490 | $template_path, |
@@ -1599,7 +1599,7 @@ discard block |
||
| 1599 | 1599 | EEH_HTML::strong( |
| 1600 | 1600 | $this->_registration->pretty_status(), |
| 1601 | 1601 | '', |
| 1602 | - 'status-' . $this->_registration->status_ID(), |
|
| 1602 | + 'status-'.$this->_registration->status_ID(), |
|
| 1603 | 1603 | 'line-height: 1em; font-size: 1.5em; font-weight: bold;' |
| 1604 | 1604 | ) |
| 1605 | 1605 | ) |
@@ -1669,9 +1669,9 @@ discard block |
||
| 1669 | 1669 | { |
| 1670 | 1670 | if (isset($this->_req_data['reg_status_change_form'])) { |
| 1671 | 1671 | $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
| 1672 | - ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
| 1672 | + ? (array) $this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
| 1673 | 1673 | } else { |
| 1674 | - $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array(); |
|
| 1674 | + $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array) $this->_req_data['_REG_ID'] : array(); |
|
| 1675 | 1675 | } |
| 1676 | 1676 | $success = $this->_set_registration_status($REG_IDs, $status); |
| 1677 | 1677 | //notify? |
@@ -1703,7 +1703,7 @@ discard block |
||
| 1703 | 1703 | { |
| 1704 | 1704 | $success = false; |
| 1705 | 1705 | // typecast $REG_IDs |
| 1706 | - $REG_IDs = (array)$REG_IDs; |
|
| 1706 | + $REG_IDs = (array) $REG_IDs; |
|
| 1707 | 1707 | if ( ! empty($REG_IDs)) { |
| 1708 | 1708 | $success = true; |
| 1709 | 1709 | // set default status if none is passed |
@@ -1933,7 +1933,7 @@ discard block |
||
| 1933 | 1933 | $filtered_line_item_tree, |
| 1934 | 1934 | array('EE_Registration' => $this->_registration) |
| 1935 | 1935 | ); |
| 1936 | - $attendee = $this->_registration->attendee(); |
|
| 1936 | + $attendee = $this->_registration->attendee(); |
|
| 1937 | 1937 | if (EE_Registry::instance()->CAP->current_user_can( |
| 1938 | 1938 | 'ee_read_transaction', |
| 1939 | 1939 | 'espresso_transactions_view_transaction' |
@@ -2012,7 +2012,7 @@ discard block |
||
| 2012 | 2012 | 'Payment method response', |
| 2013 | 2013 | 'event_espresso' |
| 2014 | 2014 | ); |
| 2015 | - $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
|
| 2015 | + $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
|
| 2016 | 2016 | } |
| 2017 | 2017 | $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
| 2018 | 2018 | $this->_template_args['reg_details']['registration_session']['label'] = esc_html__( |
@@ -2040,7 +2040,7 @@ discard block |
||
| 2040 | 2040 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
| 2041 | 2041 | $this->_template_args['event_id'] = $this->_registration->event_ID(); |
| 2042 | 2042 | $template_path = |
| 2043 | - REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 2043 | + REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 2044 | 2044 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 2045 | 2045 | } |
| 2046 | 2046 | |
@@ -2069,7 +2069,7 @@ discard block |
||
| 2069 | 2069 | $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
| 2070 | 2070 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
| 2071 | 2071 | $template_path = |
| 2072 | - REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 2072 | + REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 2073 | 2073 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 2074 | 2074 | } |
| 2075 | 2075 | } |
@@ -2086,7 +2086,7 @@ discard block |
||
| 2086 | 2086 | public function form_before_question_group($output) |
| 2087 | 2087 | { |
| 2088 | 2088 | EE_Error::doing_it_wrong( |
| 2089 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2089 | + __CLASS__.'::'.__FUNCTION__, |
|
| 2090 | 2090 | esc_html__( |
| 2091 | 2091 | 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
| 2092 | 2092 | 'event_espresso' |
@@ -2111,7 +2111,7 @@ discard block |
||
| 2111 | 2111 | public function form_after_question_group($output) |
| 2112 | 2112 | { |
| 2113 | 2113 | EE_Error::doing_it_wrong( |
| 2114 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2114 | + __CLASS__.'::'.__FUNCTION__, |
|
| 2115 | 2115 | esc_html__( |
| 2116 | 2116 | 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
| 2117 | 2117 | 'event_espresso' |
@@ -2149,7 +2149,7 @@ discard block |
||
| 2149 | 2149 | public function form_form_field_label_wrap($label) |
| 2150 | 2150 | { |
| 2151 | 2151 | EE_Error::doing_it_wrong( |
| 2152 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2152 | + __CLASS__.'::'.__FUNCTION__, |
|
| 2153 | 2153 | esc_html__( |
| 2154 | 2154 | 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
| 2155 | 2155 | 'event_espresso' |
@@ -2159,7 +2159,7 @@ discard block |
||
| 2159 | 2159 | return ' |
| 2160 | 2160 | <tr> |
| 2161 | 2161 | <th> |
| 2162 | - ' . $label . ' |
|
| 2162 | + ' . $label.' |
|
| 2163 | 2163 | </th>'; |
| 2164 | 2164 | } |
| 2165 | 2165 | |
@@ -2175,7 +2175,7 @@ discard block |
||
| 2175 | 2175 | public function form_form_field_input__wrap($input) |
| 2176 | 2176 | { |
| 2177 | 2177 | EE_Error::doing_it_wrong( |
| 2178 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2178 | + __CLASS__.'::'.__FUNCTION__, |
|
| 2179 | 2179 | esc_html__( |
| 2180 | 2180 | 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
| 2181 | 2181 | 'event_espresso' |
@@ -2184,7 +2184,7 @@ discard block |
||
| 2184 | 2184 | ); |
| 2185 | 2185 | return ' |
| 2186 | 2186 | <td class="reg-admin-attendee-questions-input-td disabled-input"> |
| 2187 | - ' . $input . ' |
|
| 2187 | + ' . $input.' |
|
| 2188 | 2188 | </td> |
| 2189 | 2189 | </tr>'; |
| 2190 | 2190 | } |
@@ -2226,7 +2226,7 @@ discard block |
||
| 2226 | 2226 | protected function _get_reg_custom_questions_form($REG_ID) |
| 2227 | 2227 | { |
| 2228 | 2228 | if ( ! $this->_reg_custom_questions_form) { |
| 2229 | - require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 2229 | + require_once(REG_ADMIN.'form_sections'.DS.'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 2230 | 2230 | $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( |
| 2231 | 2231 | EEM_Registration::instance()->get_one_by_ID($REG_ID) |
| 2232 | 2232 | ); |
@@ -2259,7 +2259,7 @@ discard block |
||
| 2259 | 2259 | if ($form->is_valid()) { |
| 2260 | 2260 | foreach ($form->subforms() as $question_group_id => $question_group_form) { |
| 2261 | 2261 | foreach ($question_group_form->inputs() as $question_id => $input) { |
| 2262 | - $where_conditions = array( |
|
| 2262 | + $where_conditions = array( |
|
| 2263 | 2263 | 'QST_ID' => $question_id, |
| 2264 | 2264 | 'REG_ID' => $REG_ID, |
| 2265 | 2265 | ); |
@@ -2297,7 +2297,7 @@ discard block |
||
| 2297 | 2297 | $REG = EEM_Registration::instance(); |
| 2298 | 2298 | //get all other registrations on this transaction, and cache |
| 2299 | 2299 | //the attendees for them so we don't have to run another query using force_join |
| 2300 | - $registrations = $REG->get_all(array( |
|
| 2300 | + $registrations = $REG->get_all(array( |
|
| 2301 | 2301 | array( |
| 2302 | 2302 | 'TXN_ID' => $this->_registration->transaction_ID(), |
| 2303 | 2303 | 'REG_ID' => array('!=', $this->_registration->ID()), |
@@ -2321,7 +2321,7 @@ discard block |
||
| 2321 | 2321 | $att_nmbr = 1; |
| 2322 | 2322 | foreach ($registrations as $registration) { |
| 2323 | 2323 | /* @var $registration EE_Registration */ |
| 2324 | - $attendee = $registration->attendee() |
|
| 2324 | + $attendee = $registration->attendee() |
|
| 2325 | 2325 | ? $registration->attendee() |
| 2326 | 2326 | : EEM_Attendee::instance() |
| 2327 | 2327 | ->create_default_object(); |
@@ -2334,19 +2334,19 @@ discard block |
||
| 2334 | 2334 | ', ', |
| 2335 | 2335 | $attendee->full_address_as_array() |
| 2336 | 2336 | ); |
| 2337 | - $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce( |
|
| 2337 | + $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce( |
|
| 2338 | 2338 | array( |
| 2339 | 2339 | 'action' => 'edit_attendee', |
| 2340 | 2340 | 'post' => $attendee->ID(), |
| 2341 | 2341 | ), |
| 2342 | 2342 | REG_ADMIN_URL |
| 2343 | 2343 | ); |
| 2344 | - $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2344 | + $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2345 | 2345 | $att_nmbr++; |
| 2346 | 2346 | } |
| 2347 | 2347 | $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
| 2348 | 2348 | } |
| 2349 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2349 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2350 | 2350 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 2351 | 2351 | } |
| 2352 | 2352 | |
@@ -2386,20 +2386,20 @@ discard block |
||
| 2386 | 2386 | $this->_template_args['phone'] = $attendee->phone(); |
| 2387 | 2387 | $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
| 2388 | 2388 | //edit link |
| 2389 | - $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2389 | + $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2390 | 2390 | 'action' => 'edit_attendee', |
| 2391 | 2391 | 'post' => $attendee->ID(), |
| 2392 | 2392 | ), REG_ADMIN_URL); |
| 2393 | 2393 | $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso'); |
| 2394 | 2394 | //create link |
| 2395 | - $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2395 | + $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2396 | 2396 | ? EE_Admin_Page::add_query_args_and_nonce(array( |
| 2397 | 2397 | 'action' => 'duplicate_attendee', |
| 2398 | 2398 | '_REG_ID' => $this->_registration->ID(), |
| 2399 | 2399 | ), REG_ADMIN_URL) : ''; |
| 2400 | 2400 | $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso'); |
| 2401 | 2401 | $this->_template_args['att_check'] = $att_check; |
| 2402 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2402 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2403 | 2403 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 2404 | 2404 | } |
| 2405 | 2405 | |
@@ -2441,7 +2441,7 @@ discard block |
||
| 2441 | 2441 | /** @var EE_Registration $REG */ |
| 2442 | 2442 | $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
| 2443 | 2443 | $payments = $REG->registration_payments(); |
| 2444 | - if (! empty($payments)) { |
|
| 2444 | + if ( ! empty($payments)) { |
|
| 2445 | 2445 | $name = $REG->attendee() instanceof EE_Attendee |
| 2446 | 2446 | ? $REG->attendee()->full_name() |
| 2447 | 2447 | : esc_html__('Unknown Attendee', 'event_espresso'); |
@@ -2634,7 +2634,7 @@ discard block |
||
| 2634 | 2634 | 'action' => 'edit', |
| 2635 | 2635 | 'post' => $this->_reg_event->ID(), |
| 2636 | 2636 | ), EVENTS_ADMIN_URL); |
| 2637 | - $edit_event_lnk = '<a href="' |
|
| 2637 | + $edit_event_lnk = '<a href="' |
|
| 2638 | 2638 | . $edit_event_url |
| 2639 | 2639 | . '" title="' |
| 2640 | 2640 | . esc_attr__('Edit ', 'event_espresso') |
@@ -2652,7 +2652,7 @@ discard block |
||
| 2652 | 2652 | } |
| 2653 | 2653 | // grab header |
| 2654 | 2654 | $template_path = |
| 2655 | - REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
| 2655 | + REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php'; |
|
| 2656 | 2656 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
| 2657 | 2657 | $this->_template_args, true); |
| 2658 | 2658 | //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
@@ -2687,7 +2687,7 @@ discard block |
||
| 2687 | 2687 | '</b>' |
| 2688 | 2688 | ); |
| 2689 | 2689 | return ' |
| 2690 | - <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div> |
|
| 2690 | + <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div> |
|
| 2691 | 2691 | <script > |
| 2692 | 2692 | // WHOAH !!! it appears that someone is using the back button from the Transaction admin page |
| 2693 | 2693 | // after just adding a new registration... we gotta try to put a stop to that !!! |
@@ -2755,7 +2755,7 @@ discard block |
||
| 2755 | 2755 | //we come back to the process_registration_step route. |
| 2756 | 2756 | $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields); |
| 2757 | 2757 | return EEH_Template::display_template( |
| 2758 | - REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php', |
|
| 2758 | + REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php', |
|
| 2759 | 2759 | $template_args, |
| 2760 | 2760 | true |
| 2761 | 2761 | ); |
@@ -2774,7 +2774,7 @@ discard block |
||
| 2774 | 2774 | if (is_object($this->_reg_event)) { |
| 2775 | 2775 | return true; |
| 2776 | 2776 | } |
| 2777 | - $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false; |
|
| 2777 | + $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false; |
|
| 2778 | 2778 | if ( ! $EVT_ID) { |
| 2779 | 2779 | return false; |
| 2780 | 2780 | } |
@@ -2840,7 +2840,7 @@ discard block |
||
| 2840 | 2840 | } |
| 2841 | 2841 | break; |
| 2842 | 2842 | case 'questions' : |
| 2843 | - if (! isset( |
|
| 2843 | + if ( ! isset( |
|
| 2844 | 2844 | $this->_req_data['txn_reg_status_change'], |
| 2845 | 2845 | $this->_req_data['txn_reg_status_change']['send_notifications']) |
| 2846 | 2846 | ) { |
@@ -2954,7 +2954,7 @@ discard block |
||
| 2954 | 2954 | public function get_attendees($per_page, $count = false, $trash = false) |
| 2955 | 2955 | { |
| 2956 | 2956 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
| 2957 | - require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
| 2957 | + require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php'); |
|
| 2958 | 2958 | $ATT_MDL = EEM_Attendee::instance(); |
| 2959 | 2959 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
| 2960 | 2960 | switch ($this->_req_data['orderby']) { |
@@ -2991,7 +2991,7 @@ discard block |
||
| 2991 | 2991 | : $per_page; |
| 2992 | 2992 | $_where = array(); |
| 2993 | 2993 | if ( ! empty($this->_req_data['s'])) { |
| 2994 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 2994 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
| 2995 | 2995 | $_where['OR'] = array( |
| 2996 | 2996 | 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
| 2997 | 2997 | 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
@@ -3067,9 +3067,9 @@ discard block |
||
| 3067 | 3067 | * the query parameters from the request |
| 3068 | 3068 | * @return void ends the request with a redirect or download |
| 3069 | 3069 | */ |
| 3070 | - public function _registrations_report_base( $method_name_for_getting_query_params ) |
|
| 3070 | + public function _registrations_report_base($method_name_for_getting_query_params) |
|
| 3071 | 3071 | { |
| 3072 | - if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 3072 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 3073 | 3073 | wp_redirect(EE_Admin_Page::add_query_args_and_nonce( |
| 3074 | 3074 | array( |
| 3075 | 3075 | 'page' => 'espresso_batch', |
@@ -3078,7 +3078,7 @@ discard block |
||
| 3078 | 3078 | 'filters' => urlencode( |
| 3079 | 3079 | serialize( |
| 3080 | 3080 | call_user_func( |
| 3081 | - array( $this, $method_name_for_getting_query_params ), |
|
| 3081 | + array($this, $method_name_for_getting_query_params), |
|
| 3082 | 3082 | EEH_Array::is_set( |
| 3083 | 3083 | $this->_req_data, |
| 3084 | 3084 | 'filters', |
@@ -3098,8 +3098,8 @@ discard block |
||
| 3098 | 3098 | 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
| 3099 | 3099 | ); |
| 3100 | 3100 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
| 3101 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3102 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3101 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 3102 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 3103 | 3103 | $EE_Export = EE_Export::instance($this->_req_data); |
| 3104 | 3104 | $EE_Export->export(); |
| 3105 | 3105 | } |
@@ -3120,8 +3120,8 @@ discard block |
||
| 3120 | 3120 | |
| 3121 | 3121 | public function _contact_list_export() |
| 3122 | 3122 | { |
| 3123 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3124 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3123 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 3124 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 3125 | 3125 | $EE_Export = EE_Export::instance($this->_req_data); |
| 3126 | 3126 | $EE_Export->export_attendees(); |
| 3127 | 3127 | } |
@@ -3138,8 +3138,8 @@ discard block |
||
| 3138 | 3138 | 'return_url' => urlencode($this->_req_data['return_url']), |
| 3139 | 3139 | ))); |
| 3140 | 3140 | } else { |
| 3141 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3142 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3141 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 3142 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 3143 | 3143 | $EE_Export = EE_Export::instance($this->_req_data); |
| 3144 | 3144 | $EE_Export->report_attendees(); |
| 3145 | 3145 | } |
@@ -3205,7 +3205,7 @@ discard block |
||
| 3205 | 3205 | $updated_fields = array( |
| 3206 | 3206 | 'ATT_fname' => $this->_req_data['ATT_fname'], |
| 3207 | 3207 | 'ATT_lname' => $this->_req_data['ATT_lname'], |
| 3208 | - 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
| 3208 | + 'ATT_full_name' => $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'], |
|
| 3209 | 3209 | 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
| 3210 | 3210 | 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
| 3211 | 3211 | 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
@@ -3338,7 +3338,7 @@ discard block |
||
| 3338 | 3338 | { |
| 3339 | 3339 | //get attendee object ( should already have it ) |
| 3340 | 3340 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
| 3341 | - $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
| 3341 | + $template = REG_TEMPLATE_PATH.'attendee_contact_info_metabox_content.template.php'; |
|
| 3342 | 3342 | EEH_Template::display_template($template, $this->_template_args); |
| 3343 | 3343 | } |
| 3344 | 3344 | |
@@ -3400,8 +3400,8 @@ discard block |
||
| 3400 | 3400 | ) |
| 3401 | 3401 | ) |
| 3402 | 3402 | ); |
| 3403 | - $template = |
|
| 3404 | - REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
| 3403 | + $template = |
|
| 3404 | + REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php'; |
|
| 3405 | 3405 | EEH_Template::display_template($template, $this->_template_args); |
| 3406 | 3406 | } |
| 3407 | 3407 | |
@@ -3420,7 +3420,7 @@ discard block |
||
| 3420 | 3420 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
| 3421 | 3421 | $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
| 3422 | 3422 | $template = |
| 3423 | - REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
| 3423 | + REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php'; |
|
| 3424 | 3424 | EEH_Template::display_template($template, $this->_template_args); |
| 3425 | 3425 | } |
| 3426 | 3426 | |
@@ -3435,7 +3435,7 @@ discard block |
||
| 3435 | 3435 | public function after_title_form_fields($post) |
| 3436 | 3436 | { |
| 3437 | 3437 | if ($post->post_type == 'espresso_attendees') { |
| 3438 | - $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
| 3438 | + $template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php'; |
|
| 3439 | 3439 | $template_args['attendee'] = $this->_cpt_model_obj; |
| 3440 | 3440 | EEH_Template::display_template($template, $template_args); |
| 3441 | 3441 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -23,2111 +23,2111 @@ discard block |
||
| 23 | 23 | class Registrations_Admin_Page extends EE_Admin_Page_CPT |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var EE_Registration |
|
| 28 | - */ |
|
| 29 | - private $_registration; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var EE_Event |
|
| 33 | - */ |
|
| 34 | - private $_reg_event; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var EE_Session |
|
| 38 | - */ |
|
| 39 | - private $_session; |
|
| 40 | - |
|
| 41 | - private static $_reg_status; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Form for displaying the custom questions for this registration. |
|
| 45 | - * This gets used a few times throughout the request so its best to cache it |
|
| 46 | - * |
|
| 47 | - * @var EE_Registration_Custom_Questions_Form |
|
| 48 | - */ |
|
| 49 | - protected $_reg_custom_questions_form = null; |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * constructor |
|
| 54 | - * |
|
| 55 | - * @Constructor |
|
| 56 | - * @access public |
|
| 57 | - * @param bool $routing |
|
| 58 | - * @return Registrations_Admin_Page |
|
| 59 | - */ |
|
| 60 | - public function __construct($routing = true) |
|
| 61 | - { |
|
| 62 | - parent::__construct($routing); |
|
| 63 | - add_action('wp_loaded', array($this, 'wp_loaded')); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - public function wp_loaded() |
|
| 68 | - { |
|
| 69 | - // when adding a new registration... |
|
| 70 | - if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') { |
|
| 71 | - EE_System::do_not_cache(); |
|
| 72 | - if (! isset($this->_req_data['processing_registration']) |
|
| 73 | - || absint($this->_req_data['processing_registration']) !== 1 |
|
| 74 | - ) { |
|
| 75 | - // and it's NOT the attendee information reg step |
|
| 76 | - // force cookie expiration by setting time to last week |
|
| 77 | - setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/'); |
|
| 78 | - // and update the global |
|
| 79 | - $_COOKIE['ee_registration_added'] = 0; |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - protected function _init_page_props() |
|
| 86 | - { |
|
| 87 | - $this->page_slug = REG_PG_SLUG; |
|
| 88 | - $this->_admin_base_url = REG_ADMIN_URL; |
|
| 89 | - $this->_admin_base_path = REG_ADMIN; |
|
| 90 | - $this->page_label = esc_html__('Registrations', 'event_espresso'); |
|
| 91 | - $this->_cpt_routes = array( |
|
| 92 | - 'add_new_attendee' => 'espresso_attendees', |
|
| 93 | - 'edit_attendee' => 'espresso_attendees', |
|
| 94 | - 'insert_attendee' => 'espresso_attendees', |
|
| 95 | - 'update_attendee' => 'espresso_attendees', |
|
| 96 | - ); |
|
| 97 | - $this->_cpt_model_names = array( |
|
| 98 | - 'add_new_attendee' => 'EEM_Attendee', |
|
| 99 | - 'edit_attendee' => 'EEM_Attendee', |
|
| 100 | - ); |
|
| 101 | - $this->_cpt_edit_routes = array( |
|
| 102 | - 'espresso_attendees' => 'edit_attendee', |
|
| 103 | - ); |
|
| 104 | - $this->_pagenow_map = array( |
|
| 105 | - 'add_new_attendee' => 'post-new.php', |
|
| 106 | - 'edit_attendee' => 'post.php', |
|
| 107 | - 'trash' => 'post.php', |
|
| 108 | - ); |
|
| 109 | - add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10); |
|
| 110 | - //add filters so that the comment urls don't take users to a confusing 404 page |
|
| 111 | - add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - |
|
| 115 | - public function clear_comment_link($link, $comment, $args) |
|
| 116 | - { |
|
| 117 | - //gotta make sure this only happens on this route |
|
| 118 | - $post_type = get_post_type($comment->comment_post_ID); |
|
| 119 | - if ($post_type === 'espresso_attendees') { |
|
| 120 | - return '#commentsdiv'; |
|
| 121 | - } |
|
| 122 | - return $link; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - protected function _ajax_hooks() |
|
| 127 | - { |
|
| 128 | - //todo: all hooks for registrations ajax goes in here |
|
| 129 | - add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status')); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - protected function _define_page_props() |
|
| 134 | - { |
|
| 135 | - $this->_admin_page_title = $this->page_label; |
|
| 136 | - $this->_labels = array( |
|
| 137 | - 'buttons' => array( |
|
| 138 | - 'add-registrant' => esc_html__('Add New Registration', 'event_espresso'), |
|
| 139 | - 'add-attendee' => esc_html__('Add Contact', 'event_espresso'), |
|
| 140 | - 'edit' => esc_html__('Edit Contact', 'event_espresso'), |
|
| 141 | - 'report' => esc_html__("Event Registrations CSV Report", "event_espresso"), |
|
| 142 | - 'report_all' => esc_html__('All Registrations CSV Report', 'event_espresso'), |
|
| 143 | - 'report_filtered' => esc_html__('Filtered CSV Report', 'event_espresso'), |
|
| 144 | - 'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'), |
|
| 145 | - 'contact_list_export' => esc_html__("Export Data", "event_espresso"), |
|
| 146 | - ), |
|
| 147 | - 'publishbox' => array( |
|
| 148 | - 'add_new_attendee' => esc_html__("Add Contact Record", 'event_espresso'), |
|
| 149 | - 'edit_attendee' => esc_html__("Update Contact Record", 'event_espresso'), |
|
| 150 | - ), |
|
| 151 | - 'hide_add_button_on_cpt_route' => array( |
|
| 152 | - 'edit_attendee' => true, |
|
| 153 | - ), |
|
| 154 | - ); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * grab url requests and route them |
|
| 160 | - * |
|
| 161 | - * @access private |
|
| 162 | - * @return void |
|
| 163 | - */ |
|
| 164 | - public function _set_page_routes() |
|
| 165 | - { |
|
| 166 | - $this->_get_registration_status_array(); |
|
| 167 | - $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 168 | - ? $this->_req_data['_REG_ID'] : 0; |
|
| 169 | - $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) |
|
| 170 | - ? $this->_req_data['ATT_ID'] : 0; |
|
| 171 | - $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) |
|
| 172 | - ? $this->_req_data['post'] |
|
| 173 | - : $att_id; |
|
| 174 | - $this->_page_routes = array( |
|
| 175 | - 'default' => array( |
|
| 176 | - 'func' => '_registrations_overview_list_table', |
|
| 177 | - 'capability' => 'ee_read_registrations', |
|
| 178 | - ), |
|
| 179 | - 'view_registration' => array( |
|
| 180 | - 'func' => '_registration_details', |
|
| 181 | - 'capability' => 'ee_read_registration', |
|
| 182 | - 'obj_id' => $reg_id, |
|
| 183 | - ), |
|
| 184 | - 'edit_registration' => array( |
|
| 185 | - 'func' => '_update_attendee_registration_form', |
|
| 186 | - 'noheader' => true, |
|
| 187 | - 'headers_sent_route' => 'view_registration', |
|
| 188 | - 'capability' => 'ee_edit_registration', |
|
| 189 | - 'obj_id' => $reg_id, |
|
| 190 | - '_REG_ID' => $reg_id, |
|
| 191 | - ), |
|
| 192 | - 'trash_registrations' => array( |
|
| 193 | - 'func' => '_trash_or_restore_registrations', |
|
| 194 | - 'args' => array('trash' => true), |
|
| 195 | - 'noheader' => true, |
|
| 196 | - 'capability' => 'ee_delete_registrations', |
|
| 197 | - ), |
|
| 198 | - 'restore_registrations' => array( |
|
| 199 | - 'func' => '_trash_or_restore_registrations', |
|
| 200 | - 'args' => array('trash' => false), |
|
| 201 | - 'noheader' => true, |
|
| 202 | - 'capability' => 'ee_delete_registrations', |
|
| 203 | - ), |
|
| 204 | - 'delete_registrations' => array( |
|
| 205 | - 'func' => '_delete_registrations', |
|
| 206 | - 'noheader' => true, |
|
| 207 | - 'capability' => 'ee_delete_registrations', |
|
| 208 | - ), |
|
| 209 | - 'new_registration' => array( |
|
| 210 | - 'func' => 'new_registration', |
|
| 211 | - 'capability' => 'ee_edit_registrations', |
|
| 212 | - ), |
|
| 213 | - 'process_reg_step' => array( |
|
| 214 | - 'func' => 'process_reg_step', |
|
| 215 | - 'noheader' => true, |
|
| 216 | - 'capability' => 'ee_edit_registrations', |
|
| 217 | - ), |
|
| 218 | - 'redirect_to_txn' => array( |
|
| 219 | - 'func' => 'redirect_to_txn', |
|
| 220 | - 'noheader' => true, |
|
| 221 | - 'capability' => 'ee_edit_registrations', |
|
| 222 | - ), |
|
| 223 | - 'change_reg_status' => array( |
|
| 224 | - 'func' => '_change_reg_status', |
|
| 225 | - 'noheader' => true, |
|
| 226 | - 'capability' => 'ee_edit_registration', |
|
| 227 | - 'obj_id' => $reg_id, |
|
| 228 | - ), |
|
| 229 | - 'approve_registration' => array( |
|
| 230 | - 'func' => 'approve_registration', |
|
| 231 | - 'noheader' => true, |
|
| 232 | - 'capability' => 'ee_edit_registration', |
|
| 233 | - 'obj_id' => $reg_id, |
|
| 234 | - ), |
|
| 235 | - 'approve_and_notify_registration' => array( |
|
| 236 | - 'func' => 'approve_registration', |
|
| 237 | - 'noheader' => true, |
|
| 238 | - 'args' => array(true), |
|
| 239 | - 'capability' => 'ee_edit_registration', |
|
| 240 | - 'obj_id' => $reg_id, |
|
| 241 | - ), |
|
| 242 | - 'decline_registration' => array( |
|
| 243 | - 'func' => 'decline_registration', |
|
| 244 | - 'noheader' => true, |
|
| 245 | - 'capability' => 'ee_edit_registration', |
|
| 246 | - 'obj_id' => $reg_id, |
|
| 247 | - ), |
|
| 248 | - 'decline_and_notify_registration' => array( |
|
| 249 | - 'func' => 'decline_registration', |
|
| 250 | - 'noheader' => true, |
|
| 251 | - 'args' => array(true), |
|
| 252 | - 'capability' => 'ee_edit_registration', |
|
| 253 | - 'obj_id' => $reg_id, |
|
| 254 | - ), |
|
| 255 | - 'pending_registration' => array( |
|
| 256 | - 'func' => 'pending_registration', |
|
| 257 | - 'noheader' => true, |
|
| 258 | - 'capability' => 'ee_edit_registration', |
|
| 259 | - 'obj_id' => $reg_id, |
|
| 260 | - ), |
|
| 261 | - 'pending_and_notify_registration' => array( |
|
| 262 | - 'func' => 'pending_registration', |
|
| 263 | - 'noheader' => true, |
|
| 264 | - 'args' => array(true), |
|
| 265 | - 'capability' => 'ee_edit_registration', |
|
| 266 | - 'obj_id' => $reg_id, |
|
| 267 | - ), |
|
| 268 | - 'no_approve_registration' => array( |
|
| 269 | - 'func' => 'not_approve_registration', |
|
| 270 | - 'noheader' => true, |
|
| 271 | - 'capability' => 'ee_edit_registration', |
|
| 272 | - 'obj_id' => $reg_id, |
|
| 273 | - ), |
|
| 274 | - 'no_approve_and_notify_registration' => array( |
|
| 275 | - 'func' => 'not_approve_registration', |
|
| 276 | - 'noheader' => true, |
|
| 277 | - 'args' => array(true), |
|
| 278 | - 'capability' => 'ee_edit_registration', |
|
| 279 | - 'obj_id' => $reg_id, |
|
| 280 | - ), |
|
| 281 | - 'cancel_registration' => array( |
|
| 282 | - 'func' => 'cancel_registration', |
|
| 283 | - 'noheader' => true, |
|
| 284 | - 'capability' => 'ee_edit_registration', |
|
| 285 | - 'obj_id' => $reg_id, |
|
| 286 | - ), |
|
| 287 | - 'cancel_and_notify_registration' => array( |
|
| 288 | - 'func' => 'cancel_registration', |
|
| 289 | - 'noheader' => true, |
|
| 290 | - 'args' => array(true), |
|
| 291 | - 'capability' => 'ee_edit_registration', |
|
| 292 | - 'obj_id' => $reg_id, |
|
| 293 | - ), |
|
| 294 | - 'contact_list' => array( |
|
| 295 | - 'func' => '_attendee_contact_list_table', |
|
| 296 | - 'capability' => 'ee_read_contacts', |
|
| 297 | - ), |
|
| 298 | - 'add_new_attendee' => array( |
|
| 299 | - 'func' => '_create_new_cpt_item', |
|
| 300 | - 'args' => array( |
|
| 301 | - 'new_attendee' => true, |
|
| 302 | - 'capability' => 'ee_edit_contacts', |
|
| 303 | - ), |
|
| 304 | - ), |
|
| 305 | - 'edit_attendee' => array( |
|
| 306 | - 'func' => '_edit_cpt_item', |
|
| 307 | - 'capability' => 'ee_edit_contacts', |
|
| 308 | - 'obj_id' => $att_id, |
|
| 309 | - ), |
|
| 310 | - 'duplicate_attendee' => array( |
|
| 311 | - 'func' => '_duplicate_attendee', |
|
| 312 | - 'noheader' => true, |
|
| 313 | - 'capability' => 'ee_edit_contacts', |
|
| 314 | - 'obj_id' => $att_id, |
|
| 315 | - ), |
|
| 316 | - 'insert_attendee' => array( |
|
| 317 | - 'func' => '_insert_or_update_attendee', |
|
| 318 | - 'args' => array( |
|
| 319 | - 'new_attendee' => true, |
|
| 320 | - ), |
|
| 321 | - 'noheader' => true, |
|
| 322 | - 'capability' => 'ee_edit_contacts', |
|
| 323 | - ), |
|
| 324 | - 'update_attendee' => array( |
|
| 325 | - 'func' => '_insert_or_update_attendee', |
|
| 326 | - 'args' => array( |
|
| 327 | - 'new_attendee' => false, |
|
| 328 | - ), |
|
| 329 | - 'noheader' => true, |
|
| 330 | - 'capability' => 'ee_edit_contacts', |
|
| 331 | - 'obj_id' => $att_id, |
|
| 332 | - ), |
|
| 333 | - 'trash_attendee' => array( |
|
| 334 | - 'func' => '_trash_or_restore_attendees', |
|
| 335 | - 'args' => array( |
|
| 336 | - 'trash' => true, |
|
| 337 | - ), |
|
| 338 | - 'noheader' => true, |
|
| 339 | - 'capability' => 'ee_delete_contacts', |
|
| 340 | - 'obj_id' => $att_id, |
|
| 341 | - ), |
|
| 342 | - 'restore_attendees' => array( |
|
| 343 | - 'func' => '_trash_or_restore_attendees', |
|
| 344 | - 'args' => array( |
|
| 345 | - 'trash' => false, |
|
| 346 | - ), |
|
| 347 | - 'noheader' => true, |
|
| 348 | - 'capability' => 'ee_delete_contacts', |
|
| 349 | - 'obj_id' => $att_id, |
|
| 350 | - ), |
|
| 351 | - 'resend_registration' => array( |
|
| 352 | - 'func' => '_resend_registration', |
|
| 353 | - 'noheader' => true, |
|
| 354 | - 'capability' => 'ee_send_message', |
|
| 355 | - ), |
|
| 356 | - 'registrations_report' => array( |
|
| 357 | - 'func' => '_registrations_report', |
|
| 358 | - 'noheader' => true, |
|
| 359 | - 'capability' => 'ee_read_registrations', |
|
| 360 | - ), |
|
| 361 | - 'contact_list_export' => array( |
|
| 362 | - 'func' => '_contact_list_export', |
|
| 363 | - 'noheader' => true, |
|
| 364 | - 'capability' => 'export', |
|
| 365 | - ), |
|
| 366 | - 'contact_list_report' => array( |
|
| 367 | - 'func' => '_contact_list_report', |
|
| 368 | - 'noheader' => true, |
|
| 369 | - 'capability' => 'ee_read_contacts', |
|
| 370 | - ), |
|
| 371 | - ); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - |
|
| 375 | - protected function _set_page_config() |
|
| 376 | - { |
|
| 377 | - $this->_page_config = array( |
|
| 378 | - 'default' => array( |
|
| 379 | - 'nav' => array( |
|
| 380 | - 'label' => esc_html__('Overview', 'event_espresso'), |
|
| 381 | - 'order' => 5, |
|
| 382 | - ), |
|
| 383 | - 'help_tabs' => array( |
|
| 384 | - 'registrations_overview_help_tab' => array( |
|
| 385 | - 'title' => esc_html__('Registrations Overview', 'event_espresso'), |
|
| 386 | - 'filename' => 'registrations_overview', |
|
| 387 | - ), |
|
| 388 | - 'registrations_overview_table_column_headings_help_tab' => array( |
|
| 389 | - 'title' => esc_html__('Registrations Table Column Headings', 'event_espresso'), |
|
| 390 | - 'filename' => 'registrations_overview_table_column_headings', |
|
| 391 | - ), |
|
| 392 | - 'registrations_overview_filters_help_tab' => array( |
|
| 393 | - 'title' => esc_html__('Registration Filters', 'event_espresso'), |
|
| 394 | - 'filename' => 'registrations_overview_filters', |
|
| 395 | - ), |
|
| 396 | - 'registrations_overview_views_help_tab' => array( |
|
| 397 | - 'title' => esc_html__('Registration Views', 'event_espresso'), |
|
| 398 | - 'filename' => 'registrations_overview_views', |
|
| 399 | - ), |
|
| 400 | - 'registrations_regoverview_other_help_tab' => array( |
|
| 401 | - 'title' => esc_html__('Registrations Other', 'event_espresso'), |
|
| 402 | - 'filename' => 'registrations_overview_other', |
|
| 403 | - ), |
|
| 404 | - ), |
|
| 405 | - 'help_tour' => array('Registration_Overview_Help_Tour'), |
|
| 406 | - 'qtips' => array('Registration_List_Table_Tips'), |
|
| 407 | - 'list_table' => 'EE_Registrations_List_Table', |
|
| 408 | - 'require_nonce' => false, |
|
| 409 | - ), |
|
| 410 | - 'view_registration' => array( |
|
| 411 | - 'nav' => array( |
|
| 412 | - 'label' => esc_html__('REG Details', 'event_espresso'), |
|
| 413 | - 'order' => 15, |
|
| 414 | - 'url' => isset($this->_req_data['_REG_ID']) |
|
| 415 | - ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url) |
|
| 416 | - : $this->_admin_base_url, |
|
| 417 | - 'persistent' => false, |
|
| 418 | - ), |
|
| 419 | - 'help_tabs' => array( |
|
| 420 | - 'registrations_details_help_tab' => array( |
|
| 421 | - 'title' => esc_html__('Registration Details', 'event_espresso'), |
|
| 422 | - 'filename' => 'registrations_details', |
|
| 423 | - ), |
|
| 424 | - 'registrations_details_table_help_tab' => array( |
|
| 425 | - 'title' => esc_html__('Registration Details Table', 'event_espresso'), |
|
| 426 | - 'filename' => 'registrations_details_table', |
|
| 427 | - ), |
|
| 428 | - 'registrations_details_form_answers_help_tab' => array( |
|
| 429 | - 'title' => esc_html__('Registration Form Answers', 'event_espresso'), |
|
| 430 | - 'filename' => 'registrations_details_form_answers', |
|
| 431 | - ), |
|
| 432 | - 'registrations_details_registrant_details_help_tab' => array( |
|
| 433 | - 'title' => esc_html__('Contact Details', 'event_espresso'), |
|
| 434 | - 'filename' => 'registrations_details_registrant_details', |
|
| 435 | - ), |
|
| 436 | - ), |
|
| 437 | - 'help_tour' => array('Registration_Details_Help_Tour'), |
|
| 438 | - 'metaboxes' => array_merge( |
|
| 439 | - $this->_default_espresso_metaboxes, |
|
| 440 | - array('_registration_details_metaboxes') |
|
| 441 | - ), |
|
| 442 | - 'require_nonce' => false, |
|
| 443 | - ), |
|
| 444 | - 'new_registration' => array( |
|
| 445 | - 'nav' => array( |
|
| 446 | - 'label' => esc_html__('Add New Registration', 'event_espresso'), |
|
| 447 | - 'url' => '#', |
|
| 448 | - 'order' => 15, |
|
| 449 | - 'persistent' => false, |
|
| 450 | - ), |
|
| 451 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 452 | - 'labels' => array( |
|
| 453 | - 'publishbox' => esc_html__('Save Registration', 'event_espresso'), |
|
| 454 | - ), |
|
| 455 | - 'require_nonce' => false, |
|
| 456 | - ), |
|
| 457 | - 'add_new_attendee' => array( |
|
| 458 | - 'nav' => array( |
|
| 459 | - 'label' => esc_html__('Add Contact', 'event_espresso'), |
|
| 460 | - 'order' => 15, |
|
| 461 | - 'persistent' => false, |
|
| 462 | - ), |
|
| 463 | - 'metaboxes' => array_merge( |
|
| 464 | - $this->_default_espresso_metaboxes, |
|
| 465 | - array('_publish_post_box', 'attendee_editor_metaboxes') |
|
| 466 | - ), |
|
| 467 | - 'require_nonce' => false, |
|
| 468 | - ), |
|
| 469 | - 'edit_attendee' => array( |
|
| 470 | - 'nav' => array( |
|
| 471 | - 'label' => esc_html__('Edit Contact', 'event_espresso'), |
|
| 472 | - 'order' => 15, |
|
| 473 | - 'persistent' => false, |
|
| 474 | - 'url' => isset($this->_req_data['ATT_ID']) |
|
| 475 | - ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) |
|
| 476 | - : $this->_admin_base_url, |
|
| 477 | - ), |
|
| 478 | - 'metaboxes' => array('attendee_editor_metaboxes'), |
|
| 479 | - 'require_nonce' => false, |
|
| 480 | - ), |
|
| 481 | - 'contact_list' => array( |
|
| 482 | - 'nav' => array( |
|
| 483 | - 'label' => esc_html__('Contact List', 'event_espresso'), |
|
| 484 | - 'order' => 20, |
|
| 485 | - ), |
|
| 486 | - 'list_table' => 'EE_Attendee_Contact_List_Table', |
|
| 487 | - 'help_tabs' => array( |
|
| 488 | - 'registrations_contact_list_help_tab' => array( |
|
| 489 | - 'title' => esc_html__('Registrations Contact List', 'event_espresso'), |
|
| 490 | - 'filename' => 'registrations_contact_list', |
|
| 491 | - ), |
|
| 492 | - 'registrations_contact-list_table_column_headings_help_tab' => array( |
|
| 493 | - 'title' => esc_html__('Contact List Table Column Headings', 'event_espresso'), |
|
| 494 | - 'filename' => 'registrations_contact_list_table_column_headings', |
|
| 495 | - ), |
|
| 496 | - 'registrations_contact_list_views_help_tab' => array( |
|
| 497 | - 'title' => esc_html__('Contact List Views', 'event_espresso'), |
|
| 498 | - 'filename' => 'registrations_contact_list_views', |
|
| 499 | - ), |
|
| 500 | - 'registrations_contact_list_other_help_tab' => array( |
|
| 501 | - 'title' => esc_html__('Contact List Other', 'event_espresso'), |
|
| 502 | - 'filename' => 'registrations_contact_list_other', |
|
| 503 | - ), |
|
| 504 | - ), |
|
| 505 | - 'help_tour' => array('Contact_List_Help_Tour'), |
|
| 506 | - 'metaboxes' => array(), |
|
| 507 | - 'require_nonce' => false, |
|
| 508 | - ), |
|
| 509 | - //override default cpt routes |
|
| 510 | - 'create_new' => '', |
|
| 511 | - 'edit' => '', |
|
| 512 | - ); |
|
| 513 | - } |
|
| 514 | - |
|
| 515 | - |
|
| 516 | - /** |
|
| 517 | - * The below methods aren't used by this class currently |
|
| 518 | - */ |
|
| 519 | - protected function _add_screen_options() |
|
| 520 | - { |
|
| 521 | - } |
|
| 522 | - |
|
| 523 | - |
|
| 524 | - protected function _add_feature_pointers() |
|
| 525 | - { |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - |
|
| 529 | - public function admin_init() |
|
| 530 | - { |
|
| 531 | - EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__( |
|
| 532 | - 'click "Update Registration Questions" to save your changes', |
|
| 533 | - 'event_espresso' |
|
| 534 | - ); |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - |
|
| 538 | - public function admin_notices() |
|
| 539 | - { |
|
| 540 | - } |
|
| 541 | - |
|
| 542 | - |
|
| 543 | - public function admin_footer_scripts() |
|
| 544 | - { |
|
| 545 | - } |
|
| 546 | - |
|
| 547 | - |
|
| 548 | - /** |
|
| 549 | - * get list of registration statuses |
|
| 550 | - * |
|
| 551 | - * @access private |
|
| 552 | - * @return void |
|
| 553 | - */ |
|
| 554 | - private function _get_registration_status_array() |
|
| 555 | - { |
|
| 556 | - self::$_reg_status = EEM_Registration::reg_status_array(array(), true); |
|
| 557 | - } |
|
| 558 | - |
|
| 559 | - |
|
| 560 | - protected function _add_screen_options_default() |
|
| 561 | - { |
|
| 562 | - $this->_per_page_screen_option(); |
|
| 563 | - } |
|
| 564 | - |
|
| 565 | - |
|
| 566 | - protected function _add_screen_options_contact_list() |
|
| 567 | - { |
|
| 568 | - $page_title = $this->_admin_page_title; |
|
| 569 | - $this->_admin_page_title = esc_html__("Contacts", 'event_espresso'); |
|
| 570 | - $this->_per_page_screen_option(); |
|
| 571 | - $this->_admin_page_title = $page_title; |
|
| 572 | - } |
|
| 573 | - |
|
| 574 | - |
|
| 575 | - public function load_scripts_styles() |
|
| 576 | - { |
|
| 577 | - //style |
|
| 578 | - wp_register_style( |
|
| 579 | - 'espresso_reg', |
|
| 580 | - REG_ASSETS_URL . 'espresso_registrations_admin.css', |
|
| 581 | - array('ee-admin-css'), |
|
| 582 | - EVENT_ESPRESSO_VERSION |
|
| 583 | - ); |
|
| 584 | - wp_enqueue_style('espresso_reg'); |
|
| 585 | - //script |
|
| 586 | - wp_register_script( |
|
| 587 | - 'espresso_reg', |
|
| 588 | - REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
| 589 | - array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), |
|
| 590 | - EVENT_ESPRESSO_VERSION, |
|
| 591 | - true |
|
| 592 | - ); |
|
| 593 | - wp_enqueue_script('espresso_reg'); |
|
| 594 | - } |
|
| 595 | - |
|
| 596 | - |
|
| 597 | - public function load_scripts_styles_edit_attendee() |
|
| 598 | - { |
|
| 599 | - //stuff to only show up on our attendee edit details page. |
|
| 600 | - $attendee_details_translations = array( |
|
| 601 | - 'att_publish_text' => sprintf( |
|
| 602 | - esc_html__('Created on: <b>%1$s</b>', 'event_espresso'), |
|
| 603 | - $this->_cpt_model_obj->get_datetime('ATT_created') |
|
| 604 | - ), |
|
| 605 | - ); |
|
| 606 | - wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations); |
|
| 607 | - wp_enqueue_script('jquery-validate'); |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - |
|
| 611 | - public function load_scripts_styles_view_registration() |
|
| 612 | - { |
|
| 613 | - //styles |
|
| 614 | - wp_enqueue_style('espresso-ui-theme'); |
|
| 615 | - //scripts |
|
| 616 | - $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
| 617 | - $this->_reg_custom_questions_form->wp_enqueue_scripts(true); |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - |
|
| 621 | - public function load_scripts_styles_contact_list() |
|
| 622 | - { |
|
| 623 | - wp_deregister_style('espresso_reg'); |
|
| 624 | - wp_register_style( |
|
| 625 | - 'espresso_att', |
|
| 626 | - REG_ASSETS_URL . 'espresso_attendees_admin.css', |
|
| 627 | - array('ee-admin-css'), |
|
| 628 | - EVENT_ESPRESSO_VERSION |
|
| 629 | - ); |
|
| 630 | - wp_enqueue_style('espresso_att'); |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - |
|
| 634 | - public function load_scripts_styles_new_registration() |
|
| 635 | - { |
|
| 636 | - wp_register_script( |
|
| 637 | - 'ee-spco-for-admin', |
|
| 638 | - REG_ASSETS_URL . 'spco_for_admin.js', |
|
| 639 | - array('underscore', 'jquery'), |
|
| 640 | - EVENT_ESPRESSO_VERSION, |
|
| 641 | - true |
|
| 642 | - ); |
|
| 643 | - wp_enqueue_script('ee-spco-for-admin'); |
|
| 644 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 645 | - EE_Form_Section_Proper::wp_enqueue_scripts(); |
|
| 646 | - EED_Ticket_Selector::load_tckt_slctr_assets(); |
|
| 647 | - EE_Datepicker_Input::enqueue_styles_and_scripts(); |
|
| 648 | - } |
|
| 649 | - |
|
| 650 | - |
|
| 651 | - public function AHEE__EE_Admin_Page__route_admin_request_resend_registration() |
|
| 652 | - { |
|
| 653 | - add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 654 | - } |
|
| 655 | - |
|
| 656 | - |
|
| 657 | - public function AHEE__EE_Admin_Page__route_admin_request_approve_registration() |
|
| 658 | - { |
|
| 659 | - add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 660 | - } |
|
| 661 | - |
|
| 662 | - |
|
| 663 | - protected function _set_list_table_views_default() |
|
| 664 | - { |
|
| 665 | - //for notification related bulk actions we need to make sure only active messengers have an option. |
|
| 666 | - EED_Messages::set_autoloaders(); |
|
| 667 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
| 668 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 669 | - $active_mts = $message_resource_manager->list_of_active_message_types(); |
|
| 670 | - //key= bulk_action_slug, value= message type. |
|
| 671 | - $match_array = array( |
|
| 672 | - 'approve_registration' => 'registration', |
|
| 673 | - 'decline_registration' => 'declined_registration', |
|
| 674 | - 'pending_registration' => 'pending_approval', |
|
| 675 | - 'no_approve_registration' => 'not_approved_registration', |
|
| 676 | - 'cancel_registration' => 'cancelled_registration', |
|
| 677 | - ); |
|
| 678 | - /** setup reg status bulk actions **/ |
|
| 679 | - $def_reg_status_actions['approve_registration'] = esc_html__('Approve Registrations', 'event_espresso'); |
|
| 680 | - if (in_array($match_array['approve_registration'], $active_mts) |
|
| 681 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 682 | - ) { |
|
| 683 | - $def_reg_status_actions['approve_and_notify_registration'] = esc_html__( |
|
| 684 | - 'Approve and Notify Registrations', |
|
| 685 | - 'event_espresso' |
|
| 686 | - ); |
|
| 687 | - } |
|
| 688 | - $def_reg_status_actions['decline_registration'] = esc_html__('Decline Registrations', 'event_espresso'); |
|
| 689 | - if (in_array($match_array['decline_registration'], $active_mts) |
|
| 690 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 691 | - ) { |
|
| 692 | - $def_reg_status_actions['decline_and_notify_registration'] = esc_html__( |
|
| 693 | - 'Decline and Notify Registrations', |
|
| 694 | - 'event_espresso' |
|
| 695 | - ); |
|
| 696 | - } |
|
| 697 | - $def_reg_status_actions['pending_registration'] = esc_html__( |
|
| 698 | - 'Set Registrations to Pending Payment', |
|
| 699 | - 'event_espresso' |
|
| 700 | - ); |
|
| 701 | - if (in_array($match_array['pending_registration'], $active_mts) |
|
| 702 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 703 | - ) { |
|
| 704 | - $def_reg_status_actions['pending_and_notify_registration'] = esc_html__( |
|
| 705 | - 'Set Registrations to Pending Payment and Notify', |
|
| 706 | - 'event_espresso' |
|
| 707 | - ); |
|
| 708 | - } |
|
| 709 | - $def_reg_status_actions['no_approve_registration'] = esc_html__( |
|
| 710 | - 'Set Registrations to Not Approved', |
|
| 711 | - 'event_espresso' |
|
| 712 | - ); |
|
| 713 | - if (in_array($match_array['no_approve_registration'], $active_mts) |
|
| 714 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 715 | - ) { |
|
| 716 | - $def_reg_status_actions['no_approve_and_notify_registration'] = esc_html__( |
|
| 717 | - 'Set Registrations to Not Approved and Notify', |
|
| 718 | - 'event_espresso' |
|
| 719 | - ); |
|
| 720 | - } |
|
| 721 | - $def_reg_status_actions['cancel_registration'] = esc_html__('Cancel Registrations', 'event_espresso'); |
|
| 722 | - if (in_array($match_array['cancel_registration'], $active_mts) |
|
| 723 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 724 | - ) { |
|
| 725 | - $def_reg_status_actions['cancel_and_notify_registration'] = esc_html__( |
|
| 726 | - 'Cancel Registrations and Notify', |
|
| 727 | - 'event_espresso' |
|
| 728 | - ); |
|
| 729 | - } |
|
| 730 | - $this->_views = array( |
|
| 731 | - 'all' => array( |
|
| 732 | - 'slug' => 'all', |
|
| 733 | - 'label' => esc_html__('View All Registrations', 'event_espresso'), |
|
| 734 | - 'count' => 0, |
|
| 735 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 736 | - 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 737 | - )), |
|
| 738 | - ), |
|
| 739 | - 'month' => array( |
|
| 740 | - 'slug' => 'month', |
|
| 741 | - 'label' => esc_html__('This Month', 'event_espresso'), |
|
| 742 | - 'count' => 0, |
|
| 743 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 744 | - 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 745 | - )), |
|
| 746 | - ), |
|
| 747 | - 'today' => array( |
|
| 748 | - 'slug' => 'today', |
|
| 749 | - 'label' => sprintf( |
|
| 750 | - esc_html__('Today - %s', 'event_espresso'), |
|
| 751 | - date('M d, Y', current_time('timestamp')) |
|
| 752 | - ), |
|
| 753 | - 'count' => 0, |
|
| 754 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 755 | - 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 756 | - )), |
|
| 757 | - ), |
|
| 758 | - ); |
|
| 759 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 760 | - 'ee_delete_registrations', |
|
| 761 | - 'espresso_registrations_delete_registration' |
|
| 762 | - )) { |
|
| 763 | - $this->_views['incomplete'] = array( |
|
| 764 | - 'slug' => 'incomplete', |
|
| 765 | - 'label' => esc_html__('Incomplete', 'event_espresso'), |
|
| 766 | - 'count' => 0, |
|
| 767 | - 'bulk_action' => array( |
|
| 768 | - 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 769 | - ), |
|
| 770 | - ); |
|
| 771 | - $this->_views['trash'] = array( |
|
| 772 | - 'slug' => 'trash', |
|
| 773 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 774 | - 'count' => 0, |
|
| 775 | - 'bulk_action' => array( |
|
| 776 | - 'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'), |
|
| 777 | - 'delete_registrations' => esc_html__('Delete Registrations Permanently', 'event_espresso'), |
|
| 778 | - ), |
|
| 779 | - ); |
|
| 780 | - } |
|
| 781 | - } |
|
| 782 | - |
|
| 783 | - |
|
| 784 | - protected function _set_list_table_views_contact_list() |
|
| 785 | - { |
|
| 786 | - $this->_views = array( |
|
| 787 | - 'in_use' => array( |
|
| 788 | - 'slug' => 'in_use', |
|
| 789 | - 'label' => esc_html__('In Use', 'event_espresso'), |
|
| 790 | - 'count' => 0, |
|
| 791 | - 'bulk_action' => array( |
|
| 792 | - 'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 793 | - ), |
|
| 794 | - ), |
|
| 795 | - ); |
|
| 796 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', |
|
| 797 | - 'espresso_registrations_trash_attendees') |
|
| 798 | - ) { |
|
| 799 | - $this->_views['trash'] = array( |
|
| 800 | - 'slug' => 'trash', |
|
| 801 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 802 | - 'count' => 0, |
|
| 803 | - 'bulk_action' => array( |
|
| 804 | - 'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'), |
|
| 805 | - ), |
|
| 806 | - ); |
|
| 807 | - } |
|
| 808 | - } |
|
| 809 | - |
|
| 810 | - |
|
| 811 | - protected function _registration_legend_items() |
|
| 812 | - { |
|
| 813 | - $fc_items = array( |
|
| 814 | - 'star-icon' => array( |
|
| 815 | - 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 816 | - 'desc' => esc_html__('This is the Primary Registrant', 'event_espresso'), |
|
| 817 | - ), |
|
| 818 | - 'view_details' => array( |
|
| 819 | - 'class' => 'dashicons dashicons-clipboard', |
|
| 820 | - 'desc' => esc_html__('View Registration Details', 'event_espresso'), |
|
| 821 | - ), |
|
| 822 | - 'edit_attendee' => array( |
|
| 823 | - 'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16', |
|
| 824 | - 'desc' => esc_html__('Edit Contact Details', 'event_espresso'), |
|
| 825 | - ), |
|
| 826 | - 'view_transaction' => array( |
|
| 827 | - 'class' => 'dashicons dashicons-cart', |
|
| 828 | - 'desc' => esc_html__('View Transaction Details', 'event_espresso'), |
|
| 829 | - ), |
|
| 830 | - 'view_invoice' => array( |
|
| 831 | - 'class' => 'dashicons dashicons-media-spreadsheet', |
|
| 832 | - 'desc' => esc_html__('View Transaction Invoice', 'event_espresso'), |
|
| 833 | - ), |
|
| 834 | - ); |
|
| 835 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 836 | - 'ee_send_message', |
|
| 837 | - 'espresso_registrations_resend_registration' |
|
| 838 | - )) { |
|
| 839 | - $fc_items['resend_registration'] = array( |
|
| 840 | - 'class' => 'dashicons dashicons-email-alt', |
|
| 841 | - 'desc' => esc_html__('Resend Registration Details', 'event_espresso'), |
|
| 842 | - ); |
|
| 843 | - } else { |
|
| 844 | - $fc_items['blank'] = array('class' => 'blank', 'desc' => ''); |
|
| 845 | - } |
|
| 846 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 847 | - 'ee_read_global_messages', |
|
| 848 | - 'view_filtered_messages' |
|
| 849 | - )) { |
|
| 850 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 851 | - if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
| 852 | - $fc_items['view_related_messages'] = array( |
|
| 853 | - 'class' => $related_for_icon['css_class'], |
|
| 854 | - 'desc' => $related_for_icon['label'], |
|
| 855 | - ); |
|
| 856 | - } |
|
| 857 | - } |
|
| 858 | - $sc_items = array( |
|
| 859 | - 'approved_status' => array( |
|
| 860 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 861 | - 'desc' => EEH_Template::pretty_status( |
|
| 862 | - EEM_Registration::status_id_approved, |
|
| 863 | - false, |
|
| 864 | - 'sentence' |
|
| 865 | - ), |
|
| 866 | - ), |
|
| 867 | - 'pending_status' => array( |
|
| 868 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 869 | - 'desc' => EEH_Template::pretty_status( |
|
| 870 | - EEM_Registration::status_id_pending_payment, |
|
| 871 | - false, |
|
| 872 | - 'sentence' |
|
| 873 | - ), |
|
| 874 | - ), |
|
| 875 | - 'wait_list' => array( |
|
| 876 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 877 | - 'desc' => EEH_Template::pretty_status( |
|
| 878 | - EEM_Registration::status_id_wait_list, |
|
| 879 | - false, |
|
| 880 | - 'sentence' |
|
| 881 | - ), |
|
| 882 | - ), |
|
| 883 | - 'incomplete_status' => array( |
|
| 884 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
| 885 | - 'desc' => EEH_Template::pretty_status( |
|
| 886 | - EEM_Registration::status_id_incomplete, |
|
| 887 | - false, |
|
| 888 | - 'sentence' |
|
| 889 | - ), |
|
| 890 | - ), |
|
| 891 | - 'not_approved' => array( |
|
| 892 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 893 | - 'desc' => EEH_Template::pretty_status( |
|
| 894 | - EEM_Registration::status_id_not_approved, |
|
| 895 | - false, |
|
| 896 | - 'sentence' |
|
| 897 | - ), |
|
| 898 | - ), |
|
| 899 | - 'declined_status' => array( |
|
| 900 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 901 | - 'desc' => EEH_Template::pretty_status( |
|
| 902 | - EEM_Registration::status_id_declined, |
|
| 903 | - false, |
|
| 904 | - 'sentence' |
|
| 905 | - ), |
|
| 906 | - ), |
|
| 907 | - 'cancelled_status' => array( |
|
| 908 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 909 | - 'desc' => EEH_Template::pretty_status( |
|
| 910 | - EEM_Registration::status_id_cancelled, |
|
| 911 | - false, |
|
| 912 | - 'sentence' |
|
| 913 | - ), |
|
| 914 | - ), |
|
| 915 | - ); |
|
| 916 | - return array_merge($fc_items, $sc_items); |
|
| 917 | - } |
|
| 918 | - |
|
| 919 | - |
|
| 920 | - |
|
| 921 | - /*************************************** REGISTRATION OVERVIEW **************************************/ |
|
| 922 | - /** |
|
| 923 | - * @throws \EE_Error |
|
| 924 | - */ |
|
| 925 | - protected function _registrations_overview_list_table() |
|
| 926 | - { |
|
| 927 | - $this->_template_args['admin_page_header'] = ''; |
|
| 928 | - $EVT_ID = ! empty($this->_req_data['event_id']) |
|
| 929 | - ? absint($this->_req_data['event_id']) |
|
| 930 | - : 0; |
|
| 931 | - if ($EVT_ID) { |
|
| 932 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 933 | - 'ee_edit_registrations', |
|
| 934 | - 'espresso_registrations_new_registration', |
|
| 935 | - $EVT_ID |
|
| 936 | - )) { |
|
| 937 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 938 | - 'new_registration', |
|
| 939 | - 'add-registrant', |
|
| 940 | - array('event_id' => $EVT_ID), |
|
| 941 | - 'add-new-h2' |
|
| 942 | - ); |
|
| 943 | - } |
|
| 944 | - $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 945 | - if ($event instanceof EE_Event) { |
|
| 946 | - $this->_template_args['admin_page_header'] = sprintf( |
|
| 947 | - esc_html__( |
|
| 948 | - '%s Viewing registrations for the event: %s%s', |
|
| 949 | - 'event_espresso' |
|
| 950 | - ), |
|
| 951 | - '<h3 style="line-height:1.5em;">', |
|
| 952 | - '<br /><a href="' |
|
| 953 | - . EE_Admin_Page::add_query_args_and_nonce( |
|
| 954 | - array( |
|
| 955 | - 'action' => 'edit', |
|
| 956 | - 'post' => $event->ID(), |
|
| 957 | - ), |
|
| 958 | - EVENTS_ADMIN_URL |
|
| 959 | - ) |
|
| 960 | - . '"> ' |
|
| 961 | - . $event->get('EVT_name') |
|
| 962 | - . ' </a> ', |
|
| 963 | - '</h3>' |
|
| 964 | - ); |
|
| 965 | - } |
|
| 966 | - $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
|
| 967 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 968 | - if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') { |
|
| 969 | - $this->_template_args['admin_page_header'] = substr( |
|
| 970 | - $this->_template_args['admin_page_header'], |
|
| 971 | - 0, |
|
| 972 | - -5 |
|
| 973 | - ); |
|
| 974 | - $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
|
| 975 | - $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 976 | - $this->_template_args['admin_page_header'] .= $datetime->name(); |
|
| 977 | - $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
| 978 | - $this->_template_args['admin_page_header'] .= '</span></h3>'; |
|
| 979 | - } |
|
| 980 | - } |
|
| 981 | - $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items()); |
|
| 982 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 983 | - } |
|
| 984 | - |
|
| 985 | - |
|
| 986 | - /** |
|
| 987 | - * This sets the _registration property for the registration details screen |
|
| 988 | - * |
|
| 989 | - * @access private |
|
| 990 | - * @return bool |
|
| 991 | - */ |
|
| 992 | - private function _set_registration_object() |
|
| 993 | - { |
|
| 994 | - //get out if we've already set the object |
|
| 995 | - if (is_object($this->_registration)) { |
|
| 996 | - return true; |
|
| 997 | - } |
|
| 998 | - $REG = EEM_Registration::instance(); |
|
| 999 | - $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 1000 | - if ($this->_registration = $REG->get_one_by_ID($REG_ID)) { |
|
| 1001 | - return true; |
|
| 1002 | - } else { |
|
| 1003 | - $error_msg = sprintf( |
|
| 1004 | - esc_html__( |
|
| 1005 | - 'An error occurred and the details for Registration ID #%s could not be retrieved.', |
|
| 1006 | - 'event_espresso' |
|
| 1007 | - ), |
|
| 1008 | - $REG_ID |
|
| 1009 | - ); |
|
| 1010 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1011 | - $this->_registration = null; |
|
| 1012 | - return false; |
|
| 1013 | - } |
|
| 1014 | - } |
|
| 1015 | - |
|
| 1016 | - |
|
| 1017 | - /** |
|
| 1018 | - * Used to retrieve registrations for the list table. |
|
| 1019 | - * |
|
| 1020 | - * @param int $per_page |
|
| 1021 | - * @param bool $count |
|
| 1022 | - * @param bool $this_month |
|
| 1023 | - * @param bool $today |
|
| 1024 | - * @return EE_Registration[]|int |
|
| 1025 | - * @throws EE_Error |
|
| 1026 | - */ |
|
| 1027 | - public function get_registrations( |
|
| 1028 | - $per_page = 10, |
|
| 1029 | - $count = false, |
|
| 1030 | - $this_month = false, |
|
| 1031 | - $today = false |
|
| 1032 | - ) { |
|
| 1033 | - if ($this_month) { |
|
| 1034 | - $this->_req_data['status'] = 'month'; |
|
| 1035 | - } |
|
| 1036 | - if ($today) { |
|
| 1037 | - $this->_req_data['status'] = 'today'; |
|
| 1038 | - } |
|
| 1039 | - $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count); |
|
| 1040 | - /** |
|
| 1041 | - * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
| 1042 | - * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
| 1043 | - * @see EEM_Base::get_all() |
|
| 1044 | - */ |
|
| 1045 | - $query_params['group_by'] = ''; |
|
| 1046 | - |
|
| 1047 | - return $count |
|
| 1048 | - ? EEM_Registration::instance()->count($query_params) |
|
| 1049 | - /** @type EE_Registration[] */ |
|
| 1050 | - : EEM_Registration::instance()->get_all($query_params); |
|
| 1051 | - } |
|
| 1052 | - |
|
| 1053 | - |
|
| 1054 | - |
|
| 1055 | - /** |
|
| 1056 | - * Retrieves the query parameters to be used by the Registration model for getting registrations. |
|
| 1057 | - * Note: this listens to values on the request for some of the query parameters. |
|
| 1058 | - * |
|
| 1059 | - * @param array $request |
|
| 1060 | - * @param int $per_page |
|
| 1061 | - * @param bool $count |
|
| 1062 | - * @return array |
|
| 1063 | - */ |
|
| 1064 | - protected function _get_registration_query_parameters( |
|
| 1065 | - $request = array(), |
|
| 1066 | - $per_page = 10, |
|
| 1067 | - $count = false |
|
| 1068 | - ) { |
|
| 1069 | - |
|
| 1070 | - $query_params = array( |
|
| 1071 | - 0 => $this->_get_where_conditions_for_registrations_query( |
|
| 1072 | - $request |
|
| 1073 | - ), |
|
| 1074 | - 'caps' => EEM_Registration::caps_read_admin, |
|
| 1075 | - 'default_where_conditions' => 'this_model_only', |
|
| 1076 | - ); |
|
| 1077 | - if (! $count) { |
|
| 1078 | - $query_params = array_merge( |
|
| 1079 | - $query_params, |
|
| 1080 | - $this->_get_orderby_for_registrations_query(), |
|
| 1081 | - $this->_get_limit($per_page) |
|
| 1082 | - ); |
|
| 1083 | - } |
|
| 1084 | - |
|
| 1085 | - return $query_params; |
|
| 1086 | - } |
|
| 1087 | - |
|
| 1088 | - |
|
| 1089 | - /** |
|
| 1090 | - * This will add EVT_ID to the provided $where array for EE model query parameters. |
|
| 1091 | - * |
|
| 1092 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1093 | - * @return array |
|
| 1094 | - */ |
|
| 1095 | - protected function _add_event_id_to_where_conditions(array $request) |
|
| 1096 | - { |
|
| 1097 | - $where = array(); |
|
| 1098 | - if (! empty($request['event_id'])) { |
|
| 1099 | - $where['EVT_ID'] = absint($request['event_id']); |
|
| 1100 | - } |
|
| 1101 | - return $where; |
|
| 1102 | - } |
|
| 1103 | - |
|
| 1104 | - |
|
| 1105 | - /** |
|
| 1106 | - * Adds category ID if it exists in the request to the where conditions for the registrations query. |
|
| 1107 | - * |
|
| 1108 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1109 | - * @return array |
|
| 1110 | - */ |
|
| 1111 | - protected function _add_category_id_to_where_conditions(array $request) |
|
| 1112 | - { |
|
| 1113 | - $where = array(); |
|
| 1114 | - if (! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) { |
|
| 1115 | - $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']); |
|
| 1116 | - } |
|
| 1117 | - return $where; |
|
| 1118 | - } |
|
| 1119 | - |
|
| 1120 | - |
|
| 1121 | - /** |
|
| 1122 | - * Adds the datetime ID if it exists in the request to the where conditions for the registrations query. |
|
| 1123 | - * |
|
| 1124 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1125 | - * @return array |
|
| 1126 | - */ |
|
| 1127 | - protected function _add_datetime_id_to_where_conditions(array $request) |
|
| 1128 | - { |
|
| 1129 | - $where = array(); |
|
| 1130 | - if (! empty($request['datetime_id'])) { |
|
| 1131 | - $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']); |
|
| 1132 | - } |
|
| 1133 | - if (! empty($request['DTT_ID'])) { |
|
| 1134 | - $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']); |
|
| 1135 | - } |
|
| 1136 | - return $where; |
|
| 1137 | - } |
|
| 1138 | - |
|
| 1139 | - |
|
| 1140 | - /** |
|
| 1141 | - * Adds the correct registration status to the where conditions for the registrations query. |
|
| 1142 | - * |
|
| 1143 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1144 | - * @return array |
|
| 1145 | - */ |
|
| 1146 | - protected function _add_registration_status_to_where_conditions(array $request) |
|
| 1147 | - { |
|
| 1148 | - $where = array(); |
|
| 1149 | - $view = EEH_Array::is_set($request, 'status', ''); |
|
| 1150 | - $registration_status = ! empty($request['_reg_status']) |
|
| 1151 | - ? sanitize_text_field($request['_reg_status']) |
|
| 1152 | - : ''; |
|
| 1153 | - |
|
| 1154 | - /* |
|
| 26 | + /** |
|
| 27 | + * @var EE_Registration |
|
| 28 | + */ |
|
| 29 | + private $_registration; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var EE_Event |
|
| 33 | + */ |
|
| 34 | + private $_reg_event; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var EE_Session |
|
| 38 | + */ |
|
| 39 | + private $_session; |
|
| 40 | + |
|
| 41 | + private static $_reg_status; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Form for displaying the custom questions for this registration. |
|
| 45 | + * This gets used a few times throughout the request so its best to cache it |
|
| 46 | + * |
|
| 47 | + * @var EE_Registration_Custom_Questions_Form |
|
| 48 | + */ |
|
| 49 | + protected $_reg_custom_questions_form = null; |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * constructor |
|
| 54 | + * |
|
| 55 | + * @Constructor |
|
| 56 | + * @access public |
|
| 57 | + * @param bool $routing |
|
| 58 | + * @return Registrations_Admin_Page |
|
| 59 | + */ |
|
| 60 | + public function __construct($routing = true) |
|
| 61 | + { |
|
| 62 | + parent::__construct($routing); |
|
| 63 | + add_action('wp_loaded', array($this, 'wp_loaded')); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + public function wp_loaded() |
|
| 68 | + { |
|
| 69 | + // when adding a new registration... |
|
| 70 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') { |
|
| 71 | + EE_System::do_not_cache(); |
|
| 72 | + if (! isset($this->_req_data['processing_registration']) |
|
| 73 | + || absint($this->_req_data['processing_registration']) !== 1 |
|
| 74 | + ) { |
|
| 75 | + // and it's NOT the attendee information reg step |
|
| 76 | + // force cookie expiration by setting time to last week |
|
| 77 | + setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/'); |
|
| 78 | + // and update the global |
|
| 79 | + $_COOKIE['ee_registration_added'] = 0; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + protected function _init_page_props() |
|
| 86 | + { |
|
| 87 | + $this->page_slug = REG_PG_SLUG; |
|
| 88 | + $this->_admin_base_url = REG_ADMIN_URL; |
|
| 89 | + $this->_admin_base_path = REG_ADMIN; |
|
| 90 | + $this->page_label = esc_html__('Registrations', 'event_espresso'); |
|
| 91 | + $this->_cpt_routes = array( |
|
| 92 | + 'add_new_attendee' => 'espresso_attendees', |
|
| 93 | + 'edit_attendee' => 'espresso_attendees', |
|
| 94 | + 'insert_attendee' => 'espresso_attendees', |
|
| 95 | + 'update_attendee' => 'espresso_attendees', |
|
| 96 | + ); |
|
| 97 | + $this->_cpt_model_names = array( |
|
| 98 | + 'add_new_attendee' => 'EEM_Attendee', |
|
| 99 | + 'edit_attendee' => 'EEM_Attendee', |
|
| 100 | + ); |
|
| 101 | + $this->_cpt_edit_routes = array( |
|
| 102 | + 'espresso_attendees' => 'edit_attendee', |
|
| 103 | + ); |
|
| 104 | + $this->_pagenow_map = array( |
|
| 105 | + 'add_new_attendee' => 'post-new.php', |
|
| 106 | + 'edit_attendee' => 'post.php', |
|
| 107 | + 'trash' => 'post.php', |
|
| 108 | + ); |
|
| 109 | + add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10); |
|
| 110 | + //add filters so that the comment urls don't take users to a confusing 404 page |
|
| 111 | + add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + |
|
| 115 | + public function clear_comment_link($link, $comment, $args) |
|
| 116 | + { |
|
| 117 | + //gotta make sure this only happens on this route |
|
| 118 | + $post_type = get_post_type($comment->comment_post_ID); |
|
| 119 | + if ($post_type === 'espresso_attendees') { |
|
| 120 | + return '#commentsdiv'; |
|
| 121 | + } |
|
| 122 | + return $link; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + protected function _ajax_hooks() |
|
| 127 | + { |
|
| 128 | + //todo: all hooks for registrations ajax goes in here |
|
| 129 | + add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status')); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + protected function _define_page_props() |
|
| 134 | + { |
|
| 135 | + $this->_admin_page_title = $this->page_label; |
|
| 136 | + $this->_labels = array( |
|
| 137 | + 'buttons' => array( |
|
| 138 | + 'add-registrant' => esc_html__('Add New Registration', 'event_espresso'), |
|
| 139 | + 'add-attendee' => esc_html__('Add Contact', 'event_espresso'), |
|
| 140 | + 'edit' => esc_html__('Edit Contact', 'event_espresso'), |
|
| 141 | + 'report' => esc_html__("Event Registrations CSV Report", "event_espresso"), |
|
| 142 | + 'report_all' => esc_html__('All Registrations CSV Report', 'event_espresso'), |
|
| 143 | + 'report_filtered' => esc_html__('Filtered CSV Report', 'event_espresso'), |
|
| 144 | + 'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'), |
|
| 145 | + 'contact_list_export' => esc_html__("Export Data", "event_espresso"), |
|
| 146 | + ), |
|
| 147 | + 'publishbox' => array( |
|
| 148 | + 'add_new_attendee' => esc_html__("Add Contact Record", 'event_espresso'), |
|
| 149 | + 'edit_attendee' => esc_html__("Update Contact Record", 'event_espresso'), |
|
| 150 | + ), |
|
| 151 | + 'hide_add_button_on_cpt_route' => array( |
|
| 152 | + 'edit_attendee' => true, |
|
| 153 | + ), |
|
| 154 | + ); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * grab url requests and route them |
|
| 160 | + * |
|
| 161 | + * @access private |
|
| 162 | + * @return void |
|
| 163 | + */ |
|
| 164 | + public function _set_page_routes() |
|
| 165 | + { |
|
| 166 | + $this->_get_registration_status_array(); |
|
| 167 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 168 | + ? $this->_req_data['_REG_ID'] : 0; |
|
| 169 | + $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) |
|
| 170 | + ? $this->_req_data['ATT_ID'] : 0; |
|
| 171 | + $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) |
|
| 172 | + ? $this->_req_data['post'] |
|
| 173 | + : $att_id; |
|
| 174 | + $this->_page_routes = array( |
|
| 175 | + 'default' => array( |
|
| 176 | + 'func' => '_registrations_overview_list_table', |
|
| 177 | + 'capability' => 'ee_read_registrations', |
|
| 178 | + ), |
|
| 179 | + 'view_registration' => array( |
|
| 180 | + 'func' => '_registration_details', |
|
| 181 | + 'capability' => 'ee_read_registration', |
|
| 182 | + 'obj_id' => $reg_id, |
|
| 183 | + ), |
|
| 184 | + 'edit_registration' => array( |
|
| 185 | + 'func' => '_update_attendee_registration_form', |
|
| 186 | + 'noheader' => true, |
|
| 187 | + 'headers_sent_route' => 'view_registration', |
|
| 188 | + 'capability' => 'ee_edit_registration', |
|
| 189 | + 'obj_id' => $reg_id, |
|
| 190 | + '_REG_ID' => $reg_id, |
|
| 191 | + ), |
|
| 192 | + 'trash_registrations' => array( |
|
| 193 | + 'func' => '_trash_or_restore_registrations', |
|
| 194 | + 'args' => array('trash' => true), |
|
| 195 | + 'noheader' => true, |
|
| 196 | + 'capability' => 'ee_delete_registrations', |
|
| 197 | + ), |
|
| 198 | + 'restore_registrations' => array( |
|
| 199 | + 'func' => '_trash_or_restore_registrations', |
|
| 200 | + 'args' => array('trash' => false), |
|
| 201 | + 'noheader' => true, |
|
| 202 | + 'capability' => 'ee_delete_registrations', |
|
| 203 | + ), |
|
| 204 | + 'delete_registrations' => array( |
|
| 205 | + 'func' => '_delete_registrations', |
|
| 206 | + 'noheader' => true, |
|
| 207 | + 'capability' => 'ee_delete_registrations', |
|
| 208 | + ), |
|
| 209 | + 'new_registration' => array( |
|
| 210 | + 'func' => 'new_registration', |
|
| 211 | + 'capability' => 'ee_edit_registrations', |
|
| 212 | + ), |
|
| 213 | + 'process_reg_step' => array( |
|
| 214 | + 'func' => 'process_reg_step', |
|
| 215 | + 'noheader' => true, |
|
| 216 | + 'capability' => 'ee_edit_registrations', |
|
| 217 | + ), |
|
| 218 | + 'redirect_to_txn' => array( |
|
| 219 | + 'func' => 'redirect_to_txn', |
|
| 220 | + 'noheader' => true, |
|
| 221 | + 'capability' => 'ee_edit_registrations', |
|
| 222 | + ), |
|
| 223 | + 'change_reg_status' => array( |
|
| 224 | + 'func' => '_change_reg_status', |
|
| 225 | + 'noheader' => true, |
|
| 226 | + 'capability' => 'ee_edit_registration', |
|
| 227 | + 'obj_id' => $reg_id, |
|
| 228 | + ), |
|
| 229 | + 'approve_registration' => array( |
|
| 230 | + 'func' => 'approve_registration', |
|
| 231 | + 'noheader' => true, |
|
| 232 | + 'capability' => 'ee_edit_registration', |
|
| 233 | + 'obj_id' => $reg_id, |
|
| 234 | + ), |
|
| 235 | + 'approve_and_notify_registration' => array( |
|
| 236 | + 'func' => 'approve_registration', |
|
| 237 | + 'noheader' => true, |
|
| 238 | + 'args' => array(true), |
|
| 239 | + 'capability' => 'ee_edit_registration', |
|
| 240 | + 'obj_id' => $reg_id, |
|
| 241 | + ), |
|
| 242 | + 'decline_registration' => array( |
|
| 243 | + 'func' => 'decline_registration', |
|
| 244 | + 'noheader' => true, |
|
| 245 | + 'capability' => 'ee_edit_registration', |
|
| 246 | + 'obj_id' => $reg_id, |
|
| 247 | + ), |
|
| 248 | + 'decline_and_notify_registration' => array( |
|
| 249 | + 'func' => 'decline_registration', |
|
| 250 | + 'noheader' => true, |
|
| 251 | + 'args' => array(true), |
|
| 252 | + 'capability' => 'ee_edit_registration', |
|
| 253 | + 'obj_id' => $reg_id, |
|
| 254 | + ), |
|
| 255 | + 'pending_registration' => array( |
|
| 256 | + 'func' => 'pending_registration', |
|
| 257 | + 'noheader' => true, |
|
| 258 | + 'capability' => 'ee_edit_registration', |
|
| 259 | + 'obj_id' => $reg_id, |
|
| 260 | + ), |
|
| 261 | + 'pending_and_notify_registration' => array( |
|
| 262 | + 'func' => 'pending_registration', |
|
| 263 | + 'noheader' => true, |
|
| 264 | + 'args' => array(true), |
|
| 265 | + 'capability' => 'ee_edit_registration', |
|
| 266 | + 'obj_id' => $reg_id, |
|
| 267 | + ), |
|
| 268 | + 'no_approve_registration' => array( |
|
| 269 | + 'func' => 'not_approve_registration', |
|
| 270 | + 'noheader' => true, |
|
| 271 | + 'capability' => 'ee_edit_registration', |
|
| 272 | + 'obj_id' => $reg_id, |
|
| 273 | + ), |
|
| 274 | + 'no_approve_and_notify_registration' => array( |
|
| 275 | + 'func' => 'not_approve_registration', |
|
| 276 | + 'noheader' => true, |
|
| 277 | + 'args' => array(true), |
|
| 278 | + 'capability' => 'ee_edit_registration', |
|
| 279 | + 'obj_id' => $reg_id, |
|
| 280 | + ), |
|
| 281 | + 'cancel_registration' => array( |
|
| 282 | + 'func' => 'cancel_registration', |
|
| 283 | + 'noheader' => true, |
|
| 284 | + 'capability' => 'ee_edit_registration', |
|
| 285 | + 'obj_id' => $reg_id, |
|
| 286 | + ), |
|
| 287 | + 'cancel_and_notify_registration' => array( |
|
| 288 | + 'func' => 'cancel_registration', |
|
| 289 | + 'noheader' => true, |
|
| 290 | + 'args' => array(true), |
|
| 291 | + 'capability' => 'ee_edit_registration', |
|
| 292 | + 'obj_id' => $reg_id, |
|
| 293 | + ), |
|
| 294 | + 'contact_list' => array( |
|
| 295 | + 'func' => '_attendee_contact_list_table', |
|
| 296 | + 'capability' => 'ee_read_contacts', |
|
| 297 | + ), |
|
| 298 | + 'add_new_attendee' => array( |
|
| 299 | + 'func' => '_create_new_cpt_item', |
|
| 300 | + 'args' => array( |
|
| 301 | + 'new_attendee' => true, |
|
| 302 | + 'capability' => 'ee_edit_contacts', |
|
| 303 | + ), |
|
| 304 | + ), |
|
| 305 | + 'edit_attendee' => array( |
|
| 306 | + 'func' => '_edit_cpt_item', |
|
| 307 | + 'capability' => 'ee_edit_contacts', |
|
| 308 | + 'obj_id' => $att_id, |
|
| 309 | + ), |
|
| 310 | + 'duplicate_attendee' => array( |
|
| 311 | + 'func' => '_duplicate_attendee', |
|
| 312 | + 'noheader' => true, |
|
| 313 | + 'capability' => 'ee_edit_contacts', |
|
| 314 | + 'obj_id' => $att_id, |
|
| 315 | + ), |
|
| 316 | + 'insert_attendee' => array( |
|
| 317 | + 'func' => '_insert_or_update_attendee', |
|
| 318 | + 'args' => array( |
|
| 319 | + 'new_attendee' => true, |
|
| 320 | + ), |
|
| 321 | + 'noheader' => true, |
|
| 322 | + 'capability' => 'ee_edit_contacts', |
|
| 323 | + ), |
|
| 324 | + 'update_attendee' => array( |
|
| 325 | + 'func' => '_insert_or_update_attendee', |
|
| 326 | + 'args' => array( |
|
| 327 | + 'new_attendee' => false, |
|
| 328 | + ), |
|
| 329 | + 'noheader' => true, |
|
| 330 | + 'capability' => 'ee_edit_contacts', |
|
| 331 | + 'obj_id' => $att_id, |
|
| 332 | + ), |
|
| 333 | + 'trash_attendee' => array( |
|
| 334 | + 'func' => '_trash_or_restore_attendees', |
|
| 335 | + 'args' => array( |
|
| 336 | + 'trash' => true, |
|
| 337 | + ), |
|
| 338 | + 'noheader' => true, |
|
| 339 | + 'capability' => 'ee_delete_contacts', |
|
| 340 | + 'obj_id' => $att_id, |
|
| 341 | + ), |
|
| 342 | + 'restore_attendees' => array( |
|
| 343 | + 'func' => '_trash_or_restore_attendees', |
|
| 344 | + 'args' => array( |
|
| 345 | + 'trash' => false, |
|
| 346 | + ), |
|
| 347 | + 'noheader' => true, |
|
| 348 | + 'capability' => 'ee_delete_contacts', |
|
| 349 | + 'obj_id' => $att_id, |
|
| 350 | + ), |
|
| 351 | + 'resend_registration' => array( |
|
| 352 | + 'func' => '_resend_registration', |
|
| 353 | + 'noheader' => true, |
|
| 354 | + 'capability' => 'ee_send_message', |
|
| 355 | + ), |
|
| 356 | + 'registrations_report' => array( |
|
| 357 | + 'func' => '_registrations_report', |
|
| 358 | + 'noheader' => true, |
|
| 359 | + 'capability' => 'ee_read_registrations', |
|
| 360 | + ), |
|
| 361 | + 'contact_list_export' => array( |
|
| 362 | + 'func' => '_contact_list_export', |
|
| 363 | + 'noheader' => true, |
|
| 364 | + 'capability' => 'export', |
|
| 365 | + ), |
|
| 366 | + 'contact_list_report' => array( |
|
| 367 | + 'func' => '_contact_list_report', |
|
| 368 | + 'noheader' => true, |
|
| 369 | + 'capability' => 'ee_read_contacts', |
|
| 370 | + ), |
|
| 371 | + ); |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + |
|
| 375 | + protected function _set_page_config() |
|
| 376 | + { |
|
| 377 | + $this->_page_config = array( |
|
| 378 | + 'default' => array( |
|
| 379 | + 'nav' => array( |
|
| 380 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
| 381 | + 'order' => 5, |
|
| 382 | + ), |
|
| 383 | + 'help_tabs' => array( |
|
| 384 | + 'registrations_overview_help_tab' => array( |
|
| 385 | + 'title' => esc_html__('Registrations Overview', 'event_espresso'), |
|
| 386 | + 'filename' => 'registrations_overview', |
|
| 387 | + ), |
|
| 388 | + 'registrations_overview_table_column_headings_help_tab' => array( |
|
| 389 | + 'title' => esc_html__('Registrations Table Column Headings', 'event_espresso'), |
|
| 390 | + 'filename' => 'registrations_overview_table_column_headings', |
|
| 391 | + ), |
|
| 392 | + 'registrations_overview_filters_help_tab' => array( |
|
| 393 | + 'title' => esc_html__('Registration Filters', 'event_espresso'), |
|
| 394 | + 'filename' => 'registrations_overview_filters', |
|
| 395 | + ), |
|
| 396 | + 'registrations_overview_views_help_tab' => array( |
|
| 397 | + 'title' => esc_html__('Registration Views', 'event_espresso'), |
|
| 398 | + 'filename' => 'registrations_overview_views', |
|
| 399 | + ), |
|
| 400 | + 'registrations_regoverview_other_help_tab' => array( |
|
| 401 | + 'title' => esc_html__('Registrations Other', 'event_espresso'), |
|
| 402 | + 'filename' => 'registrations_overview_other', |
|
| 403 | + ), |
|
| 404 | + ), |
|
| 405 | + 'help_tour' => array('Registration_Overview_Help_Tour'), |
|
| 406 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
| 407 | + 'list_table' => 'EE_Registrations_List_Table', |
|
| 408 | + 'require_nonce' => false, |
|
| 409 | + ), |
|
| 410 | + 'view_registration' => array( |
|
| 411 | + 'nav' => array( |
|
| 412 | + 'label' => esc_html__('REG Details', 'event_espresso'), |
|
| 413 | + 'order' => 15, |
|
| 414 | + 'url' => isset($this->_req_data['_REG_ID']) |
|
| 415 | + ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url) |
|
| 416 | + : $this->_admin_base_url, |
|
| 417 | + 'persistent' => false, |
|
| 418 | + ), |
|
| 419 | + 'help_tabs' => array( |
|
| 420 | + 'registrations_details_help_tab' => array( |
|
| 421 | + 'title' => esc_html__('Registration Details', 'event_espresso'), |
|
| 422 | + 'filename' => 'registrations_details', |
|
| 423 | + ), |
|
| 424 | + 'registrations_details_table_help_tab' => array( |
|
| 425 | + 'title' => esc_html__('Registration Details Table', 'event_espresso'), |
|
| 426 | + 'filename' => 'registrations_details_table', |
|
| 427 | + ), |
|
| 428 | + 'registrations_details_form_answers_help_tab' => array( |
|
| 429 | + 'title' => esc_html__('Registration Form Answers', 'event_espresso'), |
|
| 430 | + 'filename' => 'registrations_details_form_answers', |
|
| 431 | + ), |
|
| 432 | + 'registrations_details_registrant_details_help_tab' => array( |
|
| 433 | + 'title' => esc_html__('Contact Details', 'event_espresso'), |
|
| 434 | + 'filename' => 'registrations_details_registrant_details', |
|
| 435 | + ), |
|
| 436 | + ), |
|
| 437 | + 'help_tour' => array('Registration_Details_Help_Tour'), |
|
| 438 | + 'metaboxes' => array_merge( |
|
| 439 | + $this->_default_espresso_metaboxes, |
|
| 440 | + array('_registration_details_metaboxes') |
|
| 441 | + ), |
|
| 442 | + 'require_nonce' => false, |
|
| 443 | + ), |
|
| 444 | + 'new_registration' => array( |
|
| 445 | + 'nav' => array( |
|
| 446 | + 'label' => esc_html__('Add New Registration', 'event_espresso'), |
|
| 447 | + 'url' => '#', |
|
| 448 | + 'order' => 15, |
|
| 449 | + 'persistent' => false, |
|
| 450 | + ), |
|
| 451 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 452 | + 'labels' => array( |
|
| 453 | + 'publishbox' => esc_html__('Save Registration', 'event_espresso'), |
|
| 454 | + ), |
|
| 455 | + 'require_nonce' => false, |
|
| 456 | + ), |
|
| 457 | + 'add_new_attendee' => array( |
|
| 458 | + 'nav' => array( |
|
| 459 | + 'label' => esc_html__('Add Contact', 'event_espresso'), |
|
| 460 | + 'order' => 15, |
|
| 461 | + 'persistent' => false, |
|
| 462 | + ), |
|
| 463 | + 'metaboxes' => array_merge( |
|
| 464 | + $this->_default_espresso_metaboxes, |
|
| 465 | + array('_publish_post_box', 'attendee_editor_metaboxes') |
|
| 466 | + ), |
|
| 467 | + 'require_nonce' => false, |
|
| 468 | + ), |
|
| 469 | + 'edit_attendee' => array( |
|
| 470 | + 'nav' => array( |
|
| 471 | + 'label' => esc_html__('Edit Contact', 'event_espresso'), |
|
| 472 | + 'order' => 15, |
|
| 473 | + 'persistent' => false, |
|
| 474 | + 'url' => isset($this->_req_data['ATT_ID']) |
|
| 475 | + ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) |
|
| 476 | + : $this->_admin_base_url, |
|
| 477 | + ), |
|
| 478 | + 'metaboxes' => array('attendee_editor_metaboxes'), |
|
| 479 | + 'require_nonce' => false, |
|
| 480 | + ), |
|
| 481 | + 'contact_list' => array( |
|
| 482 | + 'nav' => array( |
|
| 483 | + 'label' => esc_html__('Contact List', 'event_espresso'), |
|
| 484 | + 'order' => 20, |
|
| 485 | + ), |
|
| 486 | + 'list_table' => 'EE_Attendee_Contact_List_Table', |
|
| 487 | + 'help_tabs' => array( |
|
| 488 | + 'registrations_contact_list_help_tab' => array( |
|
| 489 | + 'title' => esc_html__('Registrations Contact List', 'event_espresso'), |
|
| 490 | + 'filename' => 'registrations_contact_list', |
|
| 491 | + ), |
|
| 492 | + 'registrations_contact-list_table_column_headings_help_tab' => array( |
|
| 493 | + 'title' => esc_html__('Contact List Table Column Headings', 'event_espresso'), |
|
| 494 | + 'filename' => 'registrations_contact_list_table_column_headings', |
|
| 495 | + ), |
|
| 496 | + 'registrations_contact_list_views_help_tab' => array( |
|
| 497 | + 'title' => esc_html__('Contact List Views', 'event_espresso'), |
|
| 498 | + 'filename' => 'registrations_contact_list_views', |
|
| 499 | + ), |
|
| 500 | + 'registrations_contact_list_other_help_tab' => array( |
|
| 501 | + 'title' => esc_html__('Contact List Other', 'event_espresso'), |
|
| 502 | + 'filename' => 'registrations_contact_list_other', |
|
| 503 | + ), |
|
| 504 | + ), |
|
| 505 | + 'help_tour' => array('Contact_List_Help_Tour'), |
|
| 506 | + 'metaboxes' => array(), |
|
| 507 | + 'require_nonce' => false, |
|
| 508 | + ), |
|
| 509 | + //override default cpt routes |
|
| 510 | + 'create_new' => '', |
|
| 511 | + 'edit' => '', |
|
| 512 | + ); |
|
| 513 | + } |
|
| 514 | + |
|
| 515 | + |
|
| 516 | + /** |
|
| 517 | + * The below methods aren't used by this class currently |
|
| 518 | + */ |
|
| 519 | + protected function _add_screen_options() |
|
| 520 | + { |
|
| 521 | + } |
|
| 522 | + |
|
| 523 | + |
|
| 524 | + protected function _add_feature_pointers() |
|
| 525 | + { |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + |
|
| 529 | + public function admin_init() |
|
| 530 | + { |
|
| 531 | + EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__( |
|
| 532 | + 'click "Update Registration Questions" to save your changes', |
|
| 533 | + 'event_espresso' |
|
| 534 | + ); |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + |
|
| 538 | + public function admin_notices() |
|
| 539 | + { |
|
| 540 | + } |
|
| 541 | + |
|
| 542 | + |
|
| 543 | + public function admin_footer_scripts() |
|
| 544 | + { |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + |
|
| 548 | + /** |
|
| 549 | + * get list of registration statuses |
|
| 550 | + * |
|
| 551 | + * @access private |
|
| 552 | + * @return void |
|
| 553 | + */ |
|
| 554 | + private function _get_registration_status_array() |
|
| 555 | + { |
|
| 556 | + self::$_reg_status = EEM_Registration::reg_status_array(array(), true); |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + |
|
| 560 | + protected function _add_screen_options_default() |
|
| 561 | + { |
|
| 562 | + $this->_per_page_screen_option(); |
|
| 563 | + } |
|
| 564 | + |
|
| 565 | + |
|
| 566 | + protected function _add_screen_options_contact_list() |
|
| 567 | + { |
|
| 568 | + $page_title = $this->_admin_page_title; |
|
| 569 | + $this->_admin_page_title = esc_html__("Contacts", 'event_espresso'); |
|
| 570 | + $this->_per_page_screen_option(); |
|
| 571 | + $this->_admin_page_title = $page_title; |
|
| 572 | + } |
|
| 573 | + |
|
| 574 | + |
|
| 575 | + public function load_scripts_styles() |
|
| 576 | + { |
|
| 577 | + //style |
|
| 578 | + wp_register_style( |
|
| 579 | + 'espresso_reg', |
|
| 580 | + REG_ASSETS_URL . 'espresso_registrations_admin.css', |
|
| 581 | + array('ee-admin-css'), |
|
| 582 | + EVENT_ESPRESSO_VERSION |
|
| 583 | + ); |
|
| 584 | + wp_enqueue_style('espresso_reg'); |
|
| 585 | + //script |
|
| 586 | + wp_register_script( |
|
| 587 | + 'espresso_reg', |
|
| 588 | + REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
| 589 | + array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), |
|
| 590 | + EVENT_ESPRESSO_VERSION, |
|
| 591 | + true |
|
| 592 | + ); |
|
| 593 | + wp_enqueue_script('espresso_reg'); |
|
| 594 | + } |
|
| 595 | + |
|
| 596 | + |
|
| 597 | + public function load_scripts_styles_edit_attendee() |
|
| 598 | + { |
|
| 599 | + //stuff to only show up on our attendee edit details page. |
|
| 600 | + $attendee_details_translations = array( |
|
| 601 | + 'att_publish_text' => sprintf( |
|
| 602 | + esc_html__('Created on: <b>%1$s</b>', 'event_espresso'), |
|
| 603 | + $this->_cpt_model_obj->get_datetime('ATT_created') |
|
| 604 | + ), |
|
| 605 | + ); |
|
| 606 | + wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations); |
|
| 607 | + wp_enqueue_script('jquery-validate'); |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + |
|
| 611 | + public function load_scripts_styles_view_registration() |
|
| 612 | + { |
|
| 613 | + //styles |
|
| 614 | + wp_enqueue_style('espresso-ui-theme'); |
|
| 615 | + //scripts |
|
| 616 | + $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
| 617 | + $this->_reg_custom_questions_form->wp_enqueue_scripts(true); |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + |
|
| 621 | + public function load_scripts_styles_contact_list() |
|
| 622 | + { |
|
| 623 | + wp_deregister_style('espresso_reg'); |
|
| 624 | + wp_register_style( |
|
| 625 | + 'espresso_att', |
|
| 626 | + REG_ASSETS_URL . 'espresso_attendees_admin.css', |
|
| 627 | + array('ee-admin-css'), |
|
| 628 | + EVENT_ESPRESSO_VERSION |
|
| 629 | + ); |
|
| 630 | + wp_enqueue_style('espresso_att'); |
|
| 631 | + } |
|
| 632 | + |
|
| 633 | + |
|
| 634 | + public function load_scripts_styles_new_registration() |
|
| 635 | + { |
|
| 636 | + wp_register_script( |
|
| 637 | + 'ee-spco-for-admin', |
|
| 638 | + REG_ASSETS_URL . 'spco_for_admin.js', |
|
| 639 | + array('underscore', 'jquery'), |
|
| 640 | + EVENT_ESPRESSO_VERSION, |
|
| 641 | + true |
|
| 642 | + ); |
|
| 643 | + wp_enqueue_script('ee-spco-for-admin'); |
|
| 644 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 645 | + EE_Form_Section_Proper::wp_enqueue_scripts(); |
|
| 646 | + EED_Ticket_Selector::load_tckt_slctr_assets(); |
|
| 647 | + EE_Datepicker_Input::enqueue_styles_and_scripts(); |
|
| 648 | + } |
|
| 649 | + |
|
| 650 | + |
|
| 651 | + public function AHEE__EE_Admin_Page__route_admin_request_resend_registration() |
|
| 652 | + { |
|
| 653 | + add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 654 | + } |
|
| 655 | + |
|
| 656 | + |
|
| 657 | + public function AHEE__EE_Admin_Page__route_admin_request_approve_registration() |
|
| 658 | + { |
|
| 659 | + add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 660 | + } |
|
| 661 | + |
|
| 662 | + |
|
| 663 | + protected function _set_list_table_views_default() |
|
| 664 | + { |
|
| 665 | + //for notification related bulk actions we need to make sure only active messengers have an option. |
|
| 666 | + EED_Messages::set_autoloaders(); |
|
| 667 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
| 668 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 669 | + $active_mts = $message_resource_manager->list_of_active_message_types(); |
|
| 670 | + //key= bulk_action_slug, value= message type. |
|
| 671 | + $match_array = array( |
|
| 672 | + 'approve_registration' => 'registration', |
|
| 673 | + 'decline_registration' => 'declined_registration', |
|
| 674 | + 'pending_registration' => 'pending_approval', |
|
| 675 | + 'no_approve_registration' => 'not_approved_registration', |
|
| 676 | + 'cancel_registration' => 'cancelled_registration', |
|
| 677 | + ); |
|
| 678 | + /** setup reg status bulk actions **/ |
|
| 679 | + $def_reg_status_actions['approve_registration'] = esc_html__('Approve Registrations', 'event_espresso'); |
|
| 680 | + if (in_array($match_array['approve_registration'], $active_mts) |
|
| 681 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 682 | + ) { |
|
| 683 | + $def_reg_status_actions['approve_and_notify_registration'] = esc_html__( |
|
| 684 | + 'Approve and Notify Registrations', |
|
| 685 | + 'event_espresso' |
|
| 686 | + ); |
|
| 687 | + } |
|
| 688 | + $def_reg_status_actions['decline_registration'] = esc_html__('Decline Registrations', 'event_espresso'); |
|
| 689 | + if (in_array($match_array['decline_registration'], $active_mts) |
|
| 690 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 691 | + ) { |
|
| 692 | + $def_reg_status_actions['decline_and_notify_registration'] = esc_html__( |
|
| 693 | + 'Decline and Notify Registrations', |
|
| 694 | + 'event_espresso' |
|
| 695 | + ); |
|
| 696 | + } |
|
| 697 | + $def_reg_status_actions['pending_registration'] = esc_html__( |
|
| 698 | + 'Set Registrations to Pending Payment', |
|
| 699 | + 'event_espresso' |
|
| 700 | + ); |
|
| 701 | + if (in_array($match_array['pending_registration'], $active_mts) |
|
| 702 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 703 | + ) { |
|
| 704 | + $def_reg_status_actions['pending_and_notify_registration'] = esc_html__( |
|
| 705 | + 'Set Registrations to Pending Payment and Notify', |
|
| 706 | + 'event_espresso' |
|
| 707 | + ); |
|
| 708 | + } |
|
| 709 | + $def_reg_status_actions['no_approve_registration'] = esc_html__( |
|
| 710 | + 'Set Registrations to Not Approved', |
|
| 711 | + 'event_espresso' |
|
| 712 | + ); |
|
| 713 | + if (in_array($match_array['no_approve_registration'], $active_mts) |
|
| 714 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 715 | + ) { |
|
| 716 | + $def_reg_status_actions['no_approve_and_notify_registration'] = esc_html__( |
|
| 717 | + 'Set Registrations to Not Approved and Notify', |
|
| 718 | + 'event_espresso' |
|
| 719 | + ); |
|
| 720 | + } |
|
| 721 | + $def_reg_status_actions['cancel_registration'] = esc_html__('Cancel Registrations', 'event_espresso'); |
|
| 722 | + if (in_array($match_array['cancel_registration'], $active_mts) |
|
| 723 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 724 | + ) { |
|
| 725 | + $def_reg_status_actions['cancel_and_notify_registration'] = esc_html__( |
|
| 726 | + 'Cancel Registrations and Notify', |
|
| 727 | + 'event_espresso' |
|
| 728 | + ); |
|
| 729 | + } |
|
| 730 | + $this->_views = array( |
|
| 731 | + 'all' => array( |
|
| 732 | + 'slug' => 'all', |
|
| 733 | + 'label' => esc_html__('View All Registrations', 'event_espresso'), |
|
| 734 | + 'count' => 0, |
|
| 735 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 736 | + 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 737 | + )), |
|
| 738 | + ), |
|
| 739 | + 'month' => array( |
|
| 740 | + 'slug' => 'month', |
|
| 741 | + 'label' => esc_html__('This Month', 'event_espresso'), |
|
| 742 | + 'count' => 0, |
|
| 743 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 744 | + 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 745 | + )), |
|
| 746 | + ), |
|
| 747 | + 'today' => array( |
|
| 748 | + 'slug' => 'today', |
|
| 749 | + 'label' => sprintf( |
|
| 750 | + esc_html__('Today - %s', 'event_espresso'), |
|
| 751 | + date('M d, Y', current_time('timestamp')) |
|
| 752 | + ), |
|
| 753 | + 'count' => 0, |
|
| 754 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 755 | + 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 756 | + )), |
|
| 757 | + ), |
|
| 758 | + ); |
|
| 759 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 760 | + 'ee_delete_registrations', |
|
| 761 | + 'espresso_registrations_delete_registration' |
|
| 762 | + )) { |
|
| 763 | + $this->_views['incomplete'] = array( |
|
| 764 | + 'slug' => 'incomplete', |
|
| 765 | + 'label' => esc_html__('Incomplete', 'event_espresso'), |
|
| 766 | + 'count' => 0, |
|
| 767 | + 'bulk_action' => array( |
|
| 768 | + 'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'), |
|
| 769 | + ), |
|
| 770 | + ); |
|
| 771 | + $this->_views['trash'] = array( |
|
| 772 | + 'slug' => 'trash', |
|
| 773 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 774 | + 'count' => 0, |
|
| 775 | + 'bulk_action' => array( |
|
| 776 | + 'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'), |
|
| 777 | + 'delete_registrations' => esc_html__('Delete Registrations Permanently', 'event_espresso'), |
|
| 778 | + ), |
|
| 779 | + ); |
|
| 780 | + } |
|
| 781 | + } |
|
| 782 | + |
|
| 783 | + |
|
| 784 | + protected function _set_list_table_views_contact_list() |
|
| 785 | + { |
|
| 786 | + $this->_views = array( |
|
| 787 | + 'in_use' => array( |
|
| 788 | + 'slug' => 'in_use', |
|
| 789 | + 'label' => esc_html__('In Use', 'event_espresso'), |
|
| 790 | + 'count' => 0, |
|
| 791 | + 'bulk_action' => array( |
|
| 792 | + 'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 793 | + ), |
|
| 794 | + ), |
|
| 795 | + ); |
|
| 796 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', |
|
| 797 | + 'espresso_registrations_trash_attendees') |
|
| 798 | + ) { |
|
| 799 | + $this->_views['trash'] = array( |
|
| 800 | + 'slug' => 'trash', |
|
| 801 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 802 | + 'count' => 0, |
|
| 803 | + 'bulk_action' => array( |
|
| 804 | + 'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'), |
|
| 805 | + ), |
|
| 806 | + ); |
|
| 807 | + } |
|
| 808 | + } |
|
| 809 | + |
|
| 810 | + |
|
| 811 | + protected function _registration_legend_items() |
|
| 812 | + { |
|
| 813 | + $fc_items = array( |
|
| 814 | + 'star-icon' => array( |
|
| 815 | + 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 816 | + 'desc' => esc_html__('This is the Primary Registrant', 'event_espresso'), |
|
| 817 | + ), |
|
| 818 | + 'view_details' => array( |
|
| 819 | + 'class' => 'dashicons dashicons-clipboard', |
|
| 820 | + 'desc' => esc_html__('View Registration Details', 'event_espresso'), |
|
| 821 | + ), |
|
| 822 | + 'edit_attendee' => array( |
|
| 823 | + 'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16', |
|
| 824 | + 'desc' => esc_html__('Edit Contact Details', 'event_espresso'), |
|
| 825 | + ), |
|
| 826 | + 'view_transaction' => array( |
|
| 827 | + 'class' => 'dashicons dashicons-cart', |
|
| 828 | + 'desc' => esc_html__('View Transaction Details', 'event_espresso'), |
|
| 829 | + ), |
|
| 830 | + 'view_invoice' => array( |
|
| 831 | + 'class' => 'dashicons dashicons-media-spreadsheet', |
|
| 832 | + 'desc' => esc_html__('View Transaction Invoice', 'event_espresso'), |
|
| 833 | + ), |
|
| 834 | + ); |
|
| 835 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 836 | + 'ee_send_message', |
|
| 837 | + 'espresso_registrations_resend_registration' |
|
| 838 | + )) { |
|
| 839 | + $fc_items['resend_registration'] = array( |
|
| 840 | + 'class' => 'dashicons dashicons-email-alt', |
|
| 841 | + 'desc' => esc_html__('Resend Registration Details', 'event_espresso'), |
|
| 842 | + ); |
|
| 843 | + } else { |
|
| 844 | + $fc_items['blank'] = array('class' => 'blank', 'desc' => ''); |
|
| 845 | + } |
|
| 846 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 847 | + 'ee_read_global_messages', |
|
| 848 | + 'view_filtered_messages' |
|
| 849 | + )) { |
|
| 850 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 851 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
| 852 | + $fc_items['view_related_messages'] = array( |
|
| 853 | + 'class' => $related_for_icon['css_class'], |
|
| 854 | + 'desc' => $related_for_icon['label'], |
|
| 855 | + ); |
|
| 856 | + } |
|
| 857 | + } |
|
| 858 | + $sc_items = array( |
|
| 859 | + 'approved_status' => array( |
|
| 860 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 861 | + 'desc' => EEH_Template::pretty_status( |
|
| 862 | + EEM_Registration::status_id_approved, |
|
| 863 | + false, |
|
| 864 | + 'sentence' |
|
| 865 | + ), |
|
| 866 | + ), |
|
| 867 | + 'pending_status' => array( |
|
| 868 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 869 | + 'desc' => EEH_Template::pretty_status( |
|
| 870 | + EEM_Registration::status_id_pending_payment, |
|
| 871 | + false, |
|
| 872 | + 'sentence' |
|
| 873 | + ), |
|
| 874 | + ), |
|
| 875 | + 'wait_list' => array( |
|
| 876 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 877 | + 'desc' => EEH_Template::pretty_status( |
|
| 878 | + EEM_Registration::status_id_wait_list, |
|
| 879 | + false, |
|
| 880 | + 'sentence' |
|
| 881 | + ), |
|
| 882 | + ), |
|
| 883 | + 'incomplete_status' => array( |
|
| 884 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
| 885 | + 'desc' => EEH_Template::pretty_status( |
|
| 886 | + EEM_Registration::status_id_incomplete, |
|
| 887 | + false, |
|
| 888 | + 'sentence' |
|
| 889 | + ), |
|
| 890 | + ), |
|
| 891 | + 'not_approved' => array( |
|
| 892 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 893 | + 'desc' => EEH_Template::pretty_status( |
|
| 894 | + EEM_Registration::status_id_not_approved, |
|
| 895 | + false, |
|
| 896 | + 'sentence' |
|
| 897 | + ), |
|
| 898 | + ), |
|
| 899 | + 'declined_status' => array( |
|
| 900 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 901 | + 'desc' => EEH_Template::pretty_status( |
|
| 902 | + EEM_Registration::status_id_declined, |
|
| 903 | + false, |
|
| 904 | + 'sentence' |
|
| 905 | + ), |
|
| 906 | + ), |
|
| 907 | + 'cancelled_status' => array( |
|
| 908 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 909 | + 'desc' => EEH_Template::pretty_status( |
|
| 910 | + EEM_Registration::status_id_cancelled, |
|
| 911 | + false, |
|
| 912 | + 'sentence' |
|
| 913 | + ), |
|
| 914 | + ), |
|
| 915 | + ); |
|
| 916 | + return array_merge($fc_items, $sc_items); |
|
| 917 | + } |
|
| 918 | + |
|
| 919 | + |
|
| 920 | + |
|
| 921 | + /*************************************** REGISTRATION OVERVIEW **************************************/ |
|
| 922 | + /** |
|
| 923 | + * @throws \EE_Error |
|
| 924 | + */ |
|
| 925 | + protected function _registrations_overview_list_table() |
|
| 926 | + { |
|
| 927 | + $this->_template_args['admin_page_header'] = ''; |
|
| 928 | + $EVT_ID = ! empty($this->_req_data['event_id']) |
|
| 929 | + ? absint($this->_req_data['event_id']) |
|
| 930 | + : 0; |
|
| 931 | + if ($EVT_ID) { |
|
| 932 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 933 | + 'ee_edit_registrations', |
|
| 934 | + 'espresso_registrations_new_registration', |
|
| 935 | + $EVT_ID |
|
| 936 | + )) { |
|
| 937 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 938 | + 'new_registration', |
|
| 939 | + 'add-registrant', |
|
| 940 | + array('event_id' => $EVT_ID), |
|
| 941 | + 'add-new-h2' |
|
| 942 | + ); |
|
| 943 | + } |
|
| 944 | + $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 945 | + if ($event instanceof EE_Event) { |
|
| 946 | + $this->_template_args['admin_page_header'] = sprintf( |
|
| 947 | + esc_html__( |
|
| 948 | + '%s Viewing registrations for the event: %s%s', |
|
| 949 | + 'event_espresso' |
|
| 950 | + ), |
|
| 951 | + '<h3 style="line-height:1.5em;">', |
|
| 952 | + '<br /><a href="' |
|
| 953 | + . EE_Admin_Page::add_query_args_and_nonce( |
|
| 954 | + array( |
|
| 955 | + 'action' => 'edit', |
|
| 956 | + 'post' => $event->ID(), |
|
| 957 | + ), |
|
| 958 | + EVENTS_ADMIN_URL |
|
| 959 | + ) |
|
| 960 | + . '"> ' |
|
| 961 | + . $event->get('EVT_name') |
|
| 962 | + . ' </a> ', |
|
| 963 | + '</h3>' |
|
| 964 | + ); |
|
| 965 | + } |
|
| 966 | + $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
|
| 967 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 968 | + if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') { |
|
| 969 | + $this->_template_args['admin_page_header'] = substr( |
|
| 970 | + $this->_template_args['admin_page_header'], |
|
| 971 | + 0, |
|
| 972 | + -5 |
|
| 973 | + ); |
|
| 974 | + $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
|
| 975 | + $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 976 | + $this->_template_args['admin_page_header'] .= $datetime->name(); |
|
| 977 | + $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
| 978 | + $this->_template_args['admin_page_header'] .= '</span></h3>'; |
|
| 979 | + } |
|
| 980 | + } |
|
| 981 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items()); |
|
| 982 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 983 | + } |
|
| 984 | + |
|
| 985 | + |
|
| 986 | + /** |
|
| 987 | + * This sets the _registration property for the registration details screen |
|
| 988 | + * |
|
| 989 | + * @access private |
|
| 990 | + * @return bool |
|
| 991 | + */ |
|
| 992 | + private function _set_registration_object() |
|
| 993 | + { |
|
| 994 | + //get out if we've already set the object |
|
| 995 | + if (is_object($this->_registration)) { |
|
| 996 | + return true; |
|
| 997 | + } |
|
| 998 | + $REG = EEM_Registration::instance(); |
|
| 999 | + $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 1000 | + if ($this->_registration = $REG->get_one_by_ID($REG_ID)) { |
|
| 1001 | + return true; |
|
| 1002 | + } else { |
|
| 1003 | + $error_msg = sprintf( |
|
| 1004 | + esc_html__( |
|
| 1005 | + 'An error occurred and the details for Registration ID #%s could not be retrieved.', |
|
| 1006 | + 'event_espresso' |
|
| 1007 | + ), |
|
| 1008 | + $REG_ID |
|
| 1009 | + ); |
|
| 1010 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1011 | + $this->_registration = null; |
|
| 1012 | + return false; |
|
| 1013 | + } |
|
| 1014 | + } |
|
| 1015 | + |
|
| 1016 | + |
|
| 1017 | + /** |
|
| 1018 | + * Used to retrieve registrations for the list table. |
|
| 1019 | + * |
|
| 1020 | + * @param int $per_page |
|
| 1021 | + * @param bool $count |
|
| 1022 | + * @param bool $this_month |
|
| 1023 | + * @param bool $today |
|
| 1024 | + * @return EE_Registration[]|int |
|
| 1025 | + * @throws EE_Error |
|
| 1026 | + */ |
|
| 1027 | + public function get_registrations( |
|
| 1028 | + $per_page = 10, |
|
| 1029 | + $count = false, |
|
| 1030 | + $this_month = false, |
|
| 1031 | + $today = false |
|
| 1032 | + ) { |
|
| 1033 | + if ($this_month) { |
|
| 1034 | + $this->_req_data['status'] = 'month'; |
|
| 1035 | + } |
|
| 1036 | + if ($today) { |
|
| 1037 | + $this->_req_data['status'] = 'today'; |
|
| 1038 | + } |
|
| 1039 | + $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count); |
|
| 1040 | + /** |
|
| 1041 | + * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
| 1042 | + * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
| 1043 | + * @see EEM_Base::get_all() |
|
| 1044 | + */ |
|
| 1045 | + $query_params['group_by'] = ''; |
|
| 1046 | + |
|
| 1047 | + return $count |
|
| 1048 | + ? EEM_Registration::instance()->count($query_params) |
|
| 1049 | + /** @type EE_Registration[] */ |
|
| 1050 | + : EEM_Registration::instance()->get_all($query_params); |
|
| 1051 | + } |
|
| 1052 | + |
|
| 1053 | + |
|
| 1054 | + |
|
| 1055 | + /** |
|
| 1056 | + * Retrieves the query parameters to be used by the Registration model for getting registrations. |
|
| 1057 | + * Note: this listens to values on the request for some of the query parameters. |
|
| 1058 | + * |
|
| 1059 | + * @param array $request |
|
| 1060 | + * @param int $per_page |
|
| 1061 | + * @param bool $count |
|
| 1062 | + * @return array |
|
| 1063 | + */ |
|
| 1064 | + protected function _get_registration_query_parameters( |
|
| 1065 | + $request = array(), |
|
| 1066 | + $per_page = 10, |
|
| 1067 | + $count = false |
|
| 1068 | + ) { |
|
| 1069 | + |
|
| 1070 | + $query_params = array( |
|
| 1071 | + 0 => $this->_get_where_conditions_for_registrations_query( |
|
| 1072 | + $request |
|
| 1073 | + ), |
|
| 1074 | + 'caps' => EEM_Registration::caps_read_admin, |
|
| 1075 | + 'default_where_conditions' => 'this_model_only', |
|
| 1076 | + ); |
|
| 1077 | + if (! $count) { |
|
| 1078 | + $query_params = array_merge( |
|
| 1079 | + $query_params, |
|
| 1080 | + $this->_get_orderby_for_registrations_query(), |
|
| 1081 | + $this->_get_limit($per_page) |
|
| 1082 | + ); |
|
| 1083 | + } |
|
| 1084 | + |
|
| 1085 | + return $query_params; |
|
| 1086 | + } |
|
| 1087 | + |
|
| 1088 | + |
|
| 1089 | + /** |
|
| 1090 | + * This will add EVT_ID to the provided $where array for EE model query parameters. |
|
| 1091 | + * |
|
| 1092 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1093 | + * @return array |
|
| 1094 | + */ |
|
| 1095 | + protected function _add_event_id_to_where_conditions(array $request) |
|
| 1096 | + { |
|
| 1097 | + $where = array(); |
|
| 1098 | + if (! empty($request['event_id'])) { |
|
| 1099 | + $where['EVT_ID'] = absint($request['event_id']); |
|
| 1100 | + } |
|
| 1101 | + return $where; |
|
| 1102 | + } |
|
| 1103 | + |
|
| 1104 | + |
|
| 1105 | + /** |
|
| 1106 | + * Adds category ID if it exists in the request to the where conditions for the registrations query. |
|
| 1107 | + * |
|
| 1108 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1109 | + * @return array |
|
| 1110 | + */ |
|
| 1111 | + protected function _add_category_id_to_where_conditions(array $request) |
|
| 1112 | + { |
|
| 1113 | + $where = array(); |
|
| 1114 | + if (! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) { |
|
| 1115 | + $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']); |
|
| 1116 | + } |
|
| 1117 | + return $where; |
|
| 1118 | + } |
|
| 1119 | + |
|
| 1120 | + |
|
| 1121 | + /** |
|
| 1122 | + * Adds the datetime ID if it exists in the request to the where conditions for the registrations query. |
|
| 1123 | + * |
|
| 1124 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1125 | + * @return array |
|
| 1126 | + */ |
|
| 1127 | + protected function _add_datetime_id_to_where_conditions(array $request) |
|
| 1128 | + { |
|
| 1129 | + $where = array(); |
|
| 1130 | + if (! empty($request['datetime_id'])) { |
|
| 1131 | + $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']); |
|
| 1132 | + } |
|
| 1133 | + if (! empty($request['DTT_ID'])) { |
|
| 1134 | + $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']); |
|
| 1135 | + } |
|
| 1136 | + return $where; |
|
| 1137 | + } |
|
| 1138 | + |
|
| 1139 | + |
|
| 1140 | + /** |
|
| 1141 | + * Adds the correct registration status to the where conditions for the registrations query. |
|
| 1142 | + * |
|
| 1143 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1144 | + * @return array |
|
| 1145 | + */ |
|
| 1146 | + protected function _add_registration_status_to_where_conditions(array $request) |
|
| 1147 | + { |
|
| 1148 | + $where = array(); |
|
| 1149 | + $view = EEH_Array::is_set($request, 'status', ''); |
|
| 1150 | + $registration_status = ! empty($request['_reg_status']) |
|
| 1151 | + ? sanitize_text_field($request['_reg_status']) |
|
| 1152 | + : ''; |
|
| 1153 | + |
|
| 1154 | + /* |
|
| 1155 | 1155 | * If filtering by registration status, then we show registrations matching that status. |
| 1156 | 1156 | * If not filtering by specified status, then we show all registrations excluding incomplete registrations |
| 1157 | 1157 | * UNLESS viewing trashed registrations. |
| 1158 | 1158 | */ |
| 1159 | - if (! empty($registration_status)) { |
|
| 1160 | - $where['STS_ID'] = $registration_status; |
|
| 1161 | - } else { |
|
| 1162 | - //make sure we exclude incomplete registrations, but only if not trashed. |
|
| 1163 | - if ($view === 'trash') { |
|
| 1164 | - $where['REG_deleted'] = true; |
|
| 1165 | - } elseif ($view === 'incomplete') { |
|
| 1166 | - $where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 1167 | - } else { |
|
| 1168 | - $where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 1169 | - } |
|
| 1170 | - } |
|
| 1171 | - return $where; |
|
| 1172 | - } |
|
| 1173 | - |
|
| 1174 | - |
|
| 1175 | - /** |
|
| 1176 | - * Adds any provided date restraints to the where conditions for the registrations query. |
|
| 1177 | - * |
|
| 1178 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1179 | - * @return array |
|
| 1180 | - * @throws EE_Error |
|
| 1181 | - */ |
|
| 1182 | - protected function _add_date_to_where_conditions(array $request) |
|
| 1183 | - { |
|
| 1184 | - $where = array(); |
|
| 1185 | - $view = EEH_Array::is_set($request, 'status', ''); |
|
| 1186 | - $month_range = ! empty($request['month_range']) |
|
| 1187 | - ? sanitize_text_field($request['month_range']) |
|
| 1188 | - : ''; |
|
| 1189 | - $retrieve_for_today = $view === 'today'; |
|
| 1190 | - $retrieve_for_this_month = $view === 'month'; |
|
| 1191 | - |
|
| 1192 | - if ($retrieve_for_today) { |
|
| 1193 | - $now = date('Y-m-d', current_time('timestamp')); |
|
| 1194 | - $where['REG_date'] = array( |
|
| 1195 | - 'BETWEEN', |
|
| 1196 | - array( |
|
| 1197 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1198 | - 'REG_date', |
|
| 1199 | - $now . ' 00:00:00', |
|
| 1200 | - 'Y-m-d H:i:s' |
|
| 1201 | - ), |
|
| 1202 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1203 | - 'REG_date', |
|
| 1204 | - $now . ' 23:59:59', |
|
| 1205 | - 'Y-m-d H:i:s' |
|
| 1206 | - ), |
|
| 1207 | - ), |
|
| 1208 | - ); |
|
| 1209 | - } elseif ($retrieve_for_this_month) { |
|
| 1210 | - $current_year_and_month = date('Y-m', current_time('timestamp')); |
|
| 1211 | - $days_this_month = date('t', current_time('timestamp')); |
|
| 1212 | - $where['REG_date'] = array( |
|
| 1213 | - 'BETWEEN', |
|
| 1214 | - array( |
|
| 1215 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1216 | - 'REG_date', |
|
| 1217 | - $current_year_and_month . '-01 00:00:00', |
|
| 1218 | - 'Y-m-d H:i:s' |
|
| 1219 | - ), |
|
| 1220 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1221 | - 'REG_date', |
|
| 1222 | - $current_year_and_month . '-' . $days_this_month . ' 23:59:59', |
|
| 1223 | - 'Y-m-d H:i:s' |
|
| 1224 | - ), |
|
| 1225 | - ), |
|
| 1226 | - ); |
|
| 1227 | - } elseif ($month_range) { |
|
| 1228 | - $pieces = explode(' ', $month_range, 3); |
|
| 1229 | - $month_requested = ! empty($pieces[0]) |
|
| 1230 | - ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) |
|
| 1231 | - : ''; |
|
| 1232 | - $year_requested = ! empty($pieces[1]) |
|
| 1233 | - ? $pieces[1] |
|
| 1234 | - : ''; |
|
| 1235 | - //if there is not a month or year then we can't go further |
|
| 1236 | - if ($month_requested && $year_requested) { |
|
| 1237 | - $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01')); |
|
| 1238 | - $where['REG_date'] = array( |
|
| 1239 | - 'BETWEEN', |
|
| 1240 | - array( |
|
| 1241 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1242 | - 'REG_date', |
|
| 1243 | - $year_requested . '-' . $month_requested . '-01 00:00:00', |
|
| 1244 | - 'Y-m-d H:i:s' |
|
| 1245 | - ), |
|
| 1246 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1247 | - 'REG_date', |
|
| 1248 | - $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59', |
|
| 1249 | - 'Y-m-d H:i:s' |
|
| 1250 | - ), |
|
| 1251 | - ), |
|
| 1252 | - ); |
|
| 1253 | - } |
|
| 1254 | - } |
|
| 1255 | - return $where; |
|
| 1256 | - } |
|
| 1257 | - |
|
| 1258 | - |
|
| 1259 | - /** |
|
| 1260 | - * Adds any provided search restraints to the where conditions for the registrations query |
|
| 1261 | - * |
|
| 1262 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1263 | - * @return array |
|
| 1264 | - */ |
|
| 1265 | - protected function _add_search_to_where_conditions(array $request) |
|
| 1266 | - { |
|
| 1267 | - $where = array(); |
|
| 1268 | - if (! empty($request['s'])) { |
|
| 1269 | - $search_string = '%' . sanitize_text_field($request['s']) . '%'; |
|
| 1270 | - $where['OR*search_conditions'] = array( |
|
| 1271 | - 'Event.EVT_name' => array('LIKE', $search_string), |
|
| 1272 | - 'Event.EVT_desc' => array('LIKE', $search_string), |
|
| 1273 | - 'Event.EVT_short_desc' => array('LIKE', $search_string), |
|
| 1274 | - 'Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
| 1275 | - 'Attendee.ATT_fname' => array('LIKE', $search_string), |
|
| 1276 | - 'Attendee.ATT_lname' => array('LIKE', $search_string), |
|
| 1277 | - 'Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
| 1278 | - 'Attendee.ATT_email' => array('LIKE', $search_string), |
|
| 1279 | - 'Attendee.ATT_address' => array('LIKE', $search_string), |
|
| 1280 | - 'Attendee.ATT_address2' => array('LIKE', $search_string), |
|
| 1281 | - 'Attendee.ATT_city' => array('LIKE', $search_string), |
|
| 1282 | - 'REG_final_price' => array('LIKE', $search_string), |
|
| 1283 | - 'REG_code' => array('LIKE', $search_string), |
|
| 1284 | - 'REG_count' => array('LIKE', $search_string), |
|
| 1285 | - 'REG_group_size' => array('LIKE', $search_string), |
|
| 1286 | - 'Ticket.TKT_name' => array('LIKE', $search_string), |
|
| 1287 | - 'Ticket.TKT_description' => array('LIKE', $search_string), |
|
| 1288 | - 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string), |
|
| 1289 | - ); |
|
| 1290 | - } |
|
| 1291 | - return $where; |
|
| 1292 | - } |
|
| 1293 | - |
|
| 1294 | - |
|
| 1295 | - /** |
|
| 1296 | - * Sets up the where conditions for the registrations query. |
|
| 1297 | - * |
|
| 1298 | - * @param array $request |
|
| 1299 | - * @return array |
|
| 1300 | - * @throws EE_Error |
|
| 1301 | - */ |
|
| 1302 | - protected function _get_where_conditions_for_registrations_query($request) |
|
| 1303 | - { |
|
| 1304 | - return apply_filters( |
|
| 1305 | - 'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query', |
|
| 1306 | - array_merge( |
|
| 1307 | - $this->_add_event_id_to_where_conditions($request), |
|
| 1308 | - $this->_add_category_id_to_where_conditions($request), |
|
| 1309 | - $this->_add_datetime_id_to_where_conditions($request), |
|
| 1310 | - $this->_add_registration_status_to_where_conditions($request), |
|
| 1311 | - $this->_add_date_to_where_conditions($request), |
|
| 1312 | - $this->_add_search_to_where_conditions($request) |
|
| 1313 | - ), |
|
| 1314 | - $request |
|
| 1315 | - ); |
|
| 1316 | - } |
|
| 1317 | - |
|
| 1318 | - |
|
| 1319 | - /** |
|
| 1320 | - * Sets up the orderby for the registrations query. |
|
| 1321 | - * |
|
| 1322 | - * @return array |
|
| 1323 | - */ |
|
| 1324 | - protected function _get_orderby_for_registrations_query() |
|
| 1325 | - { |
|
| 1326 | - $orderby_field = ! empty($this->_req_data['orderby']) |
|
| 1327 | - ? sanitize_text_field($this->_req_data['orderby']) |
|
| 1328 | - : ''; |
|
| 1329 | - switch ($orderby_field) { |
|
| 1330 | - case '_REG_ID': |
|
| 1331 | - $orderby_field = 'REG_ID'; |
|
| 1332 | - break; |
|
| 1333 | - case '_Reg_status': |
|
| 1334 | - $orderby_field = 'STS_ID'; |
|
| 1335 | - break; |
|
| 1336 | - case 'ATT_fname': |
|
| 1337 | - $orderby_field = array('Attendee.ATT_fname', 'Attendee.ATT_lname'); |
|
| 1338 | - break; |
|
| 1339 | - case 'ATT_lname': |
|
| 1340 | - $orderby_field = array('Attendee.ATT_lname', 'Attendee.ATT_fname'); |
|
| 1341 | - break; |
|
| 1342 | - case 'event_name': |
|
| 1343 | - $orderby_field = 'Event.EVT_name'; |
|
| 1344 | - break; |
|
| 1345 | - case 'DTT_EVT_start': |
|
| 1346 | - $orderby_field = 'Event.Datetime.DTT_EVT_start'; |
|
| 1347 | - break; |
|
| 1348 | - default: //'REG_date' |
|
| 1349 | - $orderby_field = 'REG_date'; |
|
| 1350 | - } |
|
| 1351 | - |
|
| 1352 | - //order |
|
| 1353 | - $order = ! empty($this->_req_data['order']) |
|
| 1354 | - ? sanitize_text_field($this->_req_data['order']) |
|
| 1355 | - : 'DESC'; |
|
| 1356 | - |
|
| 1357 | - //mutate orderby_field |
|
| 1358 | - $orderby_field = array_combine( |
|
| 1359 | - (array) $orderby_field, |
|
| 1360 | - array_fill(0, count($orderby_field), $order) |
|
| 1361 | - ); |
|
| 1362 | - return array('order_by' => $orderby_field); |
|
| 1363 | - } |
|
| 1364 | - |
|
| 1365 | - |
|
| 1366 | - /** |
|
| 1367 | - * Sets up the limit for the registrations query. |
|
| 1368 | - * |
|
| 1369 | - * @param $per_page |
|
| 1370 | - * @return array |
|
| 1371 | - */ |
|
| 1372 | - protected function _get_limit($per_page) |
|
| 1373 | - { |
|
| 1374 | - $current_page = ! empty($this->_req_data['paged']) |
|
| 1375 | - ? absint($this->_req_data['paged']) |
|
| 1376 | - : 1; |
|
| 1377 | - $per_page = ! empty($this->_req_data['perpage']) |
|
| 1378 | - ? $this->_req_data['perpage'] |
|
| 1379 | - : $per_page; |
|
| 1380 | - |
|
| 1381 | - //-1 means return all results so get out if that's set. |
|
| 1382 | - if ((int)$per_page === -1) { |
|
| 1383 | - return array(); |
|
| 1384 | - } |
|
| 1385 | - $per_page = absint($per_page); |
|
| 1386 | - $offset = ($current_page - 1) * $per_page; |
|
| 1387 | - return array('limit' => array($offset, $per_page)); |
|
| 1388 | - } |
|
| 1389 | - |
|
| 1390 | - |
|
| 1391 | - public function get_registration_status_array() |
|
| 1392 | - { |
|
| 1393 | - return self::$_reg_status; |
|
| 1394 | - } |
|
| 1395 | - |
|
| 1396 | - |
|
| 1397 | - |
|
| 1398 | - |
|
| 1399 | - /*************************************** REGISTRATION DETAILS ***************************************/ |
|
| 1400 | - /** |
|
| 1401 | - * generates HTML for the View Registration Details Admin page |
|
| 1402 | - * |
|
| 1403 | - * @access protected |
|
| 1404 | - * @return void |
|
| 1405 | - * @throws DomainException |
|
| 1406 | - * @throws EE_Error |
|
| 1407 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 1408 | - */ |
|
| 1409 | - protected function _registration_details() |
|
| 1410 | - { |
|
| 1411 | - $this->_template_args = array(); |
|
| 1412 | - $this->_set_registration_object(); |
|
| 1413 | - if (is_object($this->_registration)) { |
|
| 1414 | - $transaction = $this->_registration->transaction() |
|
| 1415 | - ? $this->_registration->transaction() |
|
| 1416 | - : EE_Transaction::new_instance(); |
|
| 1417 | - $this->_session = $transaction->session_data(); |
|
| 1418 | - $event_id = $this->_registration->event_ID(); |
|
| 1419 | - $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
|
| 1420 | - $this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso'); |
|
| 1421 | - $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date'); |
|
| 1422 | - $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso'); |
|
| 1423 | - $this->_template_args['grand_total'] = $transaction->total(); |
|
| 1424 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 1425 | - // link back to overview |
|
| 1426 | - $this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
|
| 1427 | - $this->_template_args['registration'] = $this->_registration; |
|
| 1428 | - $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1429 | - array( |
|
| 1430 | - 'action' => 'default', |
|
| 1431 | - 'event_id' => $event_id, |
|
| 1432 | - ), |
|
| 1433 | - REG_ADMIN_URL |
|
| 1434 | - ); |
|
| 1435 | - $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1436 | - array( |
|
| 1437 | - 'action' => 'default', |
|
| 1438 | - 'EVT_ID' => $event_id, |
|
| 1439 | - 'page' => 'espresso_transactions', |
|
| 1440 | - ), |
|
| 1441 | - admin_url('admin.php') |
|
| 1442 | - ); |
|
| 1443 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1444 | - array( |
|
| 1445 | - 'page' => 'espresso_events', |
|
| 1446 | - 'action' => 'edit', |
|
| 1447 | - 'post' => $event_id, |
|
| 1448 | - ), |
|
| 1449 | - admin_url('admin.php') |
|
| 1450 | - ); |
|
| 1451 | - //next and previous links |
|
| 1452 | - $next_reg = $this->_registration->next( |
|
| 1453 | - null, |
|
| 1454 | - array(), |
|
| 1455 | - 'REG_ID' |
|
| 1456 | - ); |
|
| 1457 | - $this->_template_args['next_registration'] = $next_reg |
|
| 1458 | - ? $this->_next_link( |
|
| 1459 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 1460 | - array( |
|
| 1461 | - 'action' => 'view_registration', |
|
| 1462 | - '_REG_ID' => $next_reg['REG_ID'], |
|
| 1463 | - ), |
|
| 1464 | - REG_ADMIN_URL |
|
| 1465 | - ), |
|
| 1466 | - 'dashicons dashicons-arrow-right ee-icon-size-22' |
|
| 1467 | - ) |
|
| 1468 | - : ''; |
|
| 1469 | - $previous_reg = $this->_registration->previous( |
|
| 1470 | - null, |
|
| 1471 | - array(), |
|
| 1472 | - 'REG_ID' |
|
| 1473 | - ); |
|
| 1474 | - $this->_template_args['previous_registration'] = $previous_reg |
|
| 1475 | - ? $this->_previous_link( |
|
| 1476 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 1477 | - array( |
|
| 1478 | - 'action' => 'view_registration', |
|
| 1479 | - '_REG_ID' => $previous_reg['REG_ID'], |
|
| 1480 | - ), |
|
| 1481 | - REG_ADMIN_URL |
|
| 1482 | - ), |
|
| 1483 | - 'dashicons dashicons-arrow-left ee-icon-size-22' |
|
| 1484 | - ) |
|
| 1485 | - : ''; |
|
| 1486 | - // grab header |
|
| 1487 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
| 1488 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1489 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template( |
|
| 1490 | - $template_path, |
|
| 1491 | - $this->_template_args, |
|
| 1492 | - true |
|
| 1493 | - ); |
|
| 1494 | - } else { |
|
| 1495 | - $this->_template_args['admin_page_header'] = $this->display_espresso_notices(); |
|
| 1496 | - } |
|
| 1497 | - // the details template wrapper |
|
| 1498 | - $this->display_admin_page_with_sidebar(); |
|
| 1499 | - } |
|
| 1500 | - |
|
| 1501 | - |
|
| 1502 | - protected function _registration_details_metaboxes() |
|
| 1503 | - { |
|
| 1504 | - do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this); |
|
| 1505 | - $this->_set_registration_object(); |
|
| 1506 | - $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
|
| 1507 | - add_meta_box('edit-reg-status-mbox', esc_html__('Registration Status', 'event_espresso'), |
|
| 1508 | - array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1509 | - add_meta_box('edit-reg-details-mbox', esc_html__('Registration Details', 'event_espresso'), |
|
| 1510 | - array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1511 | - if ($attendee instanceof EE_Attendee |
|
| 1512 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 1513 | - 'ee_edit_registration', |
|
| 1514 | - 'edit-reg-questions-mbox' |
|
| 1515 | - ) |
|
| 1516 | - ) { |
|
| 1517 | - add_meta_box( |
|
| 1518 | - 'edit-reg-questions-mbox', |
|
| 1519 | - esc_html__('Registration Form Answers', 'event_espresso'), |
|
| 1520 | - array($this, '_reg_questions_meta_box'), |
|
| 1521 | - $this->wp_page_slug, |
|
| 1522 | - 'normal', |
|
| 1523 | - 'high' |
|
| 1524 | - ); |
|
| 1525 | - } |
|
| 1526 | - add_meta_box( |
|
| 1527 | - 'edit-reg-registrant-mbox', |
|
| 1528 | - esc_html__('Contact Details', 'event_espresso'), |
|
| 1529 | - array($this, '_reg_registrant_side_meta_box'), |
|
| 1530 | - $this->wp_page_slug, |
|
| 1531 | - 'side', |
|
| 1532 | - 'high' |
|
| 1533 | - ); |
|
| 1534 | - if ($this->_registration->group_size() > 1) { |
|
| 1535 | - add_meta_box( |
|
| 1536 | - 'edit-reg-attendees-mbox', |
|
| 1537 | - esc_html__('Other Registrations in this Transaction', 'event_espresso'), |
|
| 1538 | - array($this, '_reg_attendees_meta_box'), |
|
| 1539 | - $this->wp_page_slug, |
|
| 1540 | - 'normal', |
|
| 1541 | - 'high' |
|
| 1542 | - ); |
|
| 1543 | - } |
|
| 1544 | - } |
|
| 1545 | - |
|
| 1546 | - |
|
| 1547 | - /** |
|
| 1548 | - * set_reg_status_buttons_metabox |
|
| 1549 | - * |
|
| 1550 | - * @access protected |
|
| 1551 | - * @return string |
|
| 1552 | - * @throws \EE_Error |
|
| 1553 | - */ |
|
| 1554 | - public function set_reg_status_buttons_metabox() |
|
| 1555 | - { |
|
| 1556 | - $this->_set_registration_object(); |
|
| 1557 | - $change_reg_status_form = $this->_generate_reg_status_change_form(); |
|
| 1558 | - echo $change_reg_status_form->form_open( |
|
| 1559 | - self::add_query_args_and_nonce( |
|
| 1560 | - array( |
|
| 1561 | - 'action' => 'change_reg_status', |
|
| 1562 | - ), |
|
| 1563 | - REG_ADMIN_URL |
|
| 1564 | - ) |
|
| 1565 | - ); |
|
| 1566 | - echo $change_reg_status_form->get_html(); |
|
| 1567 | - echo $change_reg_status_form->form_close(); |
|
| 1568 | - } |
|
| 1569 | - |
|
| 1570 | - |
|
| 1571 | - /** |
|
| 1572 | - * @return EE_Form_Section_Proper |
|
| 1573 | - * @throws EE_Error |
|
| 1574 | - */ |
|
| 1575 | - protected function _generate_reg_status_change_form() |
|
| 1576 | - { |
|
| 1577 | - return new EE_Form_Section_Proper(array( |
|
| 1578 | - 'name' => 'reg_status_change_form', |
|
| 1579 | - 'html_id' => 'reg-status-change-form', |
|
| 1580 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 1581 | - 'subsections' => array( |
|
| 1582 | - 'return' => new EE_Hidden_Input(array( |
|
| 1583 | - 'name' => 'return', |
|
| 1584 | - 'default' => 'view_registration', |
|
| 1585 | - )), |
|
| 1586 | - 'REG_ID' => new EE_Hidden_Input(array( |
|
| 1587 | - 'name' => 'REG_ID', |
|
| 1588 | - 'default' => $this->_registration->ID(), |
|
| 1589 | - )), |
|
| 1590 | - 'current_status' => new EE_Form_Section_HTML( |
|
| 1591 | - EEH_HTML::tr( |
|
| 1592 | - EEH_HTML::th( |
|
| 1593 | - EEH_HTML::label( |
|
| 1594 | - EEH_HTML::strong(esc_html__('Current Registration Status', 'event_espresso') |
|
| 1595 | - ) |
|
| 1596 | - ) |
|
| 1597 | - ) |
|
| 1598 | - . EEH_HTML::td( |
|
| 1599 | - EEH_HTML::strong( |
|
| 1600 | - $this->_registration->pretty_status(), |
|
| 1601 | - '', |
|
| 1602 | - 'status-' . $this->_registration->status_ID(), |
|
| 1603 | - 'line-height: 1em; font-size: 1.5em; font-weight: bold;' |
|
| 1604 | - ) |
|
| 1605 | - ) |
|
| 1606 | - ) |
|
| 1607 | - ), |
|
| 1608 | - 'reg_status' => new EE_Select_Input( |
|
| 1609 | - $this->_get_reg_statuses(), |
|
| 1610 | - array( |
|
| 1611 | - 'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'), |
|
| 1612 | - 'default' => $this->_registration->status_ID(), |
|
| 1613 | - ) |
|
| 1614 | - ), |
|
| 1615 | - 'send_notifications' => new EE_Yes_No_Input( |
|
| 1616 | - array( |
|
| 1617 | - 'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'), |
|
| 1618 | - 'default' => false, |
|
| 1619 | - 'html_help_text' => esc_html__( |
|
| 1620 | - 'If set to "Yes", then the related messages will be sent to the registrant.', |
|
| 1621 | - 'event_espresso' |
|
| 1622 | - ), |
|
| 1623 | - ) |
|
| 1624 | - ), |
|
| 1625 | - 'submit' => new EE_Submit_Input( |
|
| 1626 | - array( |
|
| 1627 | - 'html_class' => 'button-primary', |
|
| 1628 | - 'html_label_text' => ' ', |
|
| 1629 | - 'default' => esc_html__('Update Registration Status', 'event_espresso'), |
|
| 1630 | - ) |
|
| 1631 | - ), |
|
| 1632 | - ), |
|
| 1633 | - )); |
|
| 1634 | - } |
|
| 1635 | - |
|
| 1636 | - |
|
| 1637 | - /** |
|
| 1638 | - * Returns an array of all the buttons for the various statuses and switch status actions |
|
| 1639 | - * |
|
| 1640 | - * @return array |
|
| 1641 | - * @throws EE_Error |
|
| 1642 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 1643 | - */ |
|
| 1644 | - protected function _get_reg_statuses() |
|
| 1645 | - { |
|
| 1646 | - $reg_status_array = EEM_Registration::instance()->reg_status_array(); |
|
| 1647 | - unset ($reg_status_array[EEM_Registration::status_id_incomplete]); |
|
| 1648 | - // get current reg status |
|
| 1649 | - $current_status = $this->_registration->status_ID(); |
|
| 1650 | - // is registration for free event? This will determine whether to display the pending payment option |
|
| 1651 | - if ($current_status != EEM_Registration::status_id_pending_payment |
|
| 1652 | - && $this->_registration->transaction() |
|
| 1653 | - ->is_free() |
|
| 1654 | - ) { |
|
| 1655 | - unset($reg_status_array[EEM_Registration::status_id_pending_payment]); |
|
| 1656 | - } |
|
| 1657 | - return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence'); |
|
| 1658 | - } |
|
| 1659 | - |
|
| 1660 | - |
|
| 1661 | - /** |
|
| 1662 | - * This method is used when using _REG_ID from request which may or may not be an array of reg_ids. |
|
| 1663 | - * |
|
| 1664 | - * @param bool $status REG status given for changing registrations to. |
|
| 1665 | - * @param bool $notify Whether to send messages notifications or not. |
|
| 1666 | - * @return array (array with reg_id(s) updated and whether update was successful. |
|
| 1667 | - */ |
|
| 1668 | - protected function _set_registration_status_from_request($status = false, $notify = false) |
|
| 1669 | - { |
|
| 1670 | - if (isset($this->_req_data['reg_status_change_form'])) { |
|
| 1671 | - $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
|
| 1672 | - ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
| 1673 | - } else { |
|
| 1674 | - $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array(); |
|
| 1675 | - } |
|
| 1676 | - $success = $this->_set_registration_status($REG_IDs, $status); |
|
| 1677 | - //notify? |
|
| 1678 | - if ($success |
|
| 1679 | - && $notify |
|
| 1680 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 1681 | - 'ee_send_message', |
|
| 1682 | - 'espresso_registrations_resend_registration' |
|
| 1683 | - ) |
|
| 1684 | - ) { |
|
| 1685 | - $this->_process_resend_registration(); |
|
| 1686 | - } |
|
| 1687 | - return $success; |
|
| 1688 | - } |
|
| 1689 | - |
|
| 1690 | - |
|
| 1691 | - /** |
|
| 1692 | - * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an |
|
| 1693 | - * array). Note, this method does NOT take care of possible notifications. That is required by calling code. |
|
| 1694 | - * |
|
| 1695 | - * @param array $REG_IDs |
|
| 1696 | - * @param bool $status |
|
| 1697 | - * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as |
|
| 1698 | - * the array of updated registrations). |
|
| 1699 | - * @throws EE_Error |
|
| 1700 | - * @throws RuntimeException |
|
| 1701 | - */ |
|
| 1702 | - protected function _set_registration_status($REG_IDs = array(), $status = false) |
|
| 1703 | - { |
|
| 1704 | - $success = false; |
|
| 1705 | - // typecast $REG_IDs |
|
| 1706 | - $REG_IDs = (array)$REG_IDs; |
|
| 1707 | - if ( ! empty($REG_IDs)) { |
|
| 1708 | - $success = true; |
|
| 1709 | - // set default status if none is passed |
|
| 1710 | - $status = $status ? $status : EEM_Registration::status_id_pending_payment; |
|
| 1711 | - // sanitize $REG_IDs |
|
| 1712 | - $REG_IDs = array_filter($REG_IDs, 'absint'); |
|
| 1713 | - //loop through REG_ID's and change status |
|
| 1714 | - foreach ($REG_IDs as $REG_ID) { |
|
| 1715 | - $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 1716 | - if ($registration instanceof EE_Registration) { |
|
| 1717 | - $registration->set_status($status); |
|
| 1718 | - $result = $registration->save(); |
|
| 1719 | - // verifying explicit fails because update *may* just return 0 for 0 rows affected |
|
| 1720 | - $success = $result !== false ? $success : false; |
|
| 1721 | - } |
|
| 1722 | - } |
|
| 1723 | - } |
|
| 1724 | - //reset _req_data['_REG_ID'] for any potential future messages notifications |
|
| 1725 | - $this->_req_data['_REG_ID'] = $REG_IDs; |
|
| 1726 | - //return $success and processed registrations |
|
| 1727 | - return array('REG_ID' => $REG_IDs, 'success' => $success); |
|
| 1728 | - } |
|
| 1729 | - |
|
| 1730 | - |
|
| 1731 | - /** |
|
| 1732 | - * Common logic for setting up success message and redirecting to appropriate route |
|
| 1733 | - * |
|
| 1734 | - * @param string $STS_ID status id for the registration changed to |
|
| 1735 | - * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
|
| 1736 | - * @return void |
|
| 1737 | - */ |
|
| 1738 | - protected function _reg_status_change_return($STS_ID, $notify = false) |
|
| 1739 | - { |
|
| 1740 | - $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify) |
|
| 1741 | - : array('success' => false); |
|
| 1742 | - $success = isset($result['success']) && $result['success']; |
|
| 1743 | - //setup success message |
|
| 1744 | - if ($success) { |
|
| 1745 | - if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) { |
|
| 1746 | - $msg = sprintf(esc_html__('Registration status has been set to %s', 'event_espresso'), |
|
| 1747 | - EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1748 | - } else { |
|
| 1749 | - $msg = sprintf(esc_html__('Registrations have been set to %s.', 'event_espresso'), |
|
| 1750 | - EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1751 | - } |
|
| 1752 | - EE_Error::add_success($msg); |
|
| 1753 | - } else { |
|
| 1754 | - EE_Error::add_error( |
|
| 1755 | - esc_html__( |
|
| 1756 | - 'Something went wrong, and the status was not changed', |
|
| 1757 | - 'event_espresso' |
|
| 1758 | - ), __FILE__, __LINE__, __FUNCTION__ |
|
| 1759 | - ); |
|
| 1760 | - } |
|
| 1761 | - if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') { |
|
| 1762 | - $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])); |
|
| 1763 | - } else { |
|
| 1764 | - $route = array('action' => 'default'); |
|
| 1765 | - } |
|
| 1766 | - //unset nonces |
|
| 1767 | - foreach ($this->_req_data as $ref => $value) { |
|
| 1768 | - if (strpos($ref, 'nonce') !== false) { |
|
| 1769 | - unset($this->_req_data[$ref]); |
|
| 1770 | - continue; |
|
| 1771 | - } |
|
| 1772 | - $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value); |
|
| 1773 | - $this->_req_data[$ref] = $value; |
|
| 1774 | - } |
|
| 1775 | - //merge request vars so that the reloaded list table contains any existing filter query params |
|
| 1776 | - $route = array_merge($this->_req_data, $route); |
|
| 1777 | - $this->_redirect_after_action($success, '', '', $route, true); |
|
| 1778 | - } |
|
| 1779 | - |
|
| 1780 | - |
|
| 1781 | - /** |
|
| 1782 | - * incoming reg status change from reg details page. |
|
| 1783 | - * |
|
| 1784 | - * @return void |
|
| 1785 | - */ |
|
| 1786 | - protected function _change_reg_status() |
|
| 1787 | - { |
|
| 1788 | - $this->_req_data['return'] = 'view_registration'; |
|
| 1789 | - //set notify based on whether the send notifications toggle is set or not |
|
| 1790 | - $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']); |
|
| 1791 | - //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
|
| 1792 | - $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status']) |
|
| 1793 | - ? $this->_req_data['reg_status_change_form']['reg_status'] : ''; |
|
| 1794 | - switch ($this->_req_data['reg_status_change_form']['reg_status']) { |
|
| 1795 | - case EEM_Registration::status_id_approved : |
|
| 1796 | - case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') : |
|
| 1797 | - $this->approve_registration($notify); |
|
| 1798 | - break; |
|
| 1799 | - case EEM_Registration::status_id_pending_payment : |
|
| 1800 | - case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') : |
|
| 1801 | - $this->pending_registration($notify); |
|
| 1802 | - break; |
|
| 1803 | - case EEM_Registration::status_id_not_approved : |
|
| 1804 | - case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') : |
|
| 1805 | - $this->not_approve_registration($notify); |
|
| 1806 | - break; |
|
| 1807 | - case EEM_Registration::status_id_declined : |
|
| 1808 | - case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') : |
|
| 1809 | - $this->decline_registration($notify); |
|
| 1810 | - break; |
|
| 1811 | - case EEM_Registration::status_id_cancelled : |
|
| 1812 | - case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') : |
|
| 1813 | - $this->cancel_registration($notify); |
|
| 1814 | - break; |
|
| 1815 | - case EEM_Registration::status_id_wait_list : |
|
| 1816 | - case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') : |
|
| 1817 | - $this->waitlist_registration($notify); |
|
| 1818 | - break; |
|
| 1819 | - case EEM_Registration::status_id_incomplete : |
|
| 1820 | - default : |
|
| 1821 | - $result['success'] = false; |
|
| 1822 | - unset($this->_req_data['return']); |
|
| 1823 | - $this->_reg_status_change_return('', false); |
|
| 1824 | - break; |
|
| 1825 | - } |
|
| 1826 | - } |
|
| 1827 | - |
|
| 1828 | - |
|
| 1829 | - /** |
|
| 1830 | - * approve_registration |
|
| 1831 | - * |
|
| 1832 | - * @access protected |
|
| 1833 | - * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1834 | - * @return void |
|
| 1835 | - */ |
|
| 1836 | - protected function approve_registration($notify = false) |
|
| 1837 | - { |
|
| 1838 | - $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify); |
|
| 1839 | - } |
|
| 1840 | - |
|
| 1841 | - |
|
| 1842 | - /** |
|
| 1843 | - * decline_registration |
|
| 1844 | - * |
|
| 1845 | - * @access protected |
|
| 1846 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1847 | - * @return void |
|
| 1848 | - */ |
|
| 1849 | - protected function decline_registration($notify = false) |
|
| 1850 | - { |
|
| 1851 | - $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify); |
|
| 1852 | - } |
|
| 1853 | - |
|
| 1854 | - |
|
| 1855 | - /** |
|
| 1856 | - * cancel_registration |
|
| 1857 | - * |
|
| 1858 | - * @access protected |
|
| 1859 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1860 | - * @return void |
|
| 1861 | - */ |
|
| 1862 | - protected function cancel_registration($notify = false) |
|
| 1863 | - { |
|
| 1864 | - $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify); |
|
| 1865 | - } |
|
| 1866 | - |
|
| 1867 | - |
|
| 1868 | - /** |
|
| 1869 | - * not_approve_registration |
|
| 1870 | - * |
|
| 1871 | - * @access protected |
|
| 1872 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1873 | - * @return void |
|
| 1874 | - */ |
|
| 1875 | - protected function not_approve_registration($notify = false) |
|
| 1876 | - { |
|
| 1877 | - $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify); |
|
| 1878 | - } |
|
| 1879 | - |
|
| 1880 | - |
|
| 1881 | - /** |
|
| 1882 | - * decline_registration |
|
| 1883 | - * |
|
| 1884 | - * @access protected |
|
| 1885 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1886 | - * @return void |
|
| 1887 | - */ |
|
| 1888 | - protected function pending_registration($notify = false) |
|
| 1889 | - { |
|
| 1890 | - $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify); |
|
| 1891 | - } |
|
| 1892 | - |
|
| 1893 | - |
|
| 1894 | - /** |
|
| 1895 | - * waitlist_registration |
|
| 1896 | - * |
|
| 1897 | - * @access protected |
|
| 1898 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1899 | - * @return void |
|
| 1900 | - */ |
|
| 1901 | - protected function waitlist_registration($notify = false) |
|
| 1902 | - { |
|
| 1903 | - $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify); |
|
| 1904 | - } |
|
| 1905 | - |
|
| 1906 | - |
|
| 1907 | - /** |
|
| 1908 | - * generates HTML for the Registration main meta box |
|
| 1909 | - * |
|
| 1910 | - * @access public |
|
| 1911 | - * @return void |
|
| 1912 | - * @throws DomainException |
|
| 1913 | - * @throws EE_Error |
|
| 1914 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 1915 | - */ |
|
| 1916 | - public function _reg_details_meta_box() |
|
| 1917 | - { |
|
| 1918 | - EEH_Autoloader::register_line_item_display_autoloaders(); |
|
| 1919 | - EEH_Autoloader::register_line_item_filter_autoloaders(); |
|
| 1920 | - EE_Registry::instance()->load_helper('Line_Item'); |
|
| 1921 | - $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
| 1922 | - : EE_Transaction::new_instance(); |
|
| 1923 | - $this->_session = $transaction->session_data(); |
|
| 1924 | - $filters = new EE_Line_Item_Filter_Collection(); |
|
| 1925 | - //$filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
| 1926 | - $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration)); |
|
| 1927 | - $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, |
|
| 1928 | - $transaction->total_line_item()); |
|
| 1929 | - $filtered_line_item_tree = $line_item_filter_processor->process(); |
|
| 1930 | - $line_item_display = new EE_Line_Item_Display('reg_admin_table', |
|
| 1931 | - 'EE_Admin_Table_Registration_Line_Item_Display_Strategy'); |
|
| 1932 | - $this->_template_args['line_item_table'] = $line_item_display->display_line_item( |
|
| 1933 | - $filtered_line_item_tree, |
|
| 1934 | - array('EE_Registration' => $this->_registration) |
|
| 1935 | - ); |
|
| 1936 | - $attendee = $this->_registration->attendee(); |
|
| 1937 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 1938 | - 'ee_read_transaction', |
|
| 1939 | - 'espresso_transactions_view_transaction' |
|
| 1940 | - )) { |
|
| 1941 | - $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link( |
|
| 1942 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 1943 | - array( |
|
| 1944 | - 'action' => 'view_transaction', |
|
| 1945 | - 'TXN_ID' => $transaction->ID(), |
|
| 1946 | - ), |
|
| 1947 | - TXN_ADMIN_URL |
|
| 1948 | - ), |
|
| 1949 | - esc_html__(' View Transaction', 'event_espresso'), |
|
| 1950 | - 'button secondary-button right', |
|
| 1951 | - 'dashicons dashicons-cart' |
|
| 1952 | - ); |
|
| 1953 | - } else { |
|
| 1954 | - $this->_template_args['view_transaction_button'] = ''; |
|
| 1955 | - } |
|
| 1956 | - if ($attendee instanceof EE_Attendee |
|
| 1957 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 1958 | - 'ee_send_message', |
|
| 1959 | - 'espresso_registrations_resend_registration' |
|
| 1960 | - ) |
|
| 1961 | - ) { |
|
| 1962 | - $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link( |
|
| 1963 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 1964 | - array( |
|
| 1965 | - 'action' => 'resend_registration', |
|
| 1966 | - '_REG_ID' => $this->_registration->ID(), |
|
| 1967 | - 'redirect_to' => 'view_registration', |
|
| 1968 | - ), |
|
| 1969 | - REG_ADMIN_URL |
|
| 1970 | - ), |
|
| 1971 | - esc_html__(' Resend Registration', 'event_espresso'), |
|
| 1972 | - 'button secondary-button right', |
|
| 1973 | - 'dashicons dashicons-email-alt' |
|
| 1974 | - ); |
|
| 1975 | - } else { |
|
| 1976 | - $this->_template_args['resend_registration_button'] = ''; |
|
| 1977 | - } |
|
| 1978 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 1979 | - $payment = $transaction->get_first_related('Payment'); |
|
| 1980 | - $payment = ! $payment instanceof EE_Payment |
|
| 1981 | - ? EE_Payment::new_instance() |
|
| 1982 | - : $payment; |
|
| 1983 | - $payment_method = $payment->get_first_related('Payment_Method'); |
|
| 1984 | - $payment_method = ! $payment_method instanceof EE_Payment_Method |
|
| 1985 | - ? EE_Payment_Method::new_instance() |
|
| 1986 | - : $payment_method; |
|
| 1987 | - $reg_details = array( |
|
| 1988 | - 'payment_method' => $payment_method->name(), |
|
| 1989 | - 'response_msg' => $payment->gateway_response(), |
|
| 1990 | - 'registration_id' => $this->_registration->get('REG_code'), |
|
| 1991 | - 'registration_session' => $this->_registration->session_ID(), |
|
| 1992 | - 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', |
|
| 1993 | - 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '', |
|
| 1994 | - ); |
|
| 1995 | - if (isset($reg_details['registration_id'])) { |
|
| 1996 | - $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
|
| 1997 | - $this->_template_args['reg_details']['registration_id']['label'] = esc_html__( |
|
| 1998 | - 'Registration ID', |
|
| 1999 | - 'event_espresso' |
|
| 2000 | - ); |
|
| 2001 | - $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
|
| 2002 | - } |
|
| 2003 | - if (isset($reg_details['payment_method'])) { |
|
| 2004 | - $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
|
| 2005 | - $this->_template_args['reg_details']['payment_method']['label'] = esc_html__( |
|
| 2006 | - 'Most Recent Payment Method', |
|
| 2007 | - 'event_espresso' |
|
| 2008 | - ); |
|
| 2009 | - $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
|
| 2010 | - $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
|
| 2011 | - $this->_template_args['reg_details']['response_msg']['label'] = esc_html__( |
|
| 2012 | - 'Payment method response', |
|
| 2013 | - 'event_espresso' |
|
| 2014 | - ); |
|
| 2015 | - $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
|
| 2016 | - } |
|
| 2017 | - $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
|
| 2018 | - $this->_template_args['reg_details']['registration_session']['label'] = esc_html__( |
|
| 2019 | - 'Registration Session', |
|
| 2020 | - 'event_espresso' |
|
| 2021 | - ); |
|
| 2022 | - $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
|
| 2023 | - $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
|
| 2024 | - $this->_template_args['reg_details']['ip_address']['label'] = esc_html__( |
|
| 2025 | - 'Registration placed from IP', |
|
| 2026 | - 'event_espresso' |
|
| 2027 | - ); |
|
| 2028 | - $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
|
| 2029 | - $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
|
| 2030 | - $this->_template_args['reg_details']['user_agent']['label'] = esc_html__('Registrant User Agent', |
|
| 2031 | - 'event_espresso'); |
|
| 2032 | - $this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
|
| 2033 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 2034 | - array( |
|
| 2035 | - 'action' => 'default', |
|
| 2036 | - 'event_id' => $this->_registration->event_ID(), |
|
| 2037 | - ), |
|
| 2038 | - REG_ADMIN_URL |
|
| 2039 | - ); |
|
| 2040 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 2041 | - $this->_template_args['event_id'] = $this->_registration->event_ID(); |
|
| 2042 | - $template_path = |
|
| 2043 | - REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 2044 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2045 | - } |
|
| 2046 | - |
|
| 2047 | - |
|
| 2048 | - /** |
|
| 2049 | - * generates HTML for the Registration Questions meta box. |
|
| 2050 | - * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters), |
|
| 2051 | - * otherwise uses new forms system |
|
| 2052 | - * |
|
| 2053 | - * @access public |
|
| 2054 | - * @return void |
|
| 2055 | - * @throws DomainException |
|
| 2056 | - * @throws EE_Error |
|
| 2057 | - */ |
|
| 2058 | - public function _reg_questions_meta_box() |
|
| 2059 | - { |
|
| 2060 | - //allow someone to override this method entirely |
|
| 2061 | - if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, |
|
| 2062 | - $this->_registration)) { |
|
| 2063 | - $form = $this->_get_reg_custom_questions_form( |
|
| 2064 | - $this->_registration->ID() |
|
| 2065 | - ); |
|
| 2066 | - $this->_template_args['att_questions'] = count($form->subforms()) > 0 |
|
| 2067 | - ? $form->get_html_and_js() |
|
| 2068 | - : ''; |
|
| 2069 | - $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
|
| 2070 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 2071 | - $template_path = |
|
| 2072 | - REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 2073 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2074 | - } |
|
| 2075 | - } |
|
| 2076 | - |
|
| 2077 | - |
|
| 2078 | - /** |
|
| 2079 | - * form_before_question_group |
|
| 2080 | - * |
|
| 2081 | - * @deprecated as of 4.8.32.rc.000 |
|
| 2082 | - * @access public |
|
| 2083 | - * @param string $output |
|
| 2084 | - * @return string |
|
| 2085 | - */ |
|
| 2086 | - public function form_before_question_group($output) |
|
| 2087 | - { |
|
| 2088 | - EE_Error::doing_it_wrong( |
|
| 2089 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2090 | - esc_html__( |
|
| 2091 | - 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2092 | - 'event_espresso' |
|
| 2093 | - ), |
|
| 2094 | - '4.8.32.rc.000' |
|
| 2095 | - ); |
|
| 2096 | - return ' |
|
| 1159 | + if (! empty($registration_status)) { |
|
| 1160 | + $where['STS_ID'] = $registration_status; |
|
| 1161 | + } else { |
|
| 1162 | + //make sure we exclude incomplete registrations, but only if not trashed. |
|
| 1163 | + if ($view === 'trash') { |
|
| 1164 | + $where['REG_deleted'] = true; |
|
| 1165 | + } elseif ($view === 'incomplete') { |
|
| 1166 | + $where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 1167 | + } else { |
|
| 1168 | + $where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 1169 | + } |
|
| 1170 | + } |
|
| 1171 | + return $where; |
|
| 1172 | + } |
|
| 1173 | + |
|
| 1174 | + |
|
| 1175 | + /** |
|
| 1176 | + * Adds any provided date restraints to the where conditions for the registrations query. |
|
| 1177 | + * |
|
| 1178 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1179 | + * @return array |
|
| 1180 | + * @throws EE_Error |
|
| 1181 | + */ |
|
| 1182 | + protected function _add_date_to_where_conditions(array $request) |
|
| 1183 | + { |
|
| 1184 | + $where = array(); |
|
| 1185 | + $view = EEH_Array::is_set($request, 'status', ''); |
|
| 1186 | + $month_range = ! empty($request['month_range']) |
|
| 1187 | + ? sanitize_text_field($request['month_range']) |
|
| 1188 | + : ''; |
|
| 1189 | + $retrieve_for_today = $view === 'today'; |
|
| 1190 | + $retrieve_for_this_month = $view === 'month'; |
|
| 1191 | + |
|
| 1192 | + if ($retrieve_for_today) { |
|
| 1193 | + $now = date('Y-m-d', current_time('timestamp')); |
|
| 1194 | + $where['REG_date'] = array( |
|
| 1195 | + 'BETWEEN', |
|
| 1196 | + array( |
|
| 1197 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1198 | + 'REG_date', |
|
| 1199 | + $now . ' 00:00:00', |
|
| 1200 | + 'Y-m-d H:i:s' |
|
| 1201 | + ), |
|
| 1202 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1203 | + 'REG_date', |
|
| 1204 | + $now . ' 23:59:59', |
|
| 1205 | + 'Y-m-d H:i:s' |
|
| 1206 | + ), |
|
| 1207 | + ), |
|
| 1208 | + ); |
|
| 1209 | + } elseif ($retrieve_for_this_month) { |
|
| 1210 | + $current_year_and_month = date('Y-m', current_time('timestamp')); |
|
| 1211 | + $days_this_month = date('t', current_time('timestamp')); |
|
| 1212 | + $where['REG_date'] = array( |
|
| 1213 | + 'BETWEEN', |
|
| 1214 | + array( |
|
| 1215 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1216 | + 'REG_date', |
|
| 1217 | + $current_year_and_month . '-01 00:00:00', |
|
| 1218 | + 'Y-m-d H:i:s' |
|
| 1219 | + ), |
|
| 1220 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1221 | + 'REG_date', |
|
| 1222 | + $current_year_and_month . '-' . $days_this_month . ' 23:59:59', |
|
| 1223 | + 'Y-m-d H:i:s' |
|
| 1224 | + ), |
|
| 1225 | + ), |
|
| 1226 | + ); |
|
| 1227 | + } elseif ($month_range) { |
|
| 1228 | + $pieces = explode(' ', $month_range, 3); |
|
| 1229 | + $month_requested = ! empty($pieces[0]) |
|
| 1230 | + ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) |
|
| 1231 | + : ''; |
|
| 1232 | + $year_requested = ! empty($pieces[1]) |
|
| 1233 | + ? $pieces[1] |
|
| 1234 | + : ''; |
|
| 1235 | + //if there is not a month or year then we can't go further |
|
| 1236 | + if ($month_requested && $year_requested) { |
|
| 1237 | + $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01')); |
|
| 1238 | + $where['REG_date'] = array( |
|
| 1239 | + 'BETWEEN', |
|
| 1240 | + array( |
|
| 1241 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1242 | + 'REG_date', |
|
| 1243 | + $year_requested . '-' . $month_requested . '-01 00:00:00', |
|
| 1244 | + 'Y-m-d H:i:s' |
|
| 1245 | + ), |
|
| 1246 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1247 | + 'REG_date', |
|
| 1248 | + $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59', |
|
| 1249 | + 'Y-m-d H:i:s' |
|
| 1250 | + ), |
|
| 1251 | + ), |
|
| 1252 | + ); |
|
| 1253 | + } |
|
| 1254 | + } |
|
| 1255 | + return $where; |
|
| 1256 | + } |
|
| 1257 | + |
|
| 1258 | + |
|
| 1259 | + /** |
|
| 1260 | + * Adds any provided search restraints to the where conditions for the registrations query |
|
| 1261 | + * |
|
| 1262 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1263 | + * @return array |
|
| 1264 | + */ |
|
| 1265 | + protected function _add_search_to_where_conditions(array $request) |
|
| 1266 | + { |
|
| 1267 | + $where = array(); |
|
| 1268 | + if (! empty($request['s'])) { |
|
| 1269 | + $search_string = '%' . sanitize_text_field($request['s']) . '%'; |
|
| 1270 | + $where['OR*search_conditions'] = array( |
|
| 1271 | + 'Event.EVT_name' => array('LIKE', $search_string), |
|
| 1272 | + 'Event.EVT_desc' => array('LIKE', $search_string), |
|
| 1273 | + 'Event.EVT_short_desc' => array('LIKE', $search_string), |
|
| 1274 | + 'Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
| 1275 | + 'Attendee.ATT_fname' => array('LIKE', $search_string), |
|
| 1276 | + 'Attendee.ATT_lname' => array('LIKE', $search_string), |
|
| 1277 | + 'Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
| 1278 | + 'Attendee.ATT_email' => array('LIKE', $search_string), |
|
| 1279 | + 'Attendee.ATT_address' => array('LIKE', $search_string), |
|
| 1280 | + 'Attendee.ATT_address2' => array('LIKE', $search_string), |
|
| 1281 | + 'Attendee.ATT_city' => array('LIKE', $search_string), |
|
| 1282 | + 'REG_final_price' => array('LIKE', $search_string), |
|
| 1283 | + 'REG_code' => array('LIKE', $search_string), |
|
| 1284 | + 'REG_count' => array('LIKE', $search_string), |
|
| 1285 | + 'REG_group_size' => array('LIKE', $search_string), |
|
| 1286 | + 'Ticket.TKT_name' => array('LIKE', $search_string), |
|
| 1287 | + 'Ticket.TKT_description' => array('LIKE', $search_string), |
|
| 1288 | + 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string), |
|
| 1289 | + ); |
|
| 1290 | + } |
|
| 1291 | + return $where; |
|
| 1292 | + } |
|
| 1293 | + |
|
| 1294 | + |
|
| 1295 | + /** |
|
| 1296 | + * Sets up the where conditions for the registrations query. |
|
| 1297 | + * |
|
| 1298 | + * @param array $request |
|
| 1299 | + * @return array |
|
| 1300 | + * @throws EE_Error |
|
| 1301 | + */ |
|
| 1302 | + protected function _get_where_conditions_for_registrations_query($request) |
|
| 1303 | + { |
|
| 1304 | + return apply_filters( |
|
| 1305 | + 'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query', |
|
| 1306 | + array_merge( |
|
| 1307 | + $this->_add_event_id_to_where_conditions($request), |
|
| 1308 | + $this->_add_category_id_to_where_conditions($request), |
|
| 1309 | + $this->_add_datetime_id_to_where_conditions($request), |
|
| 1310 | + $this->_add_registration_status_to_where_conditions($request), |
|
| 1311 | + $this->_add_date_to_where_conditions($request), |
|
| 1312 | + $this->_add_search_to_where_conditions($request) |
|
| 1313 | + ), |
|
| 1314 | + $request |
|
| 1315 | + ); |
|
| 1316 | + } |
|
| 1317 | + |
|
| 1318 | + |
|
| 1319 | + /** |
|
| 1320 | + * Sets up the orderby for the registrations query. |
|
| 1321 | + * |
|
| 1322 | + * @return array |
|
| 1323 | + */ |
|
| 1324 | + protected function _get_orderby_for_registrations_query() |
|
| 1325 | + { |
|
| 1326 | + $orderby_field = ! empty($this->_req_data['orderby']) |
|
| 1327 | + ? sanitize_text_field($this->_req_data['orderby']) |
|
| 1328 | + : ''; |
|
| 1329 | + switch ($orderby_field) { |
|
| 1330 | + case '_REG_ID': |
|
| 1331 | + $orderby_field = 'REG_ID'; |
|
| 1332 | + break; |
|
| 1333 | + case '_Reg_status': |
|
| 1334 | + $orderby_field = 'STS_ID'; |
|
| 1335 | + break; |
|
| 1336 | + case 'ATT_fname': |
|
| 1337 | + $orderby_field = array('Attendee.ATT_fname', 'Attendee.ATT_lname'); |
|
| 1338 | + break; |
|
| 1339 | + case 'ATT_lname': |
|
| 1340 | + $orderby_field = array('Attendee.ATT_lname', 'Attendee.ATT_fname'); |
|
| 1341 | + break; |
|
| 1342 | + case 'event_name': |
|
| 1343 | + $orderby_field = 'Event.EVT_name'; |
|
| 1344 | + break; |
|
| 1345 | + case 'DTT_EVT_start': |
|
| 1346 | + $orderby_field = 'Event.Datetime.DTT_EVT_start'; |
|
| 1347 | + break; |
|
| 1348 | + default: //'REG_date' |
|
| 1349 | + $orderby_field = 'REG_date'; |
|
| 1350 | + } |
|
| 1351 | + |
|
| 1352 | + //order |
|
| 1353 | + $order = ! empty($this->_req_data['order']) |
|
| 1354 | + ? sanitize_text_field($this->_req_data['order']) |
|
| 1355 | + : 'DESC'; |
|
| 1356 | + |
|
| 1357 | + //mutate orderby_field |
|
| 1358 | + $orderby_field = array_combine( |
|
| 1359 | + (array) $orderby_field, |
|
| 1360 | + array_fill(0, count($orderby_field), $order) |
|
| 1361 | + ); |
|
| 1362 | + return array('order_by' => $orderby_field); |
|
| 1363 | + } |
|
| 1364 | + |
|
| 1365 | + |
|
| 1366 | + /** |
|
| 1367 | + * Sets up the limit for the registrations query. |
|
| 1368 | + * |
|
| 1369 | + * @param $per_page |
|
| 1370 | + * @return array |
|
| 1371 | + */ |
|
| 1372 | + protected function _get_limit($per_page) |
|
| 1373 | + { |
|
| 1374 | + $current_page = ! empty($this->_req_data['paged']) |
|
| 1375 | + ? absint($this->_req_data['paged']) |
|
| 1376 | + : 1; |
|
| 1377 | + $per_page = ! empty($this->_req_data['perpage']) |
|
| 1378 | + ? $this->_req_data['perpage'] |
|
| 1379 | + : $per_page; |
|
| 1380 | + |
|
| 1381 | + //-1 means return all results so get out if that's set. |
|
| 1382 | + if ((int)$per_page === -1) { |
|
| 1383 | + return array(); |
|
| 1384 | + } |
|
| 1385 | + $per_page = absint($per_page); |
|
| 1386 | + $offset = ($current_page - 1) * $per_page; |
|
| 1387 | + return array('limit' => array($offset, $per_page)); |
|
| 1388 | + } |
|
| 1389 | + |
|
| 1390 | + |
|
| 1391 | + public function get_registration_status_array() |
|
| 1392 | + { |
|
| 1393 | + return self::$_reg_status; |
|
| 1394 | + } |
|
| 1395 | + |
|
| 1396 | + |
|
| 1397 | + |
|
| 1398 | + |
|
| 1399 | + /*************************************** REGISTRATION DETAILS ***************************************/ |
|
| 1400 | + /** |
|
| 1401 | + * generates HTML for the View Registration Details Admin page |
|
| 1402 | + * |
|
| 1403 | + * @access protected |
|
| 1404 | + * @return void |
|
| 1405 | + * @throws DomainException |
|
| 1406 | + * @throws EE_Error |
|
| 1407 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 1408 | + */ |
|
| 1409 | + protected function _registration_details() |
|
| 1410 | + { |
|
| 1411 | + $this->_template_args = array(); |
|
| 1412 | + $this->_set_registration_object(); |
|
| 1413 | + if (is_object($this->_registration)) { |
|
| 1414 | + $transaction = $this->_registration->transaction() |
|
| 1415 | + ? $this->_registration->transaction() |
|
| 1416 | + : EE_Transaction::new_instance(); |
|
| 1417 | + $this->_session = $transaction->session_data(); |
|
| 1418 | + $event_id = $this->_registration->event_ID(); |
|
| 1419 | + $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
|
| 1420 | + $this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso'); |
|
| 1421 | + $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date'); |
|
| 1422 | + $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso'); |
|
| 1423 | + $this->_template_args['grand_total'] = $transaction->total(); |
|
| 1424 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 1425 | + // link back to overview |
|
| 1426 | + $this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
|
| 1427 | + $this->_template_args['registration'] = $this->_registration; |
|
| 1428 | + $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1429 | + array( |
|
| 1430 | + 'action' => 'default', |
|
| 1431 | + 'event_id' => $event_id, |
|
| 1432 | + ), |
|
| 1433 | + REG_ADMIN_URL |
|
| 1434 | + ); |
|
| 1435 | + $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1436 | + array( |
|
| 1437 | + 'action' => 'default', |
|
| 1438 | + 'EVT_ID' => $event_id, |
|
| 1439 | + 'page' => 'espresso_transactions', |
|
| 1440 | + ), |
|
| 1441 | + admin_url('admin.php') |
|
| 1442 | + ); |
|
| 1443 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1444 | + array( |
|
| 1445 | + 'page' => 'espresso_events', |
|
| 1446 | + 'action' => 'edit', |
|
| 1447 | + 'post' => $event_id, |
|
| 1448 | + ), |
|
| 1449 | + admin_url('admin.php') |
|
| 1450 | + ); |
|
| 1451 | + //next and previous links |
|
| 1452 | + $next_reg = $this->_registration->next( |
|
| 1453 | + null, |
|
| 1454 | + array(), |
|
| 1455 | + 'REG_ID' |
|
| 1456 | + ); |
|
| 1457 | + $this->_template_args['next_registration'] = $next_reg |
|
| 1458 | + ? $this->_next_link( |
|
| 1459 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 1460 | + array( |
|
| 1461 | + 'action' => 'view_registration', |
|
| 1462 | + '_REG_ID' => $next_reg['REG_ID'], |
|
| 1463 | + ), |
|
| 1464 | + REG_ADMIN_URL |
|
| 1465 | + ), |
|
| 1466 | + 'dashicons dashicons-arrow-right ee-icon-size-22' |
|
| 1467 | + ) |
|
| 1468 | + : ''; |
|
| 1469 | + $previous_reg = $this->_registration->previous( |
|
| 1470 | + null, |
|
| 1471 | + array(), |
|
| 1472 | + 'REG_ID' |
|
| 1473 | + ); |
|
| 1474 | + $this->_template_args['previous_registration'] = $previous_reg |
|
| 1475 | + ? $this->_previous_link( |
|
| 1476 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 1477 | + array( |
|
| 1478 | + 'action' => 'view_registration', |
|
| 1479 | + '_REG_ID' => $previous_reg['REG_ID'], |
|
| 1480 | + ), |
|
| 1481 | + REG_ADMIN_URL |
|
| 1482 | + ), |
|
| 1483 | + 'dashicons dashicons-arrow-left ee-icon-size-22' |
|
| 1484 | + ) |
|
| 1485 | + : ''; |
|
| 1486 | + // grab header |
|
| 1487 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
| 1488 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1489 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template( |
|
| 1490 | + $template_path, |
|
| 1491 | + $this->_template_args, |
|
| 1492 | + true |
|
| 1493 | + ); |
|
| 1494 | + } else { |
|
| 1495 | + $this->_template_args['admin_page_header'] = $this->display_espresso_notices(); |
|
| 1496 | + } |
|
| 1497 | + // the details template wrapper |
|
| 1498 | + $this->display_admin_page_with_sidebar(); |
|
| 1499 | + } |
|
| 1500 | + |
|
| 1501 | + |
|
| 1502 | + protected function _registration_details_metaboxes() |
|
| 1503 | + { |
|
| 1504 | + do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this); |
|
| 1505 | + $this->_set_registration_object(); |
|
| 1506 | + $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
|
| 1507 | + add_meta_box('edit-reg-status-mbox', esc_html__('Registration Status', 'event_espresso'), |
|
| 1508 | + array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1509 | + add_meta_box('edit-reg-details-mbox', esc_html__('Registration Details', 'event_espresso'), |
|
| 1510 | + array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1511 | + if ($attendee instanceof EE_Attendee |
|
| 1512 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 1513 | + 'ee_edit_registration', |
|
| 1514 | + 'edit-reg-questions-mbox' |
|
| 1515 | + ) |
|
| 1516 | + ) { |
|
| 1517 | + add_meta_box( |
|
| 1518 | + 'edit-reg-questions-mbox', |
|
| 1519 | + esc_html__('Registration Form Answers', 'event_espresso'), |
|
| 1520 | + array($this, '_reg_questions_meta_box'), |
|
| 1521 | + $this->wp_page_slug, |
|
| 1522 | + 'normal', |
|
| 1523 | + 'high' |
|
| 1524 | + ); |
|
| 1525 | + } |
|
| 1526 | + add_meta_box( |
|
| 1527 | + 'edit-reg-registrant-mbox', |
|
| 1528 | + esc_html__('Contact Details', 'event_espresso'), |
|
| 1529 | + array($this, '_reg_registrant_side_meta_box'), |
|
| 1530 | + $this->wp_page_slug, |
|
| 1531 | + 'side', |
|
| 1532 | + 'high' |
|
| 1533 | + ); |
|
| 1534 | + if ($this->_registration->group_size() > 1) { |
|
| 1535 | + add_meta_box( |
|
| 1536 | + 'edit-reg-attendees-mbox', |
|
| 1537 | + esc_html__('Other Registrations in this Transaction', 'event_espresso'), |
|
| 1538 | + array($this, '_reg_attendees_meta_box'), |
|
| 1539 | + $this->wp_page_slug, |
|
| 1540 | + 'normal', |
|
| 1541 | + 'high' |
|
| 1542 | + ); |
|
| 1543 | + } |
|
| 1544 | + } |
|
| 1545 | + |
|
| 1546 | + |
|
| 1547 | + /** |
|
| 1548 | + * set_reg_status_buttons_metabox |
|
| 1549 | + * |
|
| 1550 | + * @access protected |
|
| 1551 | + * @return string |
|
| 1552 | + * @throws \EE_Error |
|
| 1553 | + */ |
|
| 1554 | + public function set_reg_status_buttons_metabox() |
|
| 1555 | + { |
|
| 1556 | + $this->_set_registration_object(); |
|
| 1557 | + $change_reg_status_form = $this->_generate_reg_status_change_form(); |
|
| 1558 | + echo $change_reg_status_form->form_open( |
|
| 1559 | + self::add_query_args_and_nonce( |
|
| 1560 | + array( |
|
| 1561 | + 'action' => 'change_reg_status', |
|
| 1562 | + ), |
|
| 1563 | + REG_ADMIN_URL |
|
| 1564 | + ) |
|
| 1565 | + ); |
|
| 1566 | + echo $change_reg_status_form->get_html(); |
|
| 1567 | + echo $change_reg_status_form->form_close(); |
|
| 1568 | + } |
|
| 1569 | + |
|
| 1570 | + |
|
| 1571 | + /** |
|
| 1572 | + * @return EE_Form_Section_Proper |
|
| 1573 | + * @throws EE_Error |
|
| 1574 | + */ |
|
| 1575 | + protected function _generate_reg_status_change_form() |
|
| 1576 | + { |
|
| 1577 | + return new EE_Form_Section_Proper(array( |
|
| 1578 | + 'name' => 'reg_status_change_form', |
|
| 1579 | + 'html_id' => 'reg-status-change-form', |
|
| 1580 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 1581 | + 'subsections' => array( |
|
| 1582 | + 'return' => new EE_Hidden_Input(array( |
|
| 1583 | + 'name' => 'return', |
|
| 1584 | + 'default' => 'view_registration', |
|
| 1585 | + )), |
|
| 1586 | + 'REG_ID' => new EE_Hidden_Input(array( |
|
| 1587 | + 'name' => 'REG_ID', |
|
| 1588 | + 'default' => $this->_registration->ID(), |
|
| 1589 | + )), |
|
| 1590 | + 'current_status' => new EE_Form_Section_HTML( |
|
| 1591 | + EEH_HTML::tr( |
|
| 1592 | + EEH_HTML::th( |
|
| 1593 | + EEH_HTML::label( |
|
| 1594 | + EEH_HTML::strong(esc_html__('Current Registration Status', 'event_espresso') |
|
| 1595 | + ) |
|
| 1596 | + ) |
|
| 1597 | + ) |
|
| 1598 | + . EEH_HTML::td( |
|
| 1599 | + EEH_HTML::strong( |
|
| 1600 | + $this->_registration->pretty_status(), |
|
| 1601 | + '', |
|
| 1602 | + 'status-' . $this->_registration->status_ID(), |
|
| 1603 | + 'line-height: 1em; font-size: 1.5em; font-weight: bold;' |
|
| 1604 | + ) |
|
| 1605 | + ) |
|
| 1606 | + ) |
|
| 1607 | + ), |
|
| 1608 | + 'reg_status' => new EE_Select_Input( |
|
| 1609 | + $this->_get_reg_statuses(), |
|
| 1610 | + array( |
|
| 1611 | + 'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'), |
|
| 1612 | + 'default' => $this->_registration->status_ID(), |
|
| 1613 | + ) |
|
| 1614 | + ), |
|
| 1615 | + 'send_notifications' => new EE_Yes_No_Input( |
|
| 1616 | + array( |
|
| 1617 | + 'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'), |
|
| 1618 | + 'default' => false, |
|
| 1619 | + 'html_help_text' => esc_html__( |
|
| 1620 | + 'If set to "Yes", then the related messages will be sent to the registrant.', |
|
| 1621 | + 'event_espresso' |
|
| 1622 | + ), |
|
| 1623 | + ) |
|
| 1624 | + ), |
|
| 1625 | + 'submit' => new EE_Submit_Input( |
|
| 1626 | + array( |
|
| 1627 | + 'html_class' => 'button-primary', |
|
| 1628 | + 'html_label_text' => ' ', |
|
| 1629 | + 'default' => esc_html__('Update Registration Status', 'event_espresso'), |
|
| 1630 | + ) |
|
| 1631 | + ), |
|
| 1632 | + ), |
|
| 1633 | + )); |
|
| 1634 | + } |
|
| 1635 | + |
|
| 1636 | + |
|
| 1637 | + /** |
|
| 1638 | + * Returns an array of all the buttons for the various statuses and switch status actions |
|
| 1639 | + * |
|
| 1640 | + * @return array |
|
| 1641 | + * @throws EE_Error |
|
| 1642 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 1643 | + */ |
|
| 1644 | + protected function _get_reg_statuses() |
|
| 1645 | + { |
|
| 1646 | + $reg_status_array = EEM_Registration::instance()->reg_status_array(); |
|
| 1647 | + unset ($reg_status_array[EEM_Registration::status_id_incomplete]); |
|
| 1648 | + // get current reg status |
|
| 1649 | + $current_status = $this->_registration->status_ID(); |
|
| 1650 | + // is registration for free event? This will determine whether to display the pending payment option |
|
| 1651 | + if ($current_status != EEM_Registration::status_id_pending_payment |
|
| 1652 | + && $this->_registration->transaction() |
|
| 1653 | + ->is_free() |
|
| 1654 | + ) { |
|
| 1655 | + unset($reg_status_array[EEM_Registration::status_id_pending_payment]); |
|
| 1656 | + } |
|
| 1657 | + return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence'); |
|
| 1658 | + } |
|
| 1659 | + |
|
| 1660 | + |
|
| 1661 | + /** |
|
| 1662 | + * This method is used when using _REG_ID from request which may or may not be an array of reg_ids. |
|
| 1663 | + * |
|
| 1664 | + * @param bool $status REG status given for changing registrations to. |
|
| 1665 | + * @param bool $notify Whether to send messages notifications or not. |
|
| 1666 | + * @return array (array with reg_id(s) updated and whether update was successful. |
|
| 1667 | + */ |
|
| 1668 | + protected function _set_registration_status_from_request($status = false, $notify = false) |
|
| 1669 | + { |
|
| 1670 | + if (isset($this->_req_data['reg_status_change_form'])) { |
|
| 1671 | + $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
|
| 1672 | + ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
| 1673 | + } else { |
|
| 1674 | + $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array(); |
|
| 1675 | + } |
|
| 1676 | + $success = $this->_set_registration_status($REG_IDs, $status); |
|
| 1677 | + //notify? |
|
| 1678 | + if ($success |
|
| 1679 | + && $notify |
|
| 1680 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 1681 | + 'ee_send_message', |
|
| 1682 | + 'espresso_registrations_resend_registration' |
|
| 1683 | + ) |
|
| 1684 | + ) { |
|
| 1685 | + $this->_process_resend_registration(); |
|
| 1686 | + } |
|
| 1687 | + return $success; |
|
| 1688 | + } |
|
| 1689 | + |
|
| 1690 | + |
|
| 1691 | + /** |
|
| 1692 | + * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an |
|
| 1693 | + * array). Note, this method does NOT take care of possible notifications. That is required by calling code. |
|
| 1694 | + * |
|
| 1695 | + * @param array $REG_IDs |
|
| 1696 | + * @param bool $status |
|
| 1697 | + * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as |
|
| 1698 | + * the array of updated registrations). |
|
| 1699 | + * @throws EE_Error |
|
| 1700 | + * @throws RuntimeException |
|
| 1701 | + */ |
|
| 1702 | + protected function _set_registration_status($REG_IDs = array(), $status = false) |
|
| 1703 | + { |
|
| 1704 | + $success = false; |
|
| 1705 | + // typecast $REG_IDs |
|
| 1706 | + $REG_IDs = (array)$REG_IDs; |
|
| 1707 | + if ( ! empty($REG_IDs)) { |
|
| 1708 | + $success = true; |
|
| 1709 | + // set default status if none is passed |
|
| 1710 | + $status = $status ? $status : EEM_Registration::status_id_pending_payment; |
|
| 1711 | + // sanitize $REG_IDs |
|
| 1712 | + $REG_IDs = array_filter($REG_IDs, 'absint'); |
|
| 1713 | + //loop through REG_ID's and change status |
|
| 1714 | + foreach ($REG_IDs as $REG_ID) { |
|
| 1715 | + $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 1716 | + if ($registration instanceof EE_Registration) { |
|
| 1717 | + $registration->set_status($status); |
|
| 1718 | + $result = $registration->save(); |
|
| 1719 | + // verifying explicit fails because update *may* just return 0 for 0 rows affected |
|
| 1720 | + $success = $result !== false ? $success : false; |
|
| 1721 | + } |
|
| 1722 | + } |
|
| 1723 | + } |
|
| 1724 | + //reset _req_data['_REG_ID'] for any potential future messages notifications |
|
| 1725 | + $this->_req_data['_REG_ID'] = $REG_IDs; |
|
| 1726 | + //return $success and processed registrations |
|
| 1727 | + return array('REG_ID' => $REG_IDs, 'success' => $success); |
|
| 1728 | + } |
|
| 1729 | + |
|
| 1730 | + |
|
| 1731 | + /** |
|
| 1732 | + * Common logic for setting up success message and redirecting to appropriate route |
|
| 1733 | + * |
|
| 1734 | + * @param string $STS_ID status id for the registration changed to |
|
| 1735 | + * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
|
| 1736 | + * @return void |
|
| 1737 | + */ |
|
| 1738 | + protected function _reg_status_change_return($STS_ID, $notify = false) |
|
| 1739 | + { |
|
| 1740 | + $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify) |
|
| 1741 | + : array('success' => false); |
|
| 1742 | + $success = isset($result['success']) && $result['success']; |
|
| 1743 | + //setup success message |
|
| 1744 | + if ($success) { |
|
| 1745 | + if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) { |
|
| 1746 | + $msg = sprintf(esc_html__('Registration status has been set to %s', 'event_espresso'), |
|
| 1747 | + EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1748 | + } else { |
|
| 1749 | + $msg = sprintf(esc_html__('Registrations have been set to %s.', 'event_espresso'), |
|
| 1750 | + EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1751 | + } |
|
| 1752 | + EE_Error::add_success($msg); |
|
| 1753 | + } else { |
|
| 1754 | + EE_Error::add_error( |
|
| 1755 | + esc_html__( |
|
| 1756 | + 'Something went wrong, and the status was not changed', |
|
| 1757 | + 'event_espresso' |
|
| 1758 | + ), __FILE__, __LINE__, __FUNCTION__ |
|
| 1759 | + ); |
|
| 1760 | + } |
|
| 1761 | + if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') { |
|
| 1762 | + $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])); |
|
| 1763 | + } else { |
|
| 1764 | + $route = array('action' => 'default'); |
|
| 1765 | + } |
|
| 1766 | + //unset nonces |
|
| 1767 | + foreach ($this->_req_data as $ref => $value) { |
|
| 1768 | + if (strpos($ref, 'nonce') !== false) { |
|
| 1769 | + unset($this->_req_data[$ref]); |
|
| 1770 | + continue; |
|
| 1771 | + } |
|
| 1772 | + $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value); |
|
| 1773 | + $this->_req_data[$ref] = $value; |
|
| 1774 | + } |
|
| 1775 | + //merge request vars so that the reloaded list table contains any existing filter query params |
|
| 1776 | + $route = array_merge($this->_req_data, $route); |
|
| 1777 | + $this->_redirect_after_action($success, '', '', $route, true); |
|
| 1778 | + } |
|
| 1779 | + |
|
| 1780 | + |
|
| 1781 | + /** |
|
| 1782 | + * incoming reg status change from reg details page. |
|
| 1783 | + * |
|
| 1784 | + * @return void |
|
| 1785 | + */ |
|
| 1786 | + protected function _change_reg_status() |
|
| 1787 | + { |
|
| 1788 | + $this->_req_data['return'] = 'view_registration'; |
|
| 1789 | + //set notify based on whether the send notifications toggle is set or not |
|
| 1790 | + $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']); |
|
| 1791 | + //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
|
| 1792 | + $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status']) |
|
| 1793 | + ? $this->_req_data['reg_status_change_form']['reg_status'] : ''; |
|
| 1794 | + switch ($this->_req_data['reg_status_change_form']['reg_status']) { |
|
| 1795 | + case EEM_Registration::status_id_approved : |
|
| 1796 | + case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') : |
|
| 1797 | + $this->approve_registration($notify); |
|
| 1798 | + break; |
|
| 1799 | + case EEM_Registration::status_id_pending_payment : |
|
| 1800 | + case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') : |
|
| 1801 | + $this->pending_registration($notify); |
|
| 1802 | + break; |
|
| 1803 | + case EEM_Registration::status_id_not_approved : |
|
| 1804 | + case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') : |
|
| 1805 | + $this->not_approve_registration($notify); |
|
| 1806 | + break; |
|
| 1807 | + case EEM_Registration::status_id_declined : |
|
| 1808 | + case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') : |
|
| 1809 | + $this->decline_registration($notify); |
|
| 1810 | + break; |
|
| 1811 | + case EEM_Registration::status_id_cancelled : |
|
| 1812 | + case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') : |
|
| 1813 | + $this->cancel_registration($notify); |
|
| 1814 | + break; |
|
| 1815 | + case EEM_Registration::status_id_wait_list : |
|
| 1816 | + case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') : |
|
| 1817 | + $this->waitlist_registration($notify); |
|
| 1818 | + break; |
|
| 1819 | + case EEM_Registration::status_id_incomplete : |
|
| 1820 | + default : |
|
| 1821 | + $result['success'] = false; |
|
| 1822 | + unset($this->_req_data['return']); |
|
| 1823 | + $this->_reg_status_change_return('', false); |
|
| 1824 | + break; |
|
| 1825 | + } |
|
| 1826 | + } |
|
| 1827 | + |
|
| 1828 | + |
|
| 1829 | + /** |
|
| 1830 | + * approve_registration |
|
| 1831 | + * |
|
| 1832 | + * @access protected |
|
| 1833 | + * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1834 | + * @return void |
|
| 1835 | + */ |
|
| 1836 | + protected function approve_registration($notify = false) |
|
| 1837 | + { |
|
| 1838 | + $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify); |
|
| 1839 | + } |
|
| 1840 | + |
|
| 1841 | + |
|
| 1842 | + /** |
|
| 1843 | + * decline_registration |
|
| 1844 | + * |
|
| 1845 | + * @access protected |
|
| 1846 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1847 | + * @return void |
|
| 1848 | + */ |
|
| 1849 | + protected function decline_registration($notify = false) |
|
| 1850 | + { |
|
| 1851 | + $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify); |
|
| 1852 | + } |
|
| 1853 | + |
|
| 1854 | + |
|
| 1855 | + /** |
|
| 1856 | + * cancel_registration |
|
| 1857 | + * |
|
| 1858 | + * @access protected |
|
| 1859 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1860 | + * @return void |
|
| 1861 | + */ |
|
| 1862 | + protected function cancel_registration($notify = false) |
|
| 1863 | + { |
|
| 1864 | + $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify); |
|
| 1865 | + } |
|
| 1866 | + |
|
| 1867 | + |
|
| 1868 | + /** |
|
| 1869 | + * not_approve_registration |
|
| 1870 | + * |
|
| 1871 | + * @access protected |
|
| 1872 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1873 | + * @return void |
|
| 1874 | + */ |
|
| 1875 | + protected function not_approve_registration($notify = false) |
|
| 1876 | + { |
|
| 1877 | + $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify); |
|
| 1878 | + } |
|
| 1879 | + |
|
| 1880 | + |
|
| 1881 | + /** |
|
| 1882 | + * decline_registration |
|
| 1883 | + * |
|
| 1884 | + * @access protected |
|
| 1885 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1886 | + * @return void |
|
| 1887 | + */ |
|
| 1888 | + protected function pending_registration($notify = false) |
|
| 1889 | + { |
|
| 1890 | + $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify); |
|
| 1891 | + } |
|
| 1892 | + |
|
| 1893 | + |
|
| 1894 | + /** |
|
| 1895 | + * waitlist_registration |
|
| 1896 | + * |
|
| 1897 | + * @access protected |
|
| 1898 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1899 | + * @return void |
|
| 1900 | + */ |
|
| 1901 | + protected function waitlist_registration($notify = false) |
|
| 1902 | + { |
|
| 1903 | + $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify); |
|
| 1904 | + } |
|
| 1905 | + |
|
| 1906 | + |
|
| 1907 | + /** |
|
| 1908 | + * generates HTML for the Registration main meta box |
|
| 1909 | + * |
|
| 1910 | + * @access public |
|
| 1911 | + * @return void |
|
| 1912 | + * @throws DomainException |
|
| 1913 | + * @throws EE_Error |
|
| 1914 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 1915 | + */ |
|
| 1916 | + public function _reg_details_meta_box() |
|
| 1917 | + { |
|
| 1918 | + EEH_Autoloader::register_line_item_display_autoloaders(); |
|
| 1919 | + EEH_Autoloader::register_line_item_filter_autoloaders(); |
|
| 1920 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
| 1921 | + $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
| 1922 | + : EE_Transaction::new_instance(); |
|
| 1923 | + $this->_session = $transaction->session_data(); |
|
| 1924 | + $filters = new EE_Line_Item_Filter_Collection(); |
|
| 1925 | + //$filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
| 1926 | + $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration)); |
|
| 1927 | + $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, |
|
| 1928 | + $transaction->total_line_item()); |
|
| 1929 | + $filtered_line_item_tree = $line_item_filter_processor->process(); |
|
| 1930 | + $line_item_display = new EE_Line_Item_Display('reg_admin_table', |
|
| 1931 | + 'EE_Admin_Table_Registration_Line_Item_Display_Strategy'); |
|
| 1932 | + $this->_template_args['line_item_table'] = $line_item_display->display_line_item( |
|
| 1933 | + $filtered_line_item_tree, |
|
| 1934 | + array('EE_Registration' => $this->_registration) |
|
| 1935 | + ); |
|
| 1936 | + $attendee = $this->_registration->attendee(); |
|
| 1937 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 1938 | + 'ee_read_transaction', |
|
| 1939 | + 'espresso_transactions_view_transaction' |
|
| 1940 | + )) { |
|
| 1941 | + $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link( |
|
| 1942 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 1943 | + array( |
|
| 1944 | + 'action' => 'view_transaction', |
|
| 1945 | + 'TXN_ID' => $transaction->ID(), |
|
| 1946 | + ), |
|
| 1947 | + TXN_ADMIN_URL |
|
| 1948 | + ), |
|
| 1949 | + esc_html__(' View Transaction', 'event_espresso'), |
|
| 1950 | + 'button secondary-button right', |
|
| 1951 | + 'dashicons dashicons-cart' |
|
| 1952 | + ); |
|
| 1953 | + } else { |
|
| 1954 | + $this->_template_args['view_transaction_button'] = ''; |
|
| 1955 | + } |
|
| 1956 | + if ($attendee instanceof EE_Attendee |
|
| 1957 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 1958 | + 'ee_send_message', |
|
| 1959 | + 'espresso_registrations_resend_registration' |
|
| 1960 | + ) |
|
| 1961 | + ) { |
|
| 1962 | + $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link( |
|
| 1963 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 1964 | + array( |
|
| 1965 | + 'action' => 'resend_registration', |
|
| 1966 | + '_REG_ID' => $this->_registration->ID(), |
|
| 1967 | + 'redirect_to' => 'view_registration', |
|
| 1968 | + ), |
|
| 1969 | + REG_ADMIN_URL |
|
| 1970 | + ), |
|
| 1971 | + esc_html__(' Resend Registration', 'event_espresso'), |
|
| 1972 | + 'button secondary-button right', |
|
| 1973 | + 'dashicons dashicons-email-alt' |
|
| 1974 | + ); |
|
| 1975 | + } else { |
|
| 1976 | + $this->_template_args['resend_registration_button'] = ''; |
|
| 1977 | + } |
|
| 1978 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 1979 | + $payment = $transaction->get_first_related('Payment'); |
|
| 1980 | + $payment = ! $payment instanceof EE_Payment |
|
| 1981 | + ? EE_Payment::new_instance() |
|
| 1982 | + : $payment; |
|
| 1983 | + $payment_method = $payment->get_first_related('Payment_Method'); |
|
| 1984 | + $payment_method = ! $payment_method instanceof EE_Payment_Method |
|
| 1985 | + ? EE_Payment_Method::new_instance() |
|
| 1986 | + : $payment_method; |
|
| 1987 | + $reg_details = array( |
|
| 1988 | + 'payment_method' => $payment_method->name(), |
|
| 1989 | + 'response_msg' => $payment->gateway_response(), |
|
| 1990 | + 'registration_id' => $this->_registration->get('REG_code'), |
|
| 1991 | + 'registration_session' => $this->_registration->session_ID(), |
|
| 1992 | + 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', |
|
| 1993 | + 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '', |
|
| 1994 | + ); |
|
| 1995 | + if (isset($reg_details['registration_id'])) { |
|
| 1996 | + $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
|
| 1997 | + $this->_template_args['reg_details']['registration_id']['label'] = esc_html__( |
|
| 1998 | + 'Registration ID', |
|
| 1999 | + 'event_espresso' |
|
| 2000 | + ); |
|
| 2001 | + $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
|
| 2002 | + } |
|
| 2003 | + if (isset($reg_details['payment_method'])) { |
|
| 2004 | + $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
|
| 2005 | + $this->_template_args['reg_details']['payment_method']['label'] = esc_html__( |
|
| 2006 | + 'Most Recent Payment Method', |
|
| 2007 | + 'event_espresso' |
|
| 2008 | + ); |
|
| 2009 | + $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
|
| 2010 | + $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
|
| 2011 | + $this->_template_args['reg_details']['response_msg']['label'] = esc_html__( |
|
| 2012 | + 'Payment method response', |
|
| 2013 | + 'event_espresso' |
|
| 2014 | + ); |
|
| 2015 | + $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
|
| 2016 | + } |
|
| 2017 | + $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
|
| 2018 | + $this->_template_args['reg_details']['registration_session']['label'] = esc_html__( |
|
| 2019 | + 'Registration Session', |
|
| 2020 | + 'event_espresso' |
|
| 2021 | + ); |
|
| 2022 | + $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
|
| 2023 | + $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
|
| 2024 | + $this->_template_args['reg_details']['ip_address']['label'] = esc_html__( |
|
| 2025 | + 'Registration placed from IP', |
|
| 2026 | + 'event_espresso' |
|
| 2027 | + ); |
|
| 2028 | + $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
|
| 2029 | + $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
|
| 2030 | + $this->_template_args['reg_details']['user_agent']['label'] = esc_html__('Registrant User Agent', |
|
| 2031 | + 'event_espresso'); |
|
| 2032 | + $this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
|
| 2033 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 2034 | + array( |
|
| 2035 | + 'action' => 'default', |
|
| 2036 | + 'event_id' => $this->_registration->event_ID(), |
|
| 2037 | + ), |
|
| 2038 | + REG_ADMIN_URL |
|
| 2039 | + ); |
|
| 2040 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 2041 | + $this->_template_args['event_id'] = $this->_registration->event_ID(); |
|
| 2042 | + $template_path = |
|
| 2043 | + REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 2044 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2045 | + } |
|
| 2046 | + |
|
| 2047 | + |
|
| 2048 | + /** |
|
| 2049 | + * generates HTML for the Registration Questions meta box. |
|
| 2050 | + * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters), |
|
| 2051 | + * otherwise uses new forms system |
|
| 2052 | + * |
|
| 2053 | + * @access public |
|
| 2054 | + * @return void |
|
| 2055 | + * @throws DomainException |
|
| 2056 | + * @throws EE_Error |
|
| 2057 | + */ |
|
| 2058 | + public function _reg_questions_meta_box() |
|
| 2059 | + { |
|
| 2060 | + //allow someone to override this method entirely |
|
| 2061 | + if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, |
|
| 2062 | + $this->_registration)) { |
|
| 2063 | + $form = $this->_get_reg_custom_questions_form( |
|
| 2064 | + $this->_registration->ID() |
|
| 2065 | + ); |
|
| 2066 | + $this->_template_args['att_questions'] = count($form->subforms()) > 0 |
|
| 2067 | + ? $form->get_html_and_js() |
|
| 2068 | + : ''; |
|
| 2069 | + $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
|
| 2070 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 2071 | + $template_path = |
|
| 2072 | + REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 2073 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2074 | + } |
|
| 2075 | + } |
|
| 2076 | + |
|
| 2077 | + |
|
| 2078 | + /** |
|
| 2079 | + * form_before_question_group |
|
| 2080 | + * |
|
| 2081 | + * @deprecated as of 4.8.32.rc.000 |
|
| 2082 | + * @access public |
|
| 2083 | + * @param string $output |
|
| 2084 | + * @return string |
|
| 2085 | + */ |
|
| 2086 | + public function form_before_question_group($output) |
|
| 2087 | + { |
|
| 2088 | + EE_Error::doing_it_wrong( |
|
| 2089 | + __CLASS__ . '::' . __FUNCTION__, |
|
| 2090 | + esc_html__( |
|
| 2091 | + 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2092 | + 'event_espresso' |
|
| 2093 | + ), |
|
| 2094 | + '4.8.32.rc.000' |
|
| 2095 | + ); |
|
| 2096 | + return ' |
|
| 2097 | 2097 | <table class="form-table ee-width-100"> |
| 2098 | 2098 | <tbody> |
| 2099 | 2099 | '; |
| 2100 | - } |
|
| 2101 | - |
|
| 2102 | - |
|
| 2103 | - /** |
|
| 2104 | - * form_after_question_group |
|
| 2105 | - * |
|
| 2106 | - * @deprecated as of 4.8.32.rc.000 |
|
| 2107 | - * @access public |
|
| 2108 | - * @param string $output |
|
| 2109 | - * @return string |
|
| 2110 | - */ |
|
| 2111 | - public function form_after_question_group($output) |
|
| 2112 | - { |
|
| 2113 | - EE_Error::doing_it_wrong( |
|
| 2114 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2115 | - esc_html__( |
|
| 2116 | - 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2117 | - 'event_espresso' |
|
| 2118 | - ), |
|
| 2119 | - '4.8.32.rc.000' |
|
| 2120 | - ); |
|
| 2121 | - return ' |
|
| 2100 | + } |
|
| 2101 | + |
|
| 2102 | + |
|
| 2103 | + /** |
|
| 2104 | + * form_after_question_group |
|
| 2105 | + * |
|
| 2106 | + * @deprecated as of 4.8.32.rc.000 |
|
| 2107 | + * @access public |
|
| 2108 | + * @param string $output |
|
| 2109 | + * @return string |
|
| 2110 | + */ |
|
| 2111 | + public function form_after_question_group($output) |
|
| 2112 | + { |
|
| 2113 | + EE_Error::doing_it_wrong( |
|
| 2114 | + __CLASS__ . '::' . __FUNCTION__, |
|
| 2115 | + esc_html__( |
|
| 2116 | + 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2117 | + 'event_espresso' |
|
| 2118 | + ), |
|
| 2119 | + '4.8.32.rc.000' |
|
| 2120 | + ); |
|
| 2121 | + return ' |
|
| 2122 | 2122 | <tr class="hide-if-no-js"> |
| 2123 | 2123 | <th> </th> |
| 2124 | 2124 | <td class="reg-admin-edit-attendee-question-td"> |
| 2125 | 2125 | <a class="reg-admin-edit-attendee-question-lnk" href="#" title="' |
| 2126 | - . esc_attr__('click to edit question', 'event_espresso') |
|
| 2127 | - . '"> |
|
| 2126 | + . esc_attr__('click to edit question', 'event_espresso') |
|
| 2127 | + . '"> |
|
| 2128 | 2128 | <span class="reg-admin-edit-question-group-spn lt-grey-txt">' |
| 2129 | - . esc_html__('edit the above question group', 'event_espresso') |
|
| 2130 | - . '</span> |
|
| 2129 | + . esc_html__('edit the above question group', 'event_espresso') |
|
| 2130 | + . '</span> |
|
| 2131 | 2131 | <div class="dashicons dashicons-edit"></div> |
| 2132 | 2132 | </a> |
| 2133 | 2133 | </td> |
@@ -2135,558 +2135,558 @@ discard block |
||
| 2135 | 2135 | </tbody> |
| 2136 | 2136 | </table> |
| 2137 | 2137 | '; |
| 2138 | - } |
|
| 2139 | - |
|
| 2140 | - |
|
| 2141 | - /** |
|
| 2142 | - * form_form_field_label_wrap |
|
| 2143 | - * |
|
| 2144 | - * @deprecated as of 4.8.32.rc.000 |
|
| 2145 | - * @access public |
|
| 2146 | - * @param string $label |
|
| 2147 | - * @return string |
|
| 2148 | - */ |
|
| 2149 | - public function form_form_field_label_wrap($label) |
|
| 2150 | - { |
|
| 2151 | - EE_Error::doing_it_wrong( |
|
| 2152 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2153 | - esc_html__( |
|
| 2154 | - 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2155 | - 'event_espresso' |
|
| 2156 | - ), |
|
| 2157 | - '4.8.32.rc.000' |
|
| 2158 | - ); |
|
| 2159 | - return ' |
|
| 2138 | + } |
|
| 2139 | + |
|
| 2140 | + |
|
| 2141 | + /** |
|
| 2142 | + * form_form_field_label_wrap |
|
| 2143 | + * |
|
| 2144 | + * @deprecated as of 4.8.32.rc.000 |
|
| 2145 | + * @access public |
|
| 2146 | + * @param string $label |
|
| 2147 | + * @return string |
|
| 2148 | + */ |
|
| 2149 | + public function form_form_field_label_wrap($label) |
|
| 2150 | + { |
|
| 2151 | + EE_Error::doing_it_wrong( |
|
| 2152 | + __CLASS__ . '::' . __FUNCTION__, |
|
| 2153 | + esc_html__( |
|
| 2154 | + 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2155 | + 'event_espresso' |
|
| 2156 | + ), |
|
| 2157 | + '4.8.32.rc.000' |
|
| 2158 | + ); |
|
| 2159 | + return ' |
|
| 2160 | 2160 | <tr> |
| 2161 | 2161 | <th> |
| 2162 | 2162 | ' . $label . ' |
| 2163 | 2163 | </th>'; |
| 2164 | - } |
|
| 2165 | - |
|
| 2166 | - |
|
| 2167 | - /** |
|
| 2168 | - * form_form_field_input__wrap |
|
| 2169 | - * |
|
| 2170 | - * @deprecated as of 4.8.32.rc.000 |
|
| 2171 | - * @access public |
|
| 2172 | - * @param string $input |
|
| 2173 | - * @return string |
|
| 2174 | - */ |
|
| 2175 | - public function form_form_field_input__wrap($input) |
|
| 2176 | - { |
|
| 2177 | - EE_Error::doing_it_wrong( |
|
| 2178 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 2179 | - esc_html__( |
|
| 2180 | - 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2181 | - 'event_espresso' |
|
| 2182 | - ), |
|
| 2183 | - '4.8.32.rc.000' |
|
| 2184 | - ); |
|
| 2185 | - return ' |
|
| 2164 | + } |
|
| 2165 | + |
|
| 2166 | + |
|
| 2167 | + /** |
|
| 2168 | + * form_form_field_input__wrap |
|
| 2169 | + * |
|
| 2170 | + * @deprecated as of 4.8.32.rc.000 |
|
| 2171 | + * @access public |
|
| 2172 | + * @param string $input |
|
| 2173 | + * @return string |
|
| 2174 | + */ |
|
| 2175 | + public function form_form_field_input__wrap($input) |
|
| 2176 | + { |
|
| 2177 | + EE_Error::doing_it_wrong( |
|
| 2178 | + __CLASS__ . '::' . __FUNCTION__, |
|
| 2179 | + esc_html__( |
|
| 2180 | + 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.', |
|
| 2181 | + 'event_espresso' |
|
| 2182 | + ), |
|
| 2183 | + '4.8.32.rc.000' |
|
| 2184 | + ); |
|
| 2185 | + return ' |
|
| 2186 | 2186 | <td class="reg-admin-attendee-questions-input-td disabled-input"> |
| 2187 | 2187 | ' . $input . ' |
| 2188 | 2188 | </td> |
| 2189 | 2189 | </tr>'; |
| 2190 | - } |
|
| 2191 | - |
|
| 2192 | - |
|
| 2193 | - /** |
|
| 2194 | - * Updates the registration's custom questions according to the form info, if the form is submitted. |
|
| 2195 | - * If it's not a post, the "view_registrations" route will be called next on the SAME request |
|
| 2196 | - * to display the page |
|
| 2197 | - * |
|
| 2198 | - * @access protected |
|
| 2199 | - * @return void |
|
| 2200 | - * @throws EE_Error |
|
| 2201 | - */ |
|
| 2202 | - protected function _update_attendee_registration_form() |
|
| 2203 | - { |
|
| 2204 | - do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this); |
|
| 2205 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 2206 | - $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 2207 | - $success = $this->_save_reg_custom_questions_form($REG_ID); |
|
| 2208 | - if ($success) { |
|
| 2209 | - $what = esc_html__('Registration Form', 'event_espresso'); |
|
| 2210 | - $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) |
|
| 2211 | - : array('action' => 'default'); |
|
| 2212 | - $this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route); |
|
| 2213 | - } |
|
| 2214 | - } |
|
| 2215 | - } |
|
| 2216 | - |
|
| 2217 | - |
|
| 2218 | - /** |
|
| 2219 | - * Gets the form for saving registrations custom questions (if done |
|
| 2220 | - * previously retrieves the cached form object, which may have validation errors in it) |
|
| 2221 | - * |
|
| 2222 | - * @param int $REG_ID |
|
| 2223 | - * @return EE_Registration_Custom_Questions_Form |
|
| 2224 | - * @throws EE_Error |
|
| 2225 | - */ |
|
| 2226 | - protected function _get_reg_custom_questions_form($REG_ID) |
|
| 2227 | - { |
|
| 2228 | - if ( ! $this->_reg_custom_questions_form) { |
|
| 2229 | - require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 2230 | - $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( |
|
| 2231 | - EEM_Registration::instance()->get_one_by_ID($REG_ID) |
|
| 2232 | - ); |
|
| 2233 | - $this->_reg_custom_questions_form->_construct_finalize(null, null); |
|
| 2234 | - } |
|
| 2235 | - return $this->_reg_custom_questions_form; |
|
| 2236 | - } |
|
| 2237 | - |
|
| 2238 | - |
|
| 2239 | - /** |
|
| 2240 | - * Saves |
|
| 2241 | - * |
|
| 2242 | - * @access private |
|
| 2243 | - * @param bool $REG_ID |
|
| 2244 | - * @return bool |
|
| 2245 | - * @throws EE_Error |
|
| 2246 | - */ |
|
| 2247 | - private function _save_reg_custom_questions_form($REG_ID = false) |
|
| 2248 | - { |
|
| 2249 | - if ( ! $REG_ID) { |
|
| 2250 | - EE_Error::add_error( |
|
| 2251 | - esc_html__( |
|
| 2252 | - 'An error occurred. No registration ID was received.', 'event_espresso'), |
|
| 2253 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 2254 | - ); |
|
| 2255 | - } |
|
| 2256 | - $form = $this->_get_reg_custom_questions_form($REG_ID); |
|
| 2257 | - $form->receive_form_submission($this->_req_data); |
|
| 2258 | - $success = false; |
|
| 2259 | - if ($form->is_valid()) { |
|
| 2260 | - foreach ($form->subforms() as $question_group_id => $question_group_form) { |
|
| 2261 | - foreach ($question_group_form->inputs() as $question_id => $input) { |
|
| 2262 | - $where_conditions = array( |
|
| 2263 | - 'QST_ID' => $question_id, |
|
| 2264 | - 'REG_ID' => $REG_ID, |
|
| 2265 | - ); |
|
| 2266 | - $possibly_new_values = array( |
|
| 2267 | - 'ANS_value' => $input->normalized_value(), |
|
| 2268 | - ); |
|
| 2269 | - $answer = EEM_Answer::instance()->get_one(array($where_conditions)); |
|
| 2270 | - if ($answer instanceof EE_Answer) { |
|
| 2271 | - $success = $answer->save($possibly_new_values); |
|
| 2272 | - } else { |
|
| 2273 | - //insert it then |
|
| 2274 | - $cols_n_vals = array_merge($where_conditions, $possibly_new_values); |
|
| 2275 | - $answer = EE_Answer::new_instance($cols_n_vals); |
|
| 2276 | - $success = $answer->save(); |
|
| 2277 | - } |
|
| 2278 | - } |
|
| 2279 | - } |
|
| 2280 | - } else { |
|
| 2281 | - EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__); |
|
| 2282 | - } |
|
| 2283 | - return $success; |
|
| 2284 | - } |
|
| 2285 | - |
|
| 2286 | - |
|
| 2287 | - /** |
|
| 2288 | - * generates HTML for the Registration main meta box |
|
| 2289 | - * |
|
| 2290 | - * @access public |
|
| 2291 | - * @return void |
|
| 2292 | - * @throws DomainException |
|
| 2293 | - * @throws EE_Error |
|
| 2294 | - */ |
|
| 2295 | - public function _reg_attendees_meta_box() |
|
| 2296 | - { |
|
| 2297 | - $REG = EEM_Registration::instance(); |
|
| 2298 | - //get all other registrations on this transaction, and cache |
|
| 2299 | - //the attendees for them so we don't have to run another query using force_join |
|
| 2300 | - $registrations = $REG->get_all(array( |
|
| 2301 | - array( |
|
| 2302 | - 'TXN_ID' => $this->_registration->transaction_ID(), |
|
| 2303 | - 'REG_ID' => array('!=', $this->_registration->ID()), |
|
| 2304 | - ), |
|
| 2305 | - 'force_join' => array('Attendee'), |
|
| 2306 | - )); |
|
| 2307 | - $this->_template_args['attendees'] = array(); |
|
| 2308 | - $this->_template_args['attendee_notice'] = ''; |
|
| 2309 | - if (empty($registrations) |
|
| 2310 | - || (is_array($registrations) |
|
| 2311 | - && ! EEH_Array::get_one_item_from_array($registrations)) |
|
| 2312 | - ) { |
|
| 2313 | - EE_Error::add_error( |
|
| 2314 | - esc_html__( |
|
| 2315 | - 'There are no records attached to this registration. Something may have gone wrong with the registration', |
|
| 2316 | - 'event_espresso' |
|
| 2317 | - ), __FILE__, __FUNCTION__, __LINE__ |
|
| 2318 | - ); |
|
| 2319 | - $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
|
| 2320 | - } else { |
|
| 2321 | - $att_nmbr = 1; |
|
| 2322 | - foreach ($registrations as $registration) { |
|
| 2323 | - /* @var $registration EE_Registration */ |
|
| 2324 | - $attendee = $registration->attendee() |
|
| 2325 | - ? $registration->attendee() |
|
| 2326 | - : EEM_Attendee::instance() |
|
| 2327 | - ->create_default_object(); |
|
| 2328 | - $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
|
| 2329 | - $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); |
|
| 2330 | - $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); |
|
| 2331 | - $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); |
|
| 2332 | - $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); |
|
| 2333 | - $this->_template_args['attendees'][$att_nmbr]['address'] = implode( |
|
| 2334 | - ', ', |
|
| 2335 | - $attendee->full_address_as_array() |
|
| 2336 | - ); |
|
| 2337 | - $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce( |
|
| 2338 | - array( |
|
| 2339 | - 'action' => 'edit_attendee', |
|
| 2340 | - 'post' => $attendee->ID(), |
|
| 2341 | - ), |
|
| 2342 | - REG_ADMIN_URL |
|
| 2343 | - ); |
|
| 2344 | - $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2345 | - $att_nmbr++; |
|
| 2346 | - } |
|
| 2347 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 2348 | - } |
|
| 2349 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2350 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2351 | - } |
|
| 2352 | - |
|
| 2353 | - |
|
| 2354 | - /** |
|
| 2355 | - * generates HTML for the Edit Registration side meta box |
|
| 2356 | - * |
|
| 2357 | - * @access public |
|
| 2358 | - * @return void |
|
| 2359 | - * @throws DomainException |
|
| 2360 | - * @throws EE_Error |
|
| 2361 | - */ |
|
| 2362 | - public function _reg_registrant_side_meta_box() |
|
| 2363 | - { |
|
| 2364 | - /*@var $attendee EE_Attendee */ |
|
| 2365 | - $att_check = $this->_registration->attendee(); |
|
| 2366 | - $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
|
| 2367 | - //now let's determine if this is not the primary registration. If it isn't then we set the |
|
| 2368 | - //primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the |
|
| 2369 | - //primary registration object (that way we know if we need to show create button or not) |
|
| 2370 | - if ( ! $this->_registration->is_primary_registrant()) { |
|
| 2371 | - $primary_registration = $this->_registration->get_primary_registration(); |
|
| 2372 | - $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() |
|
| 2373 | - : null; |
|
| 2374 | - if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) { |
|
| 2375 | - //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own |
|
| 2376 | - //custom attendee object so let's not worry about the primary reg. |
|
| 2377 | - $primary_registration = null; |
|
| 2378 | - } |
|
| 2379 | - } else { |
|
| 2380 | - $primary_registration = null; |
|
| 2381 | - } |
|
| 2382 | - $this->_template_args['ATT_ID'] = $attendee->ID(); |
|
| 2383 | - $this->_template_args['fname'] = $attendee->fname(); |
|
| 2384 | - $this->_template_args['lname'] = $attendee->lname(); |
|
| 2385 | - $this->_template_args['email'] = $attendee->email(); |
|
| 2386 | - $this->_template_args['phone'] = $attendee->phone(); |
|
| 2387 | - $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
|
| 2388 | - //edit link |
|
| 2389 | - $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2390 | - 'action' => 'edit_attendee', |
|
| 2391 | - 'post' => $attendee->ID(), |
|
| 2392 | - ), REG_ADMIN_URL); |
|
| 2393 | - $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso'); |
|
| 2394 | - //create link |
|
| 2395 | - $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2396 | - ? EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2397 | - 'action' => 'duplicate_attendee', |
|
| 2398 | - '_REG_ID' => $this->_registration->ID(), |
|
| 2399 | - ), REG_ADMIN_URL) : ''; |
|
| 2400 | - $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso'); |
|
| 2401 | - $this->_template_args['att_check'] = $att_check; |
|
| 2402 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2403 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2404 | - } |
|
| 2405 | - |
|
| 2406 | - |
|
| 2407 | - /** |
|
| 2408 | - * trash or restore registrations |
|
| 2409 | - * |
|
| 2410 | - * @param boolean $trash whether to archive or restore |
|
| 2411 | - * @return void |
|
| 2412 | - * @throws EE_Error |
|
| 2413 | - * @throws RuntimeException |
|
| 2414 | - * @access protected |
|
| 2415 | - */ |
|
| 2416 | - protected function _trash_or_restore_registrations($trash = true) |
|
| 2417 | - { |
|
| 2418 | - //if empty _REG_ID then get out because there's nothing to do |
|
| 2419 | - if (empty($this->_req_data['_REG_ID'])) { |
|
| 2420 | - EE_Error::add_error( |
|
| 2421 | - sprintf( |
|
| 2422 | - esc_html__( |
|
| 2423 | - 'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.', |
|
| 2424 | - 'event_espresso' |
|
| 2425 | - ), |
|
| 2426 | - $trash ? 'trash' : 'restore' |
|
| 2427 | - ), |
|
| 2428 | - __FILE__, __LINE__, __FUNCTION__ |
|
| 2429 | - ); |
|
| 2430 | - $this->_redirect_after_action(false, '', '', array(), true); |
|
| 2431 | - } |
|
| 2432 | - $success = 0; |
|
| 2433 | - $overwrite_msgs = false; |
|
| 2434 | - //Checkboxes |
|
| 2435 | - if ( ! is_array($this->_req_data['_REG_ID'])) { |
|
| 2436 | - $this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']); |
|
| 2437 | - } |
|
| 2438 | - $reg_count = count($this->_req_data['_REG_ID']); |
|
| 2439 | - // cycle thru checkboxes |
|
| 2440 | - foreach ($this->_req_data['_REG_ID'] as $REG_ID) { |
|
| 2441 | - /** @var EE_Registration $REG */ |
|
| 2442 | - $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 2443 | - $payments = $REG->registration_payments(); |
|
| 2444 | - if (! empty($payments)) { |
|
| 2445 | - $name = $REG->attendee() instanceof EE_Attendee |
|
| 2446 | - ? $REG->attendee()->full_name() |
|
| 2447 | - : esc_html__('Unknown Attendee', 'event_espresso'); |
|
| 2448 | - $overwrite_msgs = true; |
|
| 2449 | - EE_Error::add_error( |
|
| 2450 | - sprintf( |
|
| 2451 | - esc_html__( |
|
| 2452 | - 'The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', |
|
| 2453 | - 'event_espresso' |
|
| 2454 | - ), |
|
| 2455 | - $name |
|
| 2456 | - ), |
|
| 2457 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 2458 | - ); |
|
| 2459 | - //can't trash this registration because it has payments. |
|
| 2460 | - continue; |
|
| 2461 | - } |
|
| 2462 | - $updated = $trash ? $REG->delete() : $REG->restore(); |
|
| 2463 | - if ($updated) { |
|
| 2464 | - $success++; |
|
| 2465 | - } |
|
| 2466 | - } |
|
| 2467 | - $this->_redirect_after_action( |
|
| 2468 | - $success === $reg_count, // were ALL registrations affected? |
|
| 2469 | - $success > 1 |
|
| 2470 | - ? esc_html__('Registrations', 'event_espresso') |
|
| 2471 | - : esc_html__('Registration', 'event_espresso'), |
|
| 2472 | - $trash |
|
| 2473 | - ? esc_html__('moved to the trash', 'event_espresso') |
|
| 2474 | - : esc_html__('restored', 'event_espresso'), |
|
| 2475 | - array('action' => 'default'), |
|
| 2476 | - $overwrite_msgs |
|
| 2477 | - ); |
|
| 2478 | - } |
|
| 2479 | - |
|
| 2480 | - |
|
| 2481 | - /** |
|
| 2482 | - * This is used to permanently delete registrations. Note, this will handle not only deleting permanently the |
|
| 2483 | - * registration but also. |
|
| 2484 | - * 1. Removing relations to EE_Attendee |
|
| 2485 | - * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are |
|
| 2486 | - * ALSO trashed. |
|
| 2487 | - * 3. Deleting permanently any related Line items but only if the above conditions are met. |
|
| 2488 | - * 4. Removing relationships between all tickets and the related registrations |
|
| 2489 | - * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.) |
|
| 2490 | - * 6. Deleting permanently any related Checkins. |
|
| 2491 | - * |
|
| 2492 | - * @return void |
|
| 2493 | - * @throws EE_Error |
|
| 2494 | - */ |
|
| 2495 | - protected function _delete_registrations() |
|
| 2496 | - { |
|
| 2497 | - $REG_MDL = EEM_Registration::instance(); |
|
| 2498 | - $success = 1; |
|
| 2499 | - //Checkboxes |
|
| 2500 | - if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
| 2501 | - // if array has more than one element than success message should be plural |
|
| 2502 | - $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
| 2503 | - // cycle thru checkboxes |
|
| 2504 | - while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
| 2505 | - $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2506 | - if ( ! $REG instanceof EE_Registration) { |
|
| 2507 | - continue; |
|
| 2508 | - } |
|
| 2509 | - $deleted = $this->_delete_registration($REG); |
|
| 2510 | - if ( ! $deleted) { |
|
| 2511 | - $success = 0; |
|
| 2512 | - } |
|
| 2513 | - } |
|
| 2514 | - } else { |
|
| 2515 | - // grab single id and delete |
|
| 2516 | - $REG_ID = $this->_req_data['_REG_ID']; |
|
| 2517 | - $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2518 | - $deleted = $this->_delete_registration($REG); |
|
| 2519 | - if ( ! $deleted) { |
|
| 2520 | - $success = 0; |
|
| 2521 | - } |
|
| 2522 | - } |
|
| 2523 | - $what = $success > 1 |
|
| 2524 | - ? esc_html__('Registrations', 'event_espresso') |
|
| 2525 | - : esc_html__('Registration', 'event_espresso'); |
|
| 2526 | - $action_desc = esc_html__('permanently deleted.', 'event_espresso'); |
|
| 2527 | - $this->_redirect_after_action( |
|
| 2528 | - $success, |
|
| 2529 | - $what, |
|
| 2530 | - $action_desc, |
|
| 2531 | - array('action' => 'default'), |
|
| 2532 | - true |
|
| 2533 | - ); |
|
| 2534 | - } |
|
| 2535 | - |
|
| 2536 | - |
|
| 2537 | - /** |
|
| 2538 | - * handles the permanent deletion of a registration. See comments with _delete_registrations() for details on what |
|
| 2539 | - * models get affected. |
|
| 2540 | - * |
|
| 2541 | - * @param EE_Registration $REG registration to be deleted permenantly |
|
| 2542 | - * @return bool true = successful deletion, false = fail. |
|
| 2543 | - * @throws EE_Error |
|
| 2544 | - */ |
|
| 2545 | - protected function _delete_registration(EE_Registration $REG) |
|
| 2546 | - { |
|
| 2547 | - //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related |
|
| 2548 | - //registrations on the transaction that are NOT trashed. |
|
| 2549 | - $TXN = $REG->get_first_related('Transaction'); |
|
| 2550 | - $REGS = $TXN->get_many_related('Registration'); |
|
| 2551 | - $all_trashed = true; |
|
| 2552 | - foreach ($REGS as $registration) { |
|
| 2553 | - if ( ! $registration->get('REG_deleted')) { |
|
| 2554 | - $all_trashed = false; |
|
| 2555 | - } |
|
| 2556 | - } |
|
| 2557 | - if ( ! $all_trashed) { |
|
| 2558 | - EE_Error::add_error( |
|
| 2559 | - esc_html__( |
|
| 2560 | - 'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', |
|
| 2561 | - 'event_espresso' |
|
| 2562 | - ), |
|
| 2563 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 2564 | - ); |
|
| 2565 | - return false; |
|
| 2566 | - } |
|
| 2567 | - //k made it here so that means we can delete all the related transactions and their answers (but let's do them |
|
| 2568 | - //separately from THIS one). |
|
| 2569 | - foreach ($REGS as $registration) { |
|
| 2570 | - //delete related answers |
|
| 2571 | - $registration->delete_related_permanently('Answer'); |
|
| 2572 | - //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
|
| 2573 | - $attendee = $registration->get_first_related('Attendee'); |
|
| 2574 | - if ($attendee instanceof EE_Attendee) { |
|
| 2575 | - $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 2576 | - } |
|
| 2577 | - //now remove relationships to tickets on this registration. |
|
| 2578 | - $registration->_remove_relations('Ticket'); |
|
| 2579 | - //now delete permanently the checkins related to this registration. |
|
| 2580 | - $registration->delete_related_permanently('Checkin'); |
|
| 2581 | - if ($registration->ID() === $REG->ID()) { |
|
| 2582 | - continue; |
|
| 2583 | - } //we don't want to delete permanently the existing registration just yet. |
|
| 2584 | - //remove relation to transaction for these registrations if NOT the existing registrations |
|
| 2585 | - $registration->_remove_relations('Transaction'); |
|
| 2586 | - //delete permanently any related messages. |
|
| 2587 | - $registration->delete_related_permanently('Message'); |
|
| 2588 | - //now delete this registration permanently |
|
| 2589 | - $registration->delete_permanently(); |
|
| 2590 | - } |
|
| 2591 | - //now all related registrations on the transaction are handled. So let's just handle this registration itself |
|
| 2592 | - // (the transaction and line items should be all that's left). |
|
| 2593 | - // delete the line items related to the transaction for this registration. |
|
| 2594 | - $TXN->delete_related_permanently('Line_Item'); |
|
| 2595 | - //we need to remove all the relationships on the transaction |
|
| 2596 | - $TXN->delete_related_permanently('Payment'); |
|
| 2597 | - $TXN->delete_related_permanently('Extra_Meta'); |
|
| 2598 | - $TXN->delete_related_permanently('Message'); |
|
| 2599 | - //now we can delete this REG permanently (and the transaction of course) |
|
| 2600 | - $REG->delete_related_permanently('Transaction'); |
|
| 2601 | - return $REG->delete_permanently(); |
|
| 2602 | - } |
|
| 2603 | - |
|
| 2604 | - |
|
| 2605 | - /** |
|
| 2606 | - * generates HTML for the Register New Attendee Admin page |
|
| 2607 | - * |
|
| 2608 | - * @access private |
|
| 2609 | - * @throws DomainException |
|
| 2610 | - * @throws EE_Error |
|
| 2611 | - */ |
|
| 2612 | - public function new_registration() |
|
| 2613 | - { |
|
| 2614 | - if ( ! $this->_set_reg_event()) { |
|
| 2615 | - throw new EE_Error( |
|
| 2616 | - esc_html__( |
|
| 2617 | - 'Unable to continue with registering because there is no Event ID in the request', |
|
| 2618 | - 'event_espresso' |
|
| 2619 | - ) |
|
| 2620 | - ); |
|
| 2621 | - } |
|
| 2622 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2623 | - // gotta start with a clean slate if we're not coming here via ajax |
|
| 2624 | - if ( ! defined('DOING_AJAX') |
|
| 2625 | - && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error'])) |
|
| 2626 | - ) { |
|
| 2627 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2628 | - } |
|
| 2629 | - $this->_template_args['event_name'] = ''; |
|
| 2630 | - // event name |
|
| 2631 | - if ($this->_reg_event) { |
|
| 2632 | - $this->_template_args['event_name'] = $this->_reg_event->name(); |
|
| 2633 | - $edit_event_url = self::add_query_args_and_nonce(array( |
|
| 2634 | - 'action' => 'edit', |
|
| 2635 | - 'post' => $this->_reg_event->ID(), |
|
| 2636 | - ), EVENTS_ADMIN_URL); |
|
| 2637 | - $edit_event_lnk = '<a href="' |
|
| 2638 | - . $edit_event_url |
|
| 2639 | - . '" title="' |
|
| 2640 | - . esc_attr__('Edit ', 'event_espresso') |
|
| 2641 | - . $this->_reg_event->name() |
|
| 2642 | - . '">' |
|
| 2643 | - . esc_html__('Edit Event', 'event_espresso') |
|
| 2644 | - . '</a>'; |
|
| 2645 | - $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' |
|
| 2646 | - . $edit_event_lnk |
|
| 2647 | - . '</span>'; |
|
| 2648 | - } |
|
| 2649 | - $this->_template_args['step_content'] = $this->_get_registration_step_content(); |
|
| 2650 | - if (defined('DOING_AJAX')) { |
|
| 2651 | - $this->_return_json(); |
|
| 2652 | - } |
|
| 2653 | - // grab header |
|
| 2654 | - $template_path = |
|
| 2655 | - REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
| 2656 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
|
| 2657 | - $this->_template_args, true); |
|
| 2658 | - //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
| 2659 | - // the details template wrapper |
|
| 2660 | - $this->display_admin_page_with_sidebar(); |
|
| 2661 | - } |
|
| 2662 | - |
|
| 2663 | - |
|
| 2664 | - /** |
|
| 2665 | - * This returns the content for a registration step |
|
| 2666 | - * |
|
| 2667 | - * @access protected |
|
| 2668 | - * @return string html |
|
| 2669 | - * @throws DomainException |
|
| 2670 | - * @throws EE_Error |
|
| 2671 | - */ |
|
| 2672 | - protected function _get_registration_step_content() |
|
| 2673 | - { |
|
| 2674 | - if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) { |
|
| 2675 | - $warning_msg = sprintf( |
|
| 2676 | - esc_html__( |
|
| 2677 | - '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s', |
|
| 2678 | - 'event_espresso' |
|
| 2679 | - ), |
|
| 2680 | - '<br />', |
|
| 2681 | - '<h3 class="important-notice">', |
|
| 2682 | - '</h3>', |
|
| 2683 | - '<div class="float-right">', |
|
| 2684 | - '<span id="redirect_timer" class="important-notice">30</span>', |
|
| 2685 | - '</div>', |
|
| 2686 | - '<b>', |
|
| 2687 | - '</b>' |
|
| 2688 | - ); |
|
| 2689 | - return ' |
|
| 2190 | + } |
|
| 2191 | + |
|
| 2192 | + |
|
| 2193 | + /** |
|
| 2194 | + * Updates the registration's custom questions according to the form info, if the form is submitted. |
|
| 2195 | + * If it's not a post, the "view_registrations" route will be called next on the SAME request |
|
| 2196 | + * to display the page |
|
| 2197 | + * |
|
| 2198 | + * @access protected |
|
| 2199 | + * @return void |
|
| 2200 | + * @throws EE_Error |
|
| 2201 | + */ |
|
| 2202 | + protected function _update_attendee_registration_form() |
|
| 2203 | + { |
|
| 2204 | + do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this); |
|
| 2205 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 2206 | + $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 2207 | + $success = $this->_save_reg_custom_questions_form($REG_ID); |
|
| 2208 | + if ($success) { |
|
| 2209 | + $what = esc_html__('Registration Form', 'event_espresso'); |
|
| 2210 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) |
|
| 2211 | + : array('action' => 'default'); |
|
| 2212 | + $this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route); |
|
| 2213 | + } |
|
| 2214 | + } |
|
| 2215 | + } |
|
| 2216 | + |
|
| 2217 | + |
|
| 2218 | + /** |
|
| 2219 | + * Gets the form for saving registrations custom questions (if done |
|
| 2220 | + * previously retrieves the cached form object, which may have validation errors in it) |
|
| 2221 | + * |
|
| 2222 | + * @param int $REG_ID |
|
| 2223 | + * @return EE_Registration_Custom_Questions_Form |
|
| 2224 | + * @throws EE_Error |
|
| 2225 | + */ |
|
| 2226 | + protected function _get_reg_custom_questions_form($REG_ID) |
|
| 2227 | + { |
|
| 2228 | + if ( ! $this->_reg_custom_questions_form) { |
|
| 2229 | + require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 2230 | + $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( |
|
| 2231 | + EEM_Registration::instance()->get_one_by_ID($REG_ID) |
|
| 2232 | + ); |
|
| 2233 | + $this->_reg_custom_questions_form->_construct_finalize(null, null); |
|
| 2234 | + } |
|
| 2235 | + return $this->_reg_custom_questions_form; |
|
| 2236 | + } |
|
| 2237 | + |
|
| 2238 | + |
|
| 2239 | + /** |
|
| 2240 | + * Saves |
|
| 2241 | + * |
|
| 2242 | + * @access private |
|
| 2243 | + * @param bool $REG_ID |
|
| 2244 | + * @return bool |
|
| 2245 | + * @throws EE_Error |
|
| 2246 | + */ |
|
| 2247 | + private function _save_reg_custom_questions_form($REG_ID = false) |
|
| 2248 | + { |
|
| 2249 | + if ( ! $REG_ID) { |
|
| 2250 | + EE_Error::add_error( |
|
| 2251 | + esc_html__( |
|
| 2252 | + 'An error occurred. No registration ID was received.', 'event_espresso'), |
|
| 2253 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 2254 | + ); |
|
| 2255 | + } |
|
| 2256 | + $form = $this->_get_reg_custom_questions_form($REG_ID); |
|
| 2257 | + $form->receive_form_submission($this->_req_data); |
|
| 2258 | + $success = false; |
|
| 2259 | + if ($form->is_valid()) { |
|
| 2260 | + foreach ($form->subforms() as $question_group_id => $question_group_form) { |
|
| 2261 | + foreach ($question_group_form->inputs() as $question_id => $input) { |
|
| 2262 | + $where_conditions = array( |
|
| 2263 | + 'QST_ID' => $question_id, |
|
| 2264 | + 'REG_ID' => $REG_ID, |
|
| 2265 | + ); |
|
| 2266 | + $possibly_new_values = array( |
|
| 2267 | + 'ANS_value' => $input->normalized_value(), |
|
| 2268 | + ); |
|
| 2269 | + $answer = EEM_Answer::instance()->get_one(array($where_conditions)); |
|
| 2270 | + if ($answer instanceof EE_Answer) { |
|
| 2271 | + $success = $answer->save($possibly_new_values); |
|
| 2272 | + } else { |
|
| 2273 | + //insert it then |
|
| 2274 | + $cols_n_vals = array_merge($where_conditions, $possibly_new_values); |
|
| 2275 | + $answer = EE_Answer::new_instance($cols_n_vals); |
|
| 2276 | + $success = $answer->save(); |
|
| 2277 | + } |
|
| 2278 | + } |
|
| 2279 | + } |
|
| 2280 | + } else { |
|
| 2281 | + EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__); |
|
| 2282 | + } |
|
| 2283 | + return $success; |
|
| 2284 | + } |
|
| 2285 | + |
|
| 2286 | + |
|
| 2287 | + /** |
|
| 2288 | + * generates HTML for the Registration main meta box |
|
| 2289 | + * |
|
| 2290 | + * @access public |
|
| 2291 | + * @return void |
|
| 2292 | + * @throws DomainException |
|
| 2293 | + * @throws EE_Error |
|
| 2294 | + */ |
|
| 2295 | + public function _reg_attendees_meta_box() |
|
| 2296 | + { |
|
| 2297 | + $REG = EEM_Registration::instance(); |
|
| 2298 | + //get all other registrations on this transaction, and cache |
|
| 2299 | + //the attendees for them so we don't have to run another query using force_join |
|
| 2300 | + $registrations = $REG->get_all(array( |
|
| 2301 | + array( |
|
| 2302 | + 'TXN_ID' => $this->_registration->transaction_ID(), |
|
| 2303 | + 'REG_ID' => array('!=', $this->_registration->ID()), |
|
| 2304 | + ), |
|
| 2305 | + 'force_join' => array('Attendee'), |
|
| 2306 | + )); |
|
| 2307 | + $this->_template_args['attendees'] = array(); |
|
| 2308 | + $this->_template_args['attendee_notice'] = ''; |
|
| 2309 | + if (empty($registrations) |
|
| 2310 | + || (is_array($registrations) |
|
| 2311 | + && ! EEH_Array::get_one_item_from_array($registrations)) |
|
| 2312 | + ) { |
|
| 2313 | + EE_Error::add_error( |
|
| 2314 | + esc_html__( |
|
| 2315 | + 'There are no records attached to this registration. Something may have gone wrong with the registration', |
|
| 2316 | + 'event_espresso' |
|
| 2317 | + ), __FILE__, __FUNCTION__, __LINE__ |
|
| 2318 | + ); |
|
| 2319 | + $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
|
| 2320 | + } else { |
|
| 2321 | + $att_nmbr = 1; |
|
| 2322 | + foreach ($registrations as $registration) { |
|
| 2323 | + /* @var $registration EE_Registration */ |
|
| 2324 | + $attendee = $registration->attendee() |
|
| 2325 | + ? $registration->attendee() |
|
| 2326 | + : EEM_Attendee::instance() |
|
| 2327 | + ->create_default_object(); |
|
| 2328 | + $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
|
| 2329 | + $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); |
|
| 2330 | + $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); |
|
| 2331 | + $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); |
|
| 2332 | + $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); |
|
| 2333 | + $this->_template_args['attendees'][$att_nmbr]['address'] = implode( |
|
| 2334 | + ', ', |
|
| 2335 | + $attendee->full_address_as_array() |
|
| 2336 | + ); |
|
| 2337 | + $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce( |
|
| 2338 | + array( |
|
| 2339 | + 'action' => 'edit_attendee', |
|
| 2340 | + 'post' => $attendee->ID(), |
|
| 2341 | + ), |
|
| 2342 | + REG_ADMIN_URL |
|
| 2343 | + ); |
|
| 2344 | + $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2345 | + $att_nmbr++; |
|
| 2346 | + } |
|
| 2347 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 2348 | + } |
|
| 2349 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2350 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2351 | + } |
|
| 2352 | + |
|
| 2353 | + |
|
| 2354 | + /** |
|
| 2355 | + * generates HTML for the Edit Registration side meta box |
|
| 2356 | + * |
|
| 2357 | + * @access public |
|
| 2358 | + * @return void |
|
| 2359 | + * @throws DomainException |
|
| 2360 | + * @throws EE_Error |
|
| 2361 | + */ |
|
| 2362 | + public function _reg_registrant_side_meta_box() |
|
| 2363 | + { |
|
| 2364 | + /*@var $attendee EE_Attendee */ |
|
| 2365 | + $att_check = $this->_registration->attendee(); |
|
| 2366 | + $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
|
| 2367 | + //now let's determine if this is not the primary registration. If it isn't then we set the |
|
| 2368 | + //primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the |
|
| 2369 | + //primary registration object (that way we know if we need to show create button or not) |
|
| 2370 | + if ( ! $this->_registration->is_primary_registrant()) { |
|
| 2371 | + $primary_registration = $this->_registration->get_primary_registration(); |
|
| 2372 | + $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() |
|
| 2373 | + : null; |
|
| 2374 | + if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) { |
|
| 2375 | + //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own |
|
| 2376 | + //custom attendee object so let's not worry about the primary reg. |
|
| 2377 | + $primary_registration = null; |
|
| 2378 | + } |
|
| 2379 | + } else { |
|
| 2380 | + $primary_registration = null; |
|
| 2381 | + } |
|
| 2382 | + $this->_template_args['ATT_ID'] = $attendee->ID(); |
|
| 2383 | + $this->_template_args['fname'] = $attendee->fname(); |
|
| 2384 | + $this->_template_args['lname'] = $attendee->lname(); |
|
| 2385 | + $this->_template_args['email'] = $attendee->email(); |
|
| 2386 | + $this->_template_args['phone'] = $attendee->phone(); |
|
| 2387 | + $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
|
| 2388 | + //edit link |
|
| 2389 | + $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2390 | + 'action' => 'edit_attendee', |
|
| 2391 | + 'post' => $attendee->ID(), |
|
| 2392 | + ), REG_ADMIN_URL); |
|
| 2393 | + $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso'); |
|
| 2394 | + //create link |
|
| 2395 | + $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2396 | + ? EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2397 | + 'action' => 'duplicate_attendee', |
|
| 2398 | + '_REG_ID' => $this->_registration->ID(), |
|
| 2399 | + ), REG_ADMIN_URL) : ''; |
|
| 2400 | + $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso'); |
|
| 2401 | + $this->_template_args['att_check'] = $att_check; |
|
| 2402 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2403 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2404 | + } |
|
| 2405 | + |
|
| 2406 | + |
|
| 2407 | + /** |
|
| 2408 | + * trash or restore registrations |
|
| 2409 | + * |
|
| 2410 | + * @param boolean $trash whether to archive or restore |
|
| 2411 | + * @return void |
|
| 2412 | + * @throws EE_Error |
|
| 2413 | + * @throws RuntimeException |
|
| 2414 | + * @access protected |
|
| 2415 | + */ |
|
| 2416 | + protected function _trash_or_restore_registrations($trash = true) |
|
| 2417 | + { |
|
| 2418 | + //if empty _REG_ID then get out because there's nothing to do |
|
| 2419 | + if (empty($this->_req_data['_REG_ID'])) { |
|
| 2420 | + EE_Error::add_error( |
|
| 2421 | + sprintf( |
|
| 2422 | + esc_html__( |
|
| 2423 | + 'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.', |
|
| 2424 | + 'event_espresso' |
|
| 2425 | + ), |
|
| 2426 | + $trash ? 'trash' : 'restore' |
|
| 2427 | + ), |
|
| 2428 | + __FILE__, __LINE__, __FUNCTION__ |
|
| 2429 | + ); |
|
| 2430 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
| 2431 | + } |
|
| 2432 | + $success = 0; |
|
| 2433 | + $overwrite_msgs = false; |
|
| 2434 | + //Checkboxes |
|
| 2435 | + if ( ! is_array($this->_req_data['_REG_ID'])) { |
|
| 2436 | + $this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']); |
|
| 2437 | + } |
|
| 2438 | + $reg_count = count($this->_req_data['_REG_ID']); |
|
| 2439 | + // cycle thru checkboxes |
|
| 2440 | + foreach ($this->_req_data['_REG_ID'] as $REG_ID) { |
|
| 2441 | + /** @var EE_Registration $REG */ |
|
| 2442 | + $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 2443 | + $payments = $REG->registration_payments(); |
|
| 2444 | + if (! empty($payments)) { |
|
| 2445 | + $name = $REG->attendee() instanceof EE_Attendee |
|
| 2446 | + ? $REG->attendee()->full_name() |
|
| 2447 | + : esc_html__('Unknown Attendee', 'event_espresso'); |
|
| 2448 | + $overwrite_msgs = true; |
|
| 2449 | + EE_Error::add_error( |
|
| 2450 | + sprintf( |
|
| 2451 | + esc_html__( |
|
| 2452 | + 'The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', |
|
| 2453 | + 'event_espresso' |
|
| 2454 | + ), |
|
| 2455 | + $name |
|
| 2456 | + ), |
|
| 2457 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 2458 | + ); |
|
| 2459 | + //can't trash this registration because it has payments. |
|
| 2460 | + continue; |
|
| 2461 | + } |
|
| 2462 | + $updated = $trash ? $REG->delete() : $REG->restore(); |
|
| 2463 | + if ($updated) { |
|
| 2464 | + $success++; |
|
| 2465 | + } |
|
| 2466 | + } |
|
| 2467 | + $this->_redirect_after_action( |
|
| 2468 | + $success === $reg_count, // were ALL registrations affected? |
|
| 2469 | + $success > 1 |
|
| 2470 | + ? esc_html__('Registrations', 'event_espresso') |
|
| 2471 | + : esc_html__('Registration', 'event_espresso'), |
|
| 2472 | + $trash |
|
| 2473 | + ? esc_html__('moved to the trash', 'event_espresso') |
|
| 2474 | + : esc_html__('restored', 'event_espresso'), |
|
| 2475 | + array('action' => 'default'), |
|
| 2476 | + $overwrite_msgs |
|
| 2477 | + ); |
|
| 2478 | + } |
|
| 2479 | + |
|
| 2480 | + |
|
| 2481 | + /** |
|
| 2482 | + * This is used to permanently delete registrations. Note, this will handle not only deleting permanently the |
|
| 2483 | + * registration but also. |
|
| 2484 | + * 1. Removing relations to EE_Attendee |
|
| 2485 | + * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are |
|
| 2486 | + * ALSO trashed. |
|
| 2487 | + * 3. Deleting permanently any related Line items but only if the above conditions are met. |
|
| 2488 | + * 4. Removing relationships between all tickets and the related registrations |
|
| 2489 | + * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.) |
|
| 2490 | + * 6. Deleting permanently any related Checkins. |
|
| 2491 | + * |
|
| 2492 | + * @return void |
|
| 2493 | + * @throws EE_Error |
|
| 2494 | + */ |
|
| 2495 | + protected function _delete_registrations() |
|
| 2496 | + { |
|
| 2497 | + $REG_MDL = EEM_Registration::instance(); |
|
| 2498 | + $success = 1; |
|
| 2499 | + //Checkboxes |
|
| 2500 | + if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
| 2501 | + // if array has more than one element than success message should be plural |
|
| 2502 | + $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
| 2503 | + // cycle thru checkboxes |
|
| 2504 | + while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
| 2505 | + $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2506 | + if ( ! $REG instanceof EE_Registration) { |
|
| 2507 | + continue; |
|
| 2508 | + } |
|
| 2509 | + $deleted = $this->_delete_registration($REG); |
|
| 2510 | + if ( ! $deleted) { |
|
| 2511 | + $success = 0; |
|
| 2512 | + } |
|
| 2513 | + } |
|
| 2514 | + } else { |
|
| 2515 | + // grab single id and delete |
|
| 2516 | + $REG_ID = $this->_req_data['_REG_ID']; |
|
| 2517 | + $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2518 | + $deleted = $this->_delete_registration($REG); |
|
| 2519 | + if ( ! $deleted) { |
|
| 2520 | + $success = 0; |
|
| 2521 | + } |
|
| 2522 | + } |
|
| 2523 | + $what = $success > 1 |
|
| 2524 | + ? esc_html__('Registrations', 'event_espresso') |
|
| 2525 | + : esc_html__('Registration', 'event_espresso'); |
|
| 2526 | + $action_desc = esc_html__('permanently deleted.', 'event_espresso'); |
|
| 2527 | + $this->_redirect_after_action( |
|
| 2528 | + $success, |
|
| 2529 | + $what, |
|
| 2530 | + $action_desc, |
|
| 2531 | + array('action' => 'default'), |
|
| 2532 | + true |
|
| 2533 | + ); |
|
| 2534 | + } |
|
| 2535 | + |
|
| 2536 | + |
|
| 2537 | + /** |
|
| 2538 | + * handles the permanent deletion of a registration. See comments with _delete_registrations() for details on what |
|
| 2539 | + * models get affected. |
|
| 2540 | + * |
|
| 2541 | + * @param EE_Registration $REG registration to be deleted permenantly |
|
| 2542 | + * @return bool true = successful deletion, false = fail. |
|
| 2543 | + * @throws EE_Error |
|
| 2544 | + */ |
|
| 2545 | + protected function _delete_registration(EE_Registration $REG) |
|
| 2546 | + { |
|
| 2547 | + //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related |
|
| 2548 | + //registrations on the transaction that are NOT trashed. |
|
| 2549 | + $TXN = $REG->get_first_related('Transaction'); |
|
| 2550 | + $REGS = $TXN->get_many_related('Registration'); |
|
| 2551 | + $all_trashed = true; |
|
| 2552 | + foreach ($REGS as $registration) { |
|
| 2553 | + if ( ! $registration->get('REG_deleted')) { |
|
| 2554 | + $all_trashed = false; |
|
| 2555 | + } |
|
| 2556 | + } |
|
| 2557 | + if ( ! $all_trashed) { |
|
| 2558 | + EE_Error::add_error( |
|
| 2559 | + esc_html__( |
|
| 2560 | + 'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', |
|
| 2561 | + 'event_espresso' |
|
| 2562 | + ), |
|
| 2563 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 2564 | + ); |
|
| 2565 | + return false; |
|
| 2566 | + } |
|
| 2567 | + //k made it here so that means we can delete all the related transactions and their answers (but let's do them |
|
| 2568 | + //separately from THIS one). |
|
| 2569 | + foreach ($REGS as $registration) { |
|
| 2570 | + //delete related answers |
|
| 2571 | + $registration->delete_related_permanently('Answer'); |
|
| 2572 | + //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
|
| 2573 | + $attendee = $registration->get_first_related('Attendee'); |
|
| 2574 | + if ($attendee instanceof EE_Attendee) { |
|
| 2575 | + $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 2576 | + } |
|
| 2577 | + //now remove relationships to tickets on this registration. |
|
| 2578 | + $registration->_remove_relations('Ticket'); |
|
| 2579 | + //now delete permanently the checkins related to this registration. |
|
| 2580 | + $registration->delete_related_permanently('Checkin'); |
|
| 2581 | + if ($registration->ID() === $REG->ID()) { |
|
| 2582 | + continue; |
|
| 2583 | + } //we don't want to delete permanently the existing registration just yet. |
|
| 2584 | + //remove relation to transaction for these registrations if NOT the existing registrations |
|
| 2585 | + $registration->_remove_relations('Transaction'); |
|
| 2586 | + //delete permanently any related messages. |
|
| 2587 | + $registration->delete_related_permanently('Message'); |
|
| 2588 | + //now delete this registration permanently |
|
| 2589 | + $registration->delete_permanently(); |
|
| 2590 | + } |
|
| 2591 | + //now all related registrations on the transaction are handled. So let's just handle this registration itself |
|
| 2592 | + // (the transaction and line items should be all that's left). |
|
| 2593 | + // delete the line items related to the transaction for this registration. |
|
| 2594 | + $TXN->delete_related_permanently('Line_Item'); |
|
| 2595 | + //we need to remove all the relationships on the transaction |
|
| 2596 | + $TXN->delete_related_permanently('Payment'); |
|
| 2597 | + $TXN->delete_related_permanently('Extra_Meta'); |
|
| 2598 | + $TXN->delete_related_permanently('Message'); |
|
| 2599 | + //now we can delete this REG permanently (and the transaction of course) |
|
| 2600 | + $REG->delete_related_permanently('Transaction'); |
|
| 2601 | + return $REG->delete_permanently(); |
|
| 2602 | + } |
|
| 2603 | + |
|
| 2604 | + |
|
| 2605 | + /** |
|
| 2606 | + * generates HTML for the Register New Attendee Admin page |
|
| 2607 | + * |
|
| 2608 | + * @access private |
|
| 2609 | + * @throws DomainException |
|
| 2610 | + * @throws EE_Error |
|
| 2611 | + */ |
|
| 2612 | + public function new_registration() |
|
| 2613 | + { |
|
| 2614 | + if ( ! $this->_set_reg_event()) { |
|
| 2615 | + throw new EE_Error( |
|
| 2616 | + esc_html__( |
|
| 2617 | + 'Unable to continue with registering because there is no Event ID in the request', |
|
| 2618 | + 'event_espresso' |
|
| 2619 | + ) |
|
| 2620 | + ); |
|
| 2621 | + } |
|
| 2622 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2623 | + // gotta start with a clean slate if we're not coming here via ajax |
|
| 2624 | + if ( ! defined('DOING_AJAX') |
|
| 2625 | + && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error'])) |
|
| 2626 | + ) { |
|
| 2627 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2628 | + } |
|
| 2629 | + $this->_template_args['event_name'] = ''; |
|
| 2630 | + // event name |
|
| 2631 | + if ($this->_reg_event) { |
|
| 2632 | + $this->_template_args['event_name'] = $this->_reg_event->name(); |
|
| 2633 | + $edit_event_url = self::add_query_args_and_nonce(array( |
|
| 2634 | + 'action' => 'edit', |
|
| 2635 | + 'post' => $this->_reg_event->ID(), |
|
| 2636 | + ), EVENTS_ADMIN_URL); |
|
| 2637 | + $edit_event_lnk = '<a href="' |
|
| 2638 | + . $edit_event_url |
|
| 2639 | + . '" title="' |
|
| 2640 | + . esc_attr__('Edit ', 'event_espresso') |
|
| 2641 | + . $this->_reg_event->name() |
|
| 2642 | + . '">' |
|
| 2643 | + . esc_html__('Edit Event', 'event_espresso') |
|
| 2644 | + . '</a>'; |
|
| 2645 | + $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' |
|
| 2646 | + . $edit_event_lnk |
|
| 2647 | + . '</span>'; |
|
| 2648 | + } |
|
| 2649 | + $this->_template_args['step_content'] = $this->_get_registration_step_content(); |
|
| 2650 | + if (defined('DOING_AJAX')) { |
|
| 2651 | + $this->_return_json(); |
|
| 2652 | + } |
|
| 2653 | + // grab header |
|
| 2654 | + $template_path = |
|
| 2655 | + REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
| 2656 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
|
| 2657 | + $this->_template_args, true); |
|
| 2658 | + //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
| 2659 | + // the details template wrapper |
|
| 2660 | + $this->display_admin_page_with_sidebar(); |
|
| 2661 | + } |
|
| 2662 | + |
|
| 2663 | + |
|
| 2664 | + /** |
|
| 2665 | + * This returns the content for a registration step |
|
| 2666 | + * |
|
| 2667 | + * @access protected |
|
| 2668 | + * @return string html |
|
| 2669 | + * @throws DomainException |
|
| 2670 | + * @throws EE_Error |
|
| 2671 | + */ |
|
| 2672 | + protected function _get_registration_step_content() |
|
| 2673 | + { |
|
| 2674 | + if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) { |
|
| 2675 | + $warning_msg = sprintf( |
|
| 2676 | + esc_html__( |
|
| 2677 | + '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s', |
|
| 2678 | + 'event_espresso' |
|
| 2679 | + ), |
|
| 2680 | + '<br />', |
|
| 2681 | + '<h3 class="important-notice">', |
|
| 2682 | + '</h3>', |
|
| 2683 | + '<div class="float-right">', |
|
| 2684 | + '<span id="redirect_timer" class="important-notice">30</span>', |
|
| 2685 | + '</div>', |
|
| 2686 | + '<b>', |
|
| 2687 | + '</b>' |
|
| 2688 | + ); |
|
| 2689 | + return ' |
|
| 2690 | 2690 | <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div> |
| 2691 | 2691 | <script > |
| 2692 | 2692 | // WHOAH !!! it appears that someone is using the back button from the Transaction admin page |
@@ -2699,792 +2699,792 @@ discard block |
||
| 2699 | 2699 | } |
| 2700 | 2700 | }, 800 ); |
| 2701 | 2701 | </script >'; |
| 2702 | - } |
|
| 2703 | - $template_args = array( |
|
| 2704 | - 'title' => '', |
|
| 2705 | - 'content' => '', |
|
| 2706 | - 'step_button_text' => '', |
|
| 2707 | - 'show_notification_toggle' => false, |
|
| 2708 | - ); |
|
| 2709 | - //to indicate we're processing a new registration |
|
| 2710 | - $hidden_fields = array( |
|
| 2711 | - 'processing_registration' => array( |
|
| 2712 | - 'type' => 'hidden', |
|
| 2713 | - 'value' => 0, |
|
| 2714 | - ), |
|
| 2715 | - 'event_id' => array( |
|
| 2716 | - 'type' => 'hidden', |
|
| 2717 | - 'value' => $this->_reg_event->ID(), |
|
| 2718 | - ), |
|
| 2719 | - ); |
|
| 2720 | - //if the cart is empty then we know we're at step one so we'll display ticket selector |
|
| 2721 | - $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2722 | - $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2723 | - switch ($step) { |
|
| 2724 | - case 'ticket' : |
|
| 2725 | - $hidden_fields['processing_registration']['value'] = 1; |
|
| 2726 | - $template_args['title'] = esc_html__( |
|
| 2727 | - 'Step One: Select the Ticket for this registration', |
|
| 2728 | - 'event_espresso' |
|
| 2729 | - ); |
|
| 2730 | - $template_args['content'] = |
|
| 2731 | - EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event); |
|
| 2732 | - $template_args['step_button_text'] = esc_html__( |
|
| 2733 | - 'Add Tickets and Continue to Registrant Details', |
|
| 2734 | - 'event_espresso' |
|
| 2735 | - ); |
|
| 2736 | - $template_args['show_notification_toggle'] = false; |
|
| 2737 | - break; |
|
| 2738 | - case 'questions' : |
|
| 2739 | - $hidden_fields['processing_registration']['value'] = 2; |
|
| 2740 | - $template_args['title'] = esc_html__( |
|
| 2741 | - 'Step Two: Add Registrant Details for this Registration', |
|
| 2742 | - 'event_espresso' |
|
| 2743 | - ); |
|
| 2744 | - //in theory we should be able to run EED_SPCO at this point because the cart should have been setup |
|
| 2745 | - // properly by the first process_reg_step run. |
|
| 2746 | - $template_args['content'] = |
|
| 2747 | - EED_Single_Page_Checkout::registration_checkout_for_admin(); |
|
| 2748 | - $template_args['step_button_text'] = esc_html__( |
|
| 2749 | - 'Save Registration and Continue to Details', |
|
| 2750 | - 'event_espresso' |
|
| 2751 | - ); |
|
| 2752 | - $template_args['show_notification_toggle'] = true; |
|
| 2753 | - break; |
|
| 2754 | - } |
|
| 2755 | - //we come back to the process_registration_step route. |
|
| 2756 | - $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields); |
|
| 2757 | - return EEH_Template::display_template( |
|
| 2758 | - REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php', |
|
| 2759 | - $template_args, |
|
| 2760 | - true |
|
| 2761 | - ); |
|
| 2762 | - } |
|
| 2763 | - |
|
| 2764 | - |
|
| 2765 | - /** |
|
| 2766 | - * set_reg_event |
|
| 2767 | - * |
|
| 2768 | - * @access private |
|
| 2769 | - * @return bool |
|
| 2770 | - * @throws EE_Error |
|
| 2771 | - */ |
|
| 2772 | - private function _set_reg_event() |
|
| 2773 | - { |
|
| 2774 | - if (is_object($this->_reg_event)) { |
|
| 2775 | - return true; |
|
| 2776 | - } |
|
| 2777 | - $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false; |
|
| 2778 | - if ( ! $EVT_ID) { |
|
| 2779 | - return false; |
|
| 2780 | - } |
|
| 2781 | - $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2782 | - return true; |
|
| 2783 | - } |
|
| 2784 | - |
|
| 2785 | - |
|
| 2786 | - /** |
|
| 2787 | - * process_reg_step |
|
| 2788 | - * |
|
| 2789 | - * @access public |
|
| 2790 | - * @return string |
|
| 2791 | - * @throws DomainException |
|
| 2792 | - * @throws EE_Error |
|
| 2793 | - * @throws RuntimeException |
|
| 2794 | - */ |
|
| 2795 | - public function process_reg_step() |
|
| 2796 | - { |
|
| 2797 | - EE_System::do_not_cache(); |
|
| 2798 | - $this->_set_reg_event(); |
|
| 2799 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2800 | - EE_Registry::instance()->REQ->set('uts', time()); |
|
| 2801 | - //what step are we on? |
|
| 2802 | - $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2803 | - $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2804 | - //if doing ajax then we need to verify the nonce |
|
| 2805 | - if (defined('DOING_AJAX')) { |
|
| 2806 | - $nonce = isset($this->_req_data[$this->_req_nonce]) |
|
| 2807 | - ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
| 2808 | - $this->_verify_nonce($nonce, $this->_req_nonce); |
|
| 2809 | - } |
|
| 2810 | - switch ($step) { |
|
| 2811 | - case 'ticket' : |
|
| 2812 | - //process ticket selection |
|
| 2813 | - $success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
|
| 2814 | - if ($success) { |
|
| 2815 | - EE_Error::add_success( |
|
| 2816 | - esc_html__( |
|
| 2817 | - 'Tickets Selected. Now complete the registration.', |
|
| 2818 | - 'event_espresso' |
|
| 2819 | - ) |
|
| 2820 | - ); |
|
| 2821 | - } else { |
|
| 2822 | - $query_args['step_error'] = $this->_req_data['step_error'] = true; |
|
| 2823 | - } |
|
| 2824 | - if (defined('DOING_AJAX')) { |
|
| 2825 | - $this->new_registration(); //display next step |
|
| 2826 | - } else { |
|
| 2827 | - $query_args = array( |
|
| 2828 | - 'action' => 'new_registration', |
|
| 2829 | - 'processing_registration' => 1, |
|
| 2830 | - 'event_id' => $this->_reg_event->ID(), |
|
| 2831 | - 'uts' => time(), |
|
| 2832 | - ); |
|
| 2833 | - $this->_redirect_after_action( |
|
| 2834 | - false, |
|
| 2835 | - '', |
|
| 2836 | - '', |
|
| 2837 | - $query_args, |
|
| 2838 | - true |
|
| 2839 | - ); |
|
| 2840 | - } |
|
| 2841 | - break; |
|
| 2842 | - case 'questions' : |
|
| 2843 | - if (! isset( |
|
| 2844 | - $this->_req_data['txn_reg_status_change'], |
|
| 2845 | - $this->_req_data['txn_reg_status_change']['send_notifications']) |
|
| 2846 | - ) { |
|
| 2847 | - add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
| 2848 | - } |
|
| 2849 | - //process registration |
|
| 2850 | - $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
|
| 2851 | - if ($cart instanceof EE_Cart) { |
|
| 2852 | - $grand_total = $cart->get_cart_grand_total(); |
|
| 2853 | - if ($grand_total instanceof EE_Line_Item) { |
|
| 2854 | - $grand_total->save_this_and_descendants_to_txn(); |
|
| 2855 | - } |
|
| 2856 | - } |
|
| 2857 | - if ( ! $transaction instanceof EE_Transaction) { |
|
| 2858 | - $query_args = array( |
|
| 2859 | - 'action' => 'new_registration', |
|
| 2860 | - 'processing_registration' => 2, |
|
| 2861 | - 'event_id' => $this->_reg_event->ID(), |
|
| 2862 | - 'uts' => time(), |
|
| 2863 | - ); |
|
| 2864 | - if (defined('DOING_AJAX')) { |
|
| 2865 | - //display registration form again because there are errors (maybe validation?) |
|
| 2866 | - $this->new_registration(); |
|
| 2867 | - return; |
|
| 2868 | - } else { |
|
| 2869 | - $this->_redirect_after_action( |
|
| 2870 | - false, |
|
| 2871 | - '', |
|
| 2872 | - '', |
|
| 2873 | - $query_args, |
|
| 2874 | - true |
|
| 2875 | - ); |
|
| 2876 | - return; |
|
| 2877 | - } |
|
| 2878 | - } |
|
| 2879 | - // maybe update status, and make sure to save transaction if not done already |
|
| 2880 | - if ( ! $transaction->update_status_based_on_total_paid()) { |
|
| 2881 | - $transaction->save(); |
|
| 2882 | - } |
|
| 2883 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2884 | - $this->_req_data = array(); |
|
| 2885 | - $query_args = array( |
|
| 2886 | - 'action' => 'redirect_to_txn', |
|
| 2887 | - 'TXN_ID' => $transaction->ID(), |
|
| 2888 | - 'EVT_ID' => $this->_reg_event->ID(), |
|
| 2889 | - 'event_name' => urlencode($this->_reg_event->name()), |
|
| 2890 | - 'redirect_from' => 'new_registration', |
|
| 2891 | - ); |
|
| 2892 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2893 | - break; |
|
| 2894 | - } |
|
| 2895 | - //what are you looking here for? Should be nothing to do at this point. |
|
| 2896 | - } |
|
| 2897 | - |
|
| 2898 | - |
|
| 2899 | - /** |
|
| 2900 | - * redirect_to_txn |
|
| 2901 | - * |
|
| 2902 | - * @access public |
|
| 2903 | - * @return void |
|
| 2904 | - * @throws EE_Error |
|
| 2905 | - */ |
|
| 2906 | - public function redirect_to_txn() |
|
| 2907 | - { |
|
| 2908 | - EE_System::do_not_cache(); |
|
| 2909 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2910 | - $query_args = array( |
|
| 2911 | - 'action' => 'view_transaction', |
|
| 2912 | - 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, |
|
| 2913 | - 'page' => 'espresso_transactions', |
|
| 2914 | - ); |
|
| 2915 | - if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { |
|
| 2916 | - $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; |
|
| 2917 | - $query_args['event_name'] = urlencode($this->_req_data['event_name']); |
|
| 2918 | - $query_args['redirect_from'] = $this->_req_data['redirect_from']; |
|
| 2919 | - } |
|
| 2920 | - EE_Error::add_success( |
|
| 2921 | - esc_html__( |
|
| 2922 | - 'Registration Created. Please review the transaction and add any payments as necessary', |
|
| 2923 | - 'event_espresso' |
|
| 2924 | - ) |
|
| 2925 | - ); |
|
| 2926 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2927 | - } |
|
| 2928 | - |
|
| 2929 | - |
|
| 2930 | - /** |
|
| 2931 | - * generates HTML for the Attendee Contact List |
|
| 2932 | - * |
|
| 2933 | - * @access protected |
|
| 2934 | - * @return void |
|
| 2935 | - */ |
|
| 2936 | - protected function _attendee_contact_list_table() |
|
| 2937 | - { |
|
| 2938 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2939 | - $this->_search_btn_label = esc_html__('Contacts', 'event_espresso'); |
|
| 2940 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 2941 | - } |
|
| 2942 | - |
|
| 2943 | - |
|
| 2944 | - /** |
|
| 2945 | - * get_attendees |
|
| 2946 | - * |
|
| 2947 | - * @param $per_page |
|
| 2948 | - * @param bool $count whether to return count or data. |
|
| 2949 | - * @param bool $trash |
|
| 2950 | - * @return array |
|
| 2951 | - * @throws EE_Error |
|
| 2952 | - * @access public |
|
| 2953 | - */ |
|
| 2954 | - public function get_attendees($per_page, $count = false, $trash = false) |
|
| 2955 | - { |
|
| 2956 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2957 | - require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
| 2958 | - $ATT_MDL = EEM_Attendee::instance(); |
|
| 2959 | - $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
| 2960 | - switch ($this->_req_data['orderby']) { |
|
| 2961 | - case 'ATT_ID': |
|
| 2962 | - $orderby = 'ATT_ID'; |
|
| 2963 | - break; |
|
| 2964 | - case 'ATT_fname': |
|
| 2965 | - $orderby = 'ATT_fname'; |
|
| 2966 | - break; |
|
| 2967 | - case 'ATT_email': |
|
| 2968 | - $orderby = 'ATT_email'; |
|
| 2969 | - break; |
|
| 2970 | - case 'ATT_city': |
|
| 2971 | - $orderby = 'ATT_city'; |
|
| 2972 | - break; |
|
| 2973 | - case 'STA_ID': |
|
| 2974 | - $orderby = 'STA_ID'; |
|
| 2975 | - break; |
|
| 2976 | - case 'CNT_ID': |
|
| 2977 | - $orderby = 'CNT_ID'; |
|
| 2978 | - break; |
|
| 2979 | - default: |
|
| 2980 | - $orderby = 'ATT_lname'; |
|
| 2981 | - } |
|
| 2982 | - $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) |
|
| 2983 | - ? $this->_req_data['order'] |
|
| 2984 | - : 'ASC'; |
|
| 2985 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
| 2986 | - ? $this->_req_data['paged'] |
|
| 2987 | - : 1; |
|
| 2988 | - $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
| 2989 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
| 2990 | - ? $this->_req_data['perpage'] |
|
| 2991 | - : $per_page; |
|
| 2992 | - $_where = array(); |
|
| 2993 | - if ( ! empty($this->_req_data['s'])) { |
|
| 2994 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 2995 | - $_where['OR'] = array( |
|
| 2996 | - 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
|
| 2997 | - 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
|
| 2998 | - 'Registration.Event.EVT_short_desc' => array('LIKE', $sstr), |
|
| 2999 | - 'ATT_fname' => array('LIKE', $sstr), |
|
| 3000 | - 'ATT_lname' => array('LIKE', $sstr), |
|
| 3001 | - 'ATT_short_bio' => array('LIKE', $sstr), |
|
| 3002 | - 'ATT_email' => array('LIKE', $sstr), |
|
| 3003 | - 'ATT_address' => array('LIKE', $sstr), |
|
| 3004 | - 'ATT_address2' => array('LIKE', $sstr), |
|
| 3005 | - 'ATT_city' => array('LIKE', $sstr), |
|
| 3006 | - 'Country.CNT_name' => array('LIKE', $sstr), |
|
| 3007 | - 'State.STA_name' => array('LIKE', $sstr), |
|
| 3008 | - 'ATT_phone' => array('LIKE', $sstr), |
|
| 3009 | - 'Registration.REG_final_price' => array('LIKE', $sstr), |
|
| 3010 | - 'Registration.REG_code' => array('LIKE', $sstr), |
|
| 3011 | - 'Registration.REG_count' => array('LIKE', $sstr), |
|
| 3012 | - 'Registration.REG_group_size' => array('LIKE', $sstr), |
|
| 3013 | - ); |
|
| 3014 | - } |
|
| 3015 | - $offset = ($current_page - 1) * $per_page; |
|
| 3016 | - $limit = $count ? null : array($offset, $per_page); |
|
| 3017 | - if ($trash) { |
|
| 3018 | - $_where['status'] = array('!=', 'publish'); |
|
| 3019 | - $all_attendees = $count |
|
| 3020 | - ? $ATT_MDL->count(array( |
|
| 3021 | - $_where, |
|
| 3022 | - 'order_by' => array($orderby => $sort), |
|
| 3023 | - 'limit' => $limit, |
|
| 3024 | - ), 'ATT_ID', true) |
|
| 3025 | - : $ATT_MDL->get_all(array( |
|
| 3026 | - $_where, |
|
| 3027 | - 'order_by' => array($orderby => $sort), |
|
| 3028 | - 'limit' => $limit, |
|
| 3029 | - )); |
|
| 3030 | - } else { |
|
| 3031 | - $_where['status'] = array('IN', array('publish')); |
|
| 3032 | - $all_attendees = $count |
|
| 3033 | - ? $ATT_MDL->count(array( |
|
| 3034 | - $_where, |
|
| 3035 | - 'order_by' => array($orderby => $sort), |
|
| 3036 | - 'limit' => $limit, |
|
| 3037 | - ), 'ATT_ID', true) |
|
| 3038 | - : $ATT_MDL->get_all(array( |
|
| 3039 | - $_where, |
|
| 3040 | - 'order_by' => array($orderby => $sort), |
|
| 3041 | - 'limit' => $limit, |
|
| 3042 | - )); |
|
| 3043 | - } |
|
| 3044 | - return $all_attendees; |
|
| 3045 | - } |
|
| 3046 | - |
|
| 3047 | - |
|
| 3048 | - /** |
|
| 3049 | - * This is just taking care of resending the registration confirmation |
|
| 3050 | - * |
|
| 3051 | - * @access protected |
|
| 3052 | - * @return void |
|
| 3053 | - */ |
|
| 3054 | - protected function _resend_registration() |
|
| 3055 | - { |
|
| 3056 | - $this->_process_resend_registration(); |
|
| 3057 | - $query_args = isset($this->_req_data['redirect_to']) |
|
| 3058 | - ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) |
|
| 3059 | - : array('action' => 'default'); |
|
| 3060 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 3061 | - } |
|
| 3062 | - |
|
| 3063 | - /** |
|
| 3064 | - * Creates a registration report, but accepts the name of a method to use for preparing the query parameters |
|
| 3065 | - * to use when selecting registrations |
|
| 3066 | - * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing |
|
| 3067 | - * the query parameters from the request |
|
| 3068 | - * @return void ends the request with a redirect or download |
|
| 3069 | - */ |
|
| 3070 | - public function _registrations_report_base( $method_name_for_getting_query_params ) |
|
| 3071 | - { |
|
| 3072 | - if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 3073 | - wp_redirect(EE_Admin_Page::add_query_args_and_nonce( |
|
| 3074 | - array( |
|
| 3075 | - 'page' => 'espresso_batch', |
|
| 3076 | - 'batch' => 'file', |
|
| 3077 | - 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 3078 | - 'filters' => urlencode( |
|
| 3079 | - serialize( |
|
| 3080 | - call_user_func( |
|
| 3081 | - array( $this, $method_name_for_getting_query_params ), |
|
| 3082 | - EEH_Array::is_set( |
|
| 3083 | - $this->_req_data, |
|
| 3084 | - 'filters', |
|
| 3085 | - array() |
|
| 3086 | - ) |
|
| 3087 | - ) |
|
| 3088 | - ) |
|
| 3089 | - ), |
|
| 3090 | - 'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false), |
|
| 3091 | - 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'), |
|
| 3092 | - 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 3093 | - ))); |
|
| 3094 | - } else { |
|
| 3095 | - $new_request_args = array( |
|
| 3096 | - 'export' => 'report', |
|
| 3097 | - 'action' => 'registrations_report_for_event', |
|
| 3098 | - 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 3099 | - ); |
|
| 3100 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 3101 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3102 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3103 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3104 | - $EE_Export->export(); |
|
| 3105 | - } |
|
| 3106 | - } |
|
| 3107 | - } |
|
| 3108 | - |
|
| 3109 | - |
|
| 3110 | - |
|
| 3111 | - /** |
|
| 3112 | - * Creates a registration report using only query parameters in the request |
|
| 3113 | - * @return void |
|
| 3114 | - */ |
|
| 3115 | - public function _registrations_report() |
|
| 3116 | - { |
|
| 3117 | - $this->_registrations_report_base('_get_registration_query_parameters'); |
|
| 3118 | - } |
|
| 3119 | - |
|
| 3120 | - |
|
| 3121 | - public function _contact_list_export() |
|
| 3122 | - { |
|
| 3123 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3124 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3125 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3126 | - $EE_Export->export_attendees(); |
|
| 3127 | - } |
|
| 3128 | - } |
|
| 3129 | - |
|
| 3130 | - |
|
| 3131 | - public function _contact_list_report() |
|
| 3132 | - { |
|
| 3133 | - if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 3134 | - wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 3135 | - 'page' => 'espresso_batch', |
|
| 3136 | - 'batch' => 'file', |
|
| 3137 | - 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'), |
|
| 3138 | - 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 3139 | - ))); |
|
| 3140 | - } else { |
|
| 3141 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3142 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3143 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3144 | - $EE_Export->report_attendees(); |
|
| 3145 | - } |
|
| 3146 | - } |
|
| 3147 | - } |
|
| 3148 | - |
|
| 3149 | - |
|
| 3150 | - |
|
| 3151 | - |
|
| 3152 | - |
|
| 3153 | - /*************************************** ATTENDEE DETAILS ***************************************/ |
|
| 3154 | - /** |
|
| 3155 | - * This duplicates the attendee object for the given incoming registration id and attendee_id. |
|
| 3156 | - * |
|
| 3157 | - * @return void |
|
| 3158 | - * @throws EE_Error |
|
| 3159 | - */ |
|
| 3160 | - protected function _duplicate_attendee() |
|
| 3161 | - { |
|
| 3162 | - $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default'; |
|
| 3163 | - //verify we have necessary info |
|
| 3164 | - if (empty($this->_req_data['_REG_ID'])) { |
|
| 3165 | - EE_Error::add_error( |
|
| 3166 | - esc_html__( |
|
| 3167 | - 'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', |
|
| 3168 | - 'event_espresso' |
|
| 3169 | - ), __FILE__, __LINE__, __FUNCTION__ |
|
| 3170 | - ); |
|
| 3171 | - $query_args = array('action' => $action); |
|
| 3172 | - $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 3173 | - } |
|
| 3174 | - //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
|
| 3175 | - $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']); |
|
| 3176 | - $attendee = $registration->attendee(); |
|
| 3177 | - //remove relation of existing attendee on registration |
|
| 3178 | - $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 3179 | - //new attendee |
|
| 3180 | - $new_attendee = clone $attendee; |
|
| 3181 | - $new_attendee->set('ATT_ID', 0); |
|
| 3182 | - $new_attendee->save(); |
|
| 3183 | - //add new attendee to reg |
|
| 3184 | - $registration->_add_relation_to($new_attendee, 'Attendee'); |
|
| 3185 | - EE_Error::add_success( |
|
| 3186 | - esc_html__( |
|
| 3187 | - 'New Contact record created. Now make any edits you wish to make for this contact.', |
|
| 3188 | - 'event_espresso' |
|
| 3189 | - ) |
|
| 3190 | - ); |
|
| 3191 | - //redirect to edit page for attendee |
|
| 3192 | - $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee'); |
|
| 3193 | - $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 3194 | - } |
|
| 3195 | - |
|
| 3196 | - |
|
| 3197 | - //related to cpt routes |
|
| 3198 | - protected function _insert_update_cpt_item($post_id, $post) |
|
| 3199 | - { |
|
| 3200 | - $success = true; |
|
| 3201 | - $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id); |
|
| 3202 | - //for attendee updates |
|
| 3203 | - if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) { |
|
| 3204 | - //note we should only be UPDATING attendees at this point. |
|
| 3205 | - $updated_fields = array( |
|
| 3206 | - 'ATT_fname' => $this->_req_data['ATT_fname'], |
|
| 3207 | - 'ATT_lname' => $this->_req_data['ATT_lname'], |
|
| 3208 | - 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
| 3209 | - 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
|
| 3210 | - 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
|
| 3211 | - 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
|
| 3212 | - 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', |
|
| 3213 | - 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', |
|
| 3214 | - 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', |
|
| 3215 | - 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', |
|
| 3216 | - 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '', |
|
| 3217 | - ); |
|
| 3218 | - foreach ($updated_fields as $field => $value) { |
|
| 3219 | - $attendee->set($field, $value); |
|
| 3220 | - } |
|
| 3221 | - $success = $attendee->save(); |
|
| 3222 | - $attendee_update_callbacks = apply_filters( |
|
| 3223 | - 'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', |
|
| 3224 | - array() |
|
| 3225 | - ); |
|
| 3226 | - foreach ($attendee_update_callbacks as $a_callback) { |
|
| 3227 | - if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) { |
|
| 3228 | - throw new EE_Error( |
|
| 3229 | - sprintf( |
|
| 3230 | - esc_html__( |
|
| 3231 | - 'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', |
|
| 3232 | - 'event_espresso' |
|
| 3233 | - ), |
|
| 3234 | - $a_callback |
|
| 3235 | - ) |
|
| 3236 | - ); |
|
| 3237 | - } |
|
| 3238 | - } |
|
| 3239 | - } |
|
| 3240 | - if ($success === false) { |
|
| 3241 | - EE_Error::add_error( |
|
| 3242 | - esc_html__( |
|
| 3243 | - 'Something went wrong with updating the meta table data for the registration.', |
|
| 3244 | - 'event_espresso' |
|
| 3245 | - ), |
|
| 3246 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 3247 | - ); |
|
| 3248 | - } |
|
| 3249 | - } |
|
| 3250 | - |
|
| 3251 | - |
|
| 3252 | - public function trash_cpt_item($post_id) |
|
| 3253 | - { |
|
| 3254 | - } |
|
| 3255 | - |
|
| 3256 | - |
|
| 3257 | - public function delete_cpt_item($post_id) |
|
| 3258 | - { |
|
| 3259 | - } |
|
| 3260 | - |
|
| 3261 | - |
|
| 3262 | - public function restore_cpt_item($post_id) |
|
| 3263 | - { |
|
| 3264 | - } |
|
| 3265 | - |
|
| 3266 | - |
|
| 3267 | - protected function _restore_cpt_item($post_id, $revision_id) |
|
| 3268 | - { |
|
| 3269 | - } |
|
| 3270 | - |
|
| 3271 | - |
|
| 3272 | - public function attendee_editor_metaboxes() |
|
| 3273 | - { |
|
| 3274 | - $this->verify_cpt_object(); |
|
| 3275 | - remove_meta_box( |
|
| 3276 | - 'postexcerpt', |
|
| 3277 | - esc_html__('Excerpt', 'event_espresso'), |
|
| 3278 | - 'post_excerpt_meta_box', |
|
| 3279 | - $this->_cpt_routes[$this->_req_action], |
|
| 3280 | - 'normal', |
|
| 3281 | - 'core' |
|
| 3282 | - ); |
|
| 3283 | - remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 3284 | - if (post_type_supports('espresso_attendees', 'excerpt')) { |
|
| 3285 | - add_meta_box( |
|
| 3286 | - 'postexcerpt', |
|
| 3287 | - esc_html__('Short Biography', 'event_espresso'), |
|
| 3288 | - 'post_excerpt_meta_box', |
|
| 3289 | - $this->_cpt_routes[$this->_req_action], |
|
| 3290 | - 'normal' |
|
| 3291 | - ); |
|
| 3292 | - } |
|
| 3293 | - if (post_type_supports('espresso_attendees', 'comments')) { |
|
| 3294 | - add_meta_box( |
|
| 3295 | - 'commentsdiv', |
|
| 3296 | - esc_html__('Notes on the Contact', 'event_espresso'), |
|
| 3297 | - 'post_comment_meta_box', |
|
| 3298 | - $this->_cpt_routes[$this->_req_action], |
|
| 3299 | - 'normal', |
|
| 3300 | - 'core' |
|
| 3301 | - ); |
|
| 3302 | - } |
|
| 3303 | - add_meta_box( |
|
| 3304 | - 'attendee_contact_info', |
|
| 3305 | - esc_html__('Contact Info', 'event_espresso'), |
|
| 3306 | - array($this, 'attendee_contact_info'), |
|
| 3307 | - $this->_cpt_routes[$this->_req_action], |
|
| 3308 | - 'side', |
|
| 3309 | - 'core' |
|
| 3310 | - ); |
|
| 3311 | - add_meta_box( |
|
| 3312 | - 'attendee_details_address', |
|
| 3313 | - esc_html__('Address Details', 'event_espresso'), |
|
| 3314 | - array($this, 'attendee_address_details'), |
|
| 3315 | - $this->_cpt_routes[$this->_req_action], |
|
| 3316 | - 'normal', |
|
| 3317 | - 'core' |
|
| 3318 | - ); |
|
| 3319 | - add_meta_box( |
|
| 3320 | - 'attendee_registrations', |
|
| 3321 | - esc_html__('Registrations for this Contact', 'event_espresso'), |
|
| 3322 | - array($this, 'attendee_registrations_meta_box'), |
|
| 3323 | - $this->_cpt_routes[$this->_req_action], |
|
| 3324 | - 'normal', |
|
| 3325 | - 'high' |
|
| 3326 | - ); |
|
| 3327 | - } |
|
| 3328 | - |
|
| 3329 | - |
|
| 3330 | - /** |
|
| 3331 | - * Metabox for attendee contact info |
|
| 3332 | - * |
|
| 3333 | - * @param WP_Post $post wp post object |
|
| 3334 | - * @return string attendee contact info ( and form ) |
|
| 3335 | - * @throws DomainException |
|
| 3336 | - */ |
|
| 3337 | - public function attendee_contact_info($post) |
|
| 3338 | - { |
|
| 3339 | - //get attendee object ( should already have it ) |
|
| 3340 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3341 | - $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
| 3342 | - EEH_Template::display_template($template, $this->_template_args); |
|
| 3343 | - } |
|
| 3344 | - |
|
| 3345 | - |
|
| 3346 | - /** |
|
| 3347 | - * Metabox for attendee details |
|
| 3348 | - * |
|
| 3349 | - * @param WP_Post $post wp post object |
|
| 3350 | - * @return string attendee address details (and form) |
|
| 3351 | - * @throws DomainException |
|
| 3352 | - */ |
|
| 3353 | - public function attendee_address_details($post) |
|
| 3354 | - { |
|
| 3355 | - //get attendee object (should already have it) |
|
| 3356 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3357 | - $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input( |
|
| 3358 | - new EE_Question_Form_Input( |
|
| 3359 | - EE_Question::new_instance( |
|
| 3360 | - array( |
|
| 3361 | - 'QST_ID' => 0, |
|
| 3362 | - 'QST_display_text' => esc_html__('State/Province', 'event_espresso'), |
|
| 3363 | - 'QST_system' => 'admin-state', |
|
| 3364 | - ) |
|
| 3365 | - ), |
|
| 3366 | - EE_Answer::new_instance( |
|
| 3367 | - array( |
|
| 3368 | - 'ANS_ID' => 0, |
|
| 3369 | - 'ANS_value' => $this->_cpt_model_obj->state_ID(), |
|
| 3370 | - ) |
|
| 3371 | - ), |
|
| 3372 | - array( |
|
| 3373 | - 'input_id' => 'STA_ID', |
|
| 3374 | - 'input_name' => 'STA_ID', |
|
| 3375 | - 'input_prefix' => '', |
|
| 3376 | - 'append_qstn_id' => false, |
|
| 3377 | - ) |
|
| 3378 | - ) |
|
| 3379 | - ); |
|
| 3380 | - $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input( |
|
| 3381 | - new EE_Question_Form_Input( |
|
| 3382 | - EE_Question::new_instance( |
|
| 3383 | - array( |
|
| 3384 | - 'QST_ID' => 0, |
|
| 3385 | - 'QST_display_text' => esc_html__('Country', 'event_espresso'), |
|
| 3386 | - 'QST_system' => 'admin-country', |
|
| 3387 | - ) |
|
| 3388 | - ), |
|
| 3389 | - EE_Answer::new_instance( |
|
| 3390 | - array( |
|
| 3391 | - 'ANS_ID' => 0, |
|
| 3392 | - 'ANS_value' => $this->_cpt_model_obj->country_ID(), |
|
| 3393 | - ) |
|
| 3394 | - ), |
|
| 3395 | - array( |
|
| 3396 | - 'input_id' => 'CNT_ISO', |
|
| 3397 | - 'input_name' => 'CNT_ISO', |
|
| 3398 | - 'input_prefix' => '', |
|
| 3399 | - 'append_qstn_id' => false, |
|
| 3400 | - ) |
|
| 3401 | - ) |
|
| 3402 | - ); |
|
| 3403 | - $template = |
|
| 3404 | - REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
| 3405 | - EEH_Template::display_template($template, $this->_template_args); |
|
| 3406 | - } |
|
| 3407 | - |
|
| 3408 | - |
|
| 3409 | - /** |
|
| 3410 | - * _attendee_details |
|
| 3411 | - * |
|
| 3412 | - * @access protected |
|
| 3413 | - * @param $post |
|
| 3414 | - * @return void |
|
| 3415 | - * @throws DomainException |
|
| 3416 | - * @throws EE_Error |
|
| 3417 | - */ |
|
| 3418 | - public function attendee_registrations_meta_box($post) |
|
| 3419 | - { |
|
| 3420 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3421 | - $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
|
| 3422 | - $template = |
|
| 3423 | - REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
| 3424 | - EEH_Template::display_template($template, $this->_template_args); |
|
| 3425 | - } |
|
| 3426 | - |
|
| 3427 | - |
|
| 3428 | - /** |
|
| 3429 | - * add in the form fields for the attendee edit |
|
| 3430 | - * |
|
| 3431 | - * @param WP_Post $post wp post object |
|
| 3432 | - * @return string html for new form. |
|
| 3433 | - * @throws DomainException |
|
| 3434 | - */ |
|
| 3435 | - public function after_title_form_fields($post) |
|
| 3436 | - { |
|
| 3437 | - if ($post->post_type == 'espresso_attendees') { |
|
| 3438 | - $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
| 3439 | - $template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3440 | - EEH_Template::display_template($template, $template_args); |
|
| 3441 | - } |
|
| 3442 | - } |
|
| 3443 | - |
|
| 3444 | - |
|
| 3445 | - /** |
|
| 3446 | - * _trash_or_restore_attendee |
|
| 3447 | - * |
|
| 3448 | - * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 3449 | - * @return void |
|
| 3450 | - * @throws EE_Error |
|
| 3451 | - * @access protected |
|
| 3452 | - */ |
|
| 3453 | - protected function _trash_or_restore_attendees($trash = true) |
|
| 3454 | - { |
|
| 3455 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 3456 | - $ATT_MDL = EEM_Attendee::instance(); |
|
| 3457 | - $success = 1; |
|
| 3458 | - //Checkboxes |
|
| 3459 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 3460 | - // if array has more than one element than success message should be plural |
|
| 3461 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 3462 | - // cycle thru checkboxes |
|
| 3463 | - while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 3464 | - $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) |
|
| 3465 | - : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID); |
|
| 3466 | - if ( ! $updated) { |
|
| 3467 | - $success = 0; |
|
| 3468 | - } |
|
| 3469 | - } |
|
| 3470 | - } else { |
|
| 3471 | - // grab single id and delete |
|
| 3472 | - $ATT_ID = absint($this->_req_data['ATT_ID']); |
|
| 3473 | - //get attendee |
|
| 3474 | - $att = $ATT_MDL->get_one_by_ID($ATT_ID); |
|
| 3475 | - $updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
|
| 3476 | - $updated = $att->save(); |
|
| 3477 | - if ( ! $updated) { |
|
| 3478 | - $success = 0; |
|
| 3479 | - } |
|
| 3480 | - } |
|
| 3481 | - $what = $success > 1 |
|
| 3482 | - ? esc_html__('Contacts', 'event_espresso') |
|
| 3483 | - : esc_html__('Contact', 'event_espresso'); |
|
| 3484 | - $action_desc = $trash |
|
| 3485 | - ? esc_html__('moved to the trash', 'event_espresso') |
|
| 3486 | - : esc_html__('restored', 'event_espresso'); |
|
| 3487 | - $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list')); |
|
| 3488 | - } |
|
| 2702 | + } |
|
| 2703 | + $template_args = array( |
|
| 2704 | + 'title' => '', |
|
| 2705 | + 'content' => '', |
|
| 2706 | + 'step_button_text' => '', |
|
| 2707 | + 'show_notification_toggle' => false, |
|
| 2708 | + ); |
|
| 2709 | + //to indicate we're processing a new registration |
|
| 2710 | + $hidden_fields = array( |
|
| 2711 | + 'processing_registration' => array( |
|
| 2712 | + 'type' => 'hidden', |
|
| 2713 | + 'value' => 0, |
|
| 2714 | + ), |
|
| 2715 | + 'event_id' => array( |
|
| 2716 | + 'type' => 'hidden', |
|
| 2717 | + 'value' => $this->_reg_event->ID(), |
|
| 2718 | + ), |
|
| 2719 | + ); |
|
| 2720 | + //if the cart is empty then we know we're at step one so we'll display ticket selector |
|
| 2721 | + $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2722 | + $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2723 | + switch ($step) { |
|
| 2724 | + case 'ticket' : |
|
| 2725 | + $hidden_fields['processing_registration']['value'] = 1; |
|
| 2726 | + $template_args['title'] = esc_html__( |
|
| 2727 | + 'Step One: Select the Ticket for this registration', |
|
| 2728 | + 'event_espresso' |
|
| 2729 | + ); |
|
| 2730 | + $template_args['content'] = |
|
| 2731 | + EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event); |
|
| 2732 | + $template_args['step_button_text'] = esc_html__( |
|
| 2733 | + 'Add Tickets and Continue to Registrant Details', |
|
| 2734 | + 'event_espresso' |
|
| 2735 | + ); |
|
| 2736 | + $template_args['show_notification_toggle'] = false; |
|
| 2737 | + break; |
|
| 2738 | + case 'questions' : |
|
| 2739 | + $hidden_fields['processing_registration']['value'] = 2; |
|
| 2740 | + $template_args['title'] = esc_html__( |
|
| 2741 | + 'Step Two: Add Registrant Details for this Registration', |
|
| 2742 | + 'event_espresso' |
|
| 2743 | + ); |
|
| 2744 | + //in theory we should be able to run EED_SPCO at this point because the cart should have been setup |
|
| 2745 | + // properly by the first process_reg_step run. |
|
| 2746 | + $template_args['content'] = |
|
| 2747 | + EED_Single_Page_Checkout::registration_checkout_for_admin(); |
|
| 2748 | + $template_args['step_button_text'] = esc_html__( |
|
| 2749 | + 'Save Registration and Continue to Details', |
|
| 2750 | + 'event_espresso' |
|
| 2751 | + ); |
|
| 2752 | + $template_args['show_notification_toggle'] = true; |
|
| 2753 | + break; |
|
| 2754 | + } |
|
| 2755 | + //we come back to the process_registration_step route. |
|
| 2756 | + $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields); |
|
| 2757 | + return EEH_Template::display_template( |
|
| 2758 | + REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php', |
|
| 2759 | + $template_args, |
|
| 2760 | + true |
|
| 2761 | + ); |
|
| 2762 | + } |
|
| 2763 | + |
|
| 2764 | + |
|
| 2765 | + /** |
|
| 2766 | + * set_reg_event |
|
| 2767 | + * |
|
| 2768 | + * @access private |
|
| 2769 | + * @return bool |
|
| 2770 | + * @throws EE_Error |
|
| 2771 | + */ |
|
| 2772 | + private function _set_reg_event() |
|
| 2773 | + { |
|
| 2774 | + if (is_object($this->_reg_event)) { |
|
| 2775 | + return true; |
|
| 2776 | + } |
|
| 2777 | + $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false; |
|
| 2778 | + if ( ! $EVT_ID) { |
|
| 2779 | + return false; |
|
| 2780 | + } |
|
| 2781 | + $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2782 | + return true; |
|
| 2783 | + } |
|
| 2784 | + |
|
| 2785 | + |
|
| 2786 | + /** |
|
| 2787 | + * process_reg_step |
|
| 2788 | + * |
|
| 2789 | + * @access public |
|
| 2790 | + * @return string |
|
| 2791 | + * @throws DomainException |
|
| 2792 | + * @throws EE_Error |
|
| 2793 | + * @throws RuntimeException |
|
| 2794 | + */ |
|
| 2795 | + public function process_reg_step() |
|
| 2796 | + { |
|
| 2797 | + EE_System::do_not_cache(); |
|
| 2798 | + $this->_set_reg_event(); |
|
| 2799 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2800 | + EE_Registry::instance()->REQ->set('uts', time()); |
|
| 2801 | + //what step are we on? |
|
| 2802 | + $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2803 | + $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2804 | + //if doing ajax then we need to verify the nonce |
|
| 2805 | + if (defined('DOING_AJAX')) { |
|
| 2806 | + $nonce = isset($this->_req_data[$this->_req_nonce]) |
|
| 2807 | + ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
| 2808 | + $this->_verify_nonce($nonce, $this->_req_nonce); |
|
| 2809 | + } |
|
| 2810 | + switch ($step) { |
|
| 2811 | + case 'ticket' : |
|
| 2812 | + //process ticket selection |
|
| 2813 | + $success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
|
| 2814 | + if ($success) { |
|
| 2815 | + EE_Error::add_success( |
|
| 2816 | + esc_html__( |
|
| 2817 | + 'Tickets Selected. Now complete the registration.', |
|
| 2818 | + 'event_espresso' |
|
| 2819 | + ) |
|
| 2820 | + ); |
|
| 2821 | + } else { |
|
| 2822 | + $query_args['step_error'] = $this->_req_data['step_error'] = true; |
|
| 2823 | + } |
|
| 2824 | + if (defined('DOING_AJAX')) { |
|
| 2825 | + $this->new_registration(); //display next step |
|
| 2826 | + } else { |
|
| 2827 | + $query_args = array( |
|
| 2828 | + 'action' => 'new_registration', |
|
| 2829 | + 'processing_registration' => 1, |
|
| 2830 | + 'event_id' => $this->_reg_event->ID(), |
|
| 2831 | + 'uts' => time(), |
|
| 2832 | + ); |
|
| 2833 | + $this->_redirect_after_action( |
|
| 2834 | + false, |
|
| 2835 | + '', |
|
| 2836 | + '', |
|
| 2837 | + $query_args, |
|
| 2838 | + true |
|
| 2839 | + ); |
|
| 2840 | + } |
|
| 2841 | + break; |
|
| 2842 | + case 'questions' : |
|
| 2843 | + if (! isset( |
|
| 2844 | + $this->_req_data['txn_reg_status_change'], |
|
| 2845 | + $this->_req_data['txn_reg_status_change']['send_notifications']) |
|
| 2846 | + ) { |
|
| 2847 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
| 2848 | + } |
|
| 2849 | + //process registration |
|
| 2850 | + $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
|
| 2851 | + if ($cart instanceof EE_Cart) { |
|
| 2852 | + $grand_total = $cart->get_cart_grand_total(); |
|
| 2853 | + if ($grand_total instanceof EE_Line_Item) { |
|
| 2854 | + $grand_total->save_this_and_descendants_to_txn(); |
|
| 2855 | + } |
|
| 2856 | + } |
|
| 2857 | + if ( ! $transaction instanceof EE_Transaction) { |
|
| 2858 | + $query_args = array( |
|
| 2859 | + 'action' => 'new_registration', |
|
| 2860 | + 'processing_registration' => 2, |
|
| 2861 | + 'event_id' => $this->_reg_event->ID(), |
|
| 2862 | + 'uts' => time(), |
|
| 2863 | + ); |
|
| 2864 | + if (defined('DOING_AJAX')) { |
|
| 2865 | + //display registration form again because there are errors (maybe validation?) |
|
| 2866 | + $this->new_registration(); |
|
| 2867 | + return; |
|
| 2868 | + } else { |
|
| 2869 | + $this->_redirect_after_action( |
|
| 2870 | + false, |
|
| 2871 | + '', |
|
| 2872 | + '', |
|
| 2873 | + $query_args, |
|
| 2874 | + true |
|
| 2875 | + ); |
|
| 2876 | + return; |
|
| 2877 | + } |
|
| 2878 | + } |
|
| 2879 | + // maybe update status, and make sure to save transaction if not done already |
|
| 2880 | + if ( ! $transaction->update_status_based_on_total_paid()) { |
|
| 2881 | + $transaction->save(); |
|
| 2882 | + } |
|
| 2883 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2884 | + $this->_req_data = array(); |
|
| 2885 | + $query_args = array( |
|
| 2886 | + 'action' => 'redirect_to_txn', |
|
| 2887 | + 'TXN_ID' => $transaction->ID(), |
|
| 2888 | + 'EVT_ID' => $this->_reg_event->ID(), |
|
| 2889 | + 'event_name' => urlencode($this->_reg_event->name()), |
|
| 2890 | + 'redirect_from' => 'new_registration', |
|
| 2891 | + ); |
|
| 2892 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2893 | + break; |
|
| 2894 | + } |
|
| 2895 | + //what are you looking here for? Should be nothing to do at this point. |
|
| 2896 | + } |
|
| 2897 | + |
|
| 2898 | + |
|
| 2899 | + /** |
|
| 2900 | + * redirect_to_txn |
|
| 2901 | + * |
|
| 2902 | + * @access public |
|
| 2903 | + * @return void |
|
| 2904 | + * @throws EE_Error |
|
| 2905 | + */ |
|
| 2906 | + public function redirect_to_txn() |
|
| 2907 | + { |
|
| 2908 | + EE_System::do_not_cache(); |
|
| 2909 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2910 | + $query_args = array( |
|
| 2911 | + 'action' => 'view_transaction', |
|
| 2912 | + 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, |
|
| 2913 | + 'page' => 'espresso_transactions', |
|
| 2914 | + ); |
|
| 2915 | + if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { |
|
| 2916 | + $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; |
|
| 2917 | + $query_args['event_name'] = urlencode($this->_req_data['event_name']); |
|
| 2918 | + $query_args['redirect_from'] = $this->_req_data['redirect_from']; |
|
| 2919 | + } |
|
| 2920 | + EE_Error::add_success( |
|
| 2921 | + esc_html__( |
|
| 2922 | + 'Registration Created. Please review the transaction and add any payments as necessary', |
|
| 2923 | + 'event_espresso' |
|
| 2924 | + ) |
|
| 2925 | + ); |
|
| 2926 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2927 | + } |
|
| 2928 | + |
|
| 2929 | + |
|
| 2930 | + /** |
|
| 2931 | + * generates HTML for the Attendee Contact List |
|
| 2932 | + * |
|
| 2933 | + * @access protected |
|
| 2934 | + * @return void |
|
| 2935 | + */ |
|
| 2936 | + protected function _attendee_contact_list_table() |
|
| 2937 | + { |
|
| 2938 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2939 | + $this->_search_btn_label = esc_html__('Contacts', 'event_espresso'); |
|
| 2940 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 2941 | + } |
|
| 2942 | + |
|
| 2943 | + |
|
| 2944 | + /** |
|
| 2945 | + * get_attendees |
|
| 2946 | + * |
|
| 2947 | + * @param $per_page |
|
| 2948 | + * @param bool $count whether to return count or data. |
|
| 2949 | + * @param bool $trash |
|
| 2950 | + * @return array |
|
| 2951 | + * @throws EE_Error |
|
| 2952 | + * @access public |
|
| 2953 | + */ |
|
| 2954 | + public function get_attendees($per_page, $count = false, $trash = false) |
|
| 2955 | + { |
|
| 2956 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2957 | + require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
| 2958 | + $ATT_MDL = EEM_Attendee::instance(); |
|
| 2959 | + $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
| 2960 | + switch ($this->_req_data['orderby']) { |
|
| 2961 | + case 'ATT_ID': |
|
| 2962 | + $orderby = 'ATT_ID'; |
|
| 2963 | + break; |
|
| 2964 | + case 'ATT_fname': |
|
| 2965 | + $orderby = 'ATT_fname'; |
|
| 2966 | + break; |
|
| 2967 | + case 'ATT_email': |
|
| 2968 | + $orderby = 'ATT_email'; |
|
| 2969 | + break; |
|
| 2970 | + case 'ATT_city': |
|
| 2971 | + $orderby = 'ATT_city'; |
|
| 2972 | + break; |
|
| 2973 | + case 'STA_ID': |
|
| 2974 | + $orderby = 'STA_ID'; |
|
| 2975 | + break; |
|
| 2976 | + case 'CNT_ID': |
|
| 2977 | + $orderby = 'CNT_ID'; |
|
| 2978 | + break; |
|
| 2979 | + default: |
|
| 2980 | + $orderby = 'ATT_lname'; |
|
| 2981 | + } |
|
| 2982 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) |
|
| 2983 | + ? $this->_req_data['order'] |
|
| 2984 | + : 'ASC'; |
|
| 2985 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
| 2986 | + ? $this->_req_data['paged'] |
|
| 2987 | + : 1; |
|
| 2988 | + $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
| 2989 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
| 2990 | + ? $this->_req_data['perpage'] |
|
| 2991 | + : $per_page; |
|
| 2992 | + $_where = array(); |
|
| 2993 | + if ( ! empty($this->_req_data['s'])) { |
|
| 2994 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 2995 | + $_where['OR'] = array( |
|
| 2996 | + 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
|
| 2997 | + 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
|
| 2998 | + 'Registration.Event.EVT_short_desc' => array('LIKE', $sstr), |
|
| 2999 | + 'ATT_fname' => array('LIKE', $sstr), |
|
| 3000 | + 'ATT_lname' => array('LIKE', $sstr), |
|
| 3001 | + 'ATT_short_bio' => array('LIKE', $sstr), |
|
| 3002 | + 'ATT_email' => array('LIKE', $sstr), |
|
| 3003 | + 'ATT_address' => array('LIKE', $sstr), |
|
| 3004 | + 'ATT_address2' => array('LIKE', $sstr), |
|
| 3005 | + 'ATT_city' => array('LIKE', $sstr), |
|
| 3006 | + 'Country.CNT_name' => array('LIKE', $sstr), |
|
| 3007 | + 'State.STA_name' => array('LIKE', $sstr), |
|
| 3008 | + 'ATT_phone' => array('LIKE', $sstr), |
|
| 3009 | + 'Registration.REG_final_price' => array('LIKE', $sstr), |
|
| 3010 | + 'Registration.REG_code' => array('LIKE', $sstr), |
|
| 3011 | + 'Registration.REG_count' => array('LIKE', $sstr), |
|
| 3012 | + 'Registration.REG_group_size' => array('LIKE', $sstr), |
|
| 3013 | + ); |
|
| 3014 | + } |
|
| 3015 | + $offset = ($current_page - 1) * $per_page; |
|
| 3016 | + $limit = $count ? null : array($offset, $per_page); |
|
| 3017 | + if ($trash) { |
|
| 3018 | + $_where['status'] = array('!=', 'publish'); |
|
| 3019 | + $all_attendees = $count |
|
| 3020 | + ? $ATT_MDL->count(array( |
|
| 3021 | + $_where, |
|
| 3022 | + 'order_by' => array($orderby => $sort), |
|
| 3023 | + 'limit' => $limit, |
|
| 3024 | + ), 'ATT_ID', true) |
|
| 3025 | + : $ATT_MDL->get_all(array( |
|
| 3026 | + $_where, |
|
| 3027 | + 'order_by' => array($orderby => $sort), |
|
| 3028 | + 'limit' => $limit, |
|
| 3029 | + )); |
|
| 3030 | + } else { |
|
| 3031 | + $_where['status'] = array('IN', array('publish')); |
|
| 3032 | + $all_attendees = $count |
|
| 3033 | + ? $ATT_MDL->count(array( |
|
| 3034 | + $_where, |
|
| 3035 | + 'order_by' => array($orderby => $sort), |
|
| 3036 | + 'limit' => $limit, |
|
| 3037 | + ), 'ATT_ID', true) |
|
| 3038 | + : $ATT_MDL->get_all(array( |
|
| 3039 | + $_where, |
|
| 3040 | + 'order_by' => array($orderby => $sort), |
|
| 3041 | + 'limit' => $limit, |
|
| 3042 | + )); |
|
| 3043 | + } |
|
| 3044 | + return $all_attendees; |
|
| 3045 | + } |
|
| 3046 | + |
|
| 3047 | + |
|
| 3048 | + /** |
|
| 3049 | + * This is just taking care of resending the registration confirmation |
|
| 3050 | + * |
|
| 3051 | + * @access protected |
|
| 3052 | + * @return void |
|
| 3053 | + */ |
|
| 3054 | + protected function _resend_registration() |
|
| 3055 | + { |
|
| 3056 | + $this->_process_resend_registration(); |
|
| 3057 | + $query_args = isset($this->_req_data['redirect_to']) |
|
| 3058 | + ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) |
|
| 3059 | + : array('action' => 'default'); |
|
| 3060 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 3061 | + } |
|
| 3062 | + |
|
| 3063 | + /** |
|
| 3064 | + * Creates a registration report, but accepts the name of a method to use for preparing the query parameters |
|
| 3065 | + * to use when selecting registrations |
|
| 3066 | + * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing |
|
| 3067 | + * the query parameters from the request |
|
| 3068 | + * @return void ends the request with a redirect or download |
|
| 3069 | + */ |
|
| 3070 | + public function _registrations_report_base( $method_name_for_getting_query_params ) |
|
| 3071 | + { |
|
| 3072 | + if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 3073 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce( |
|
| 3074 | + array( |
|
| 3075 | + 'page' => 'espresso_batch', |
|
| 3076 | + 'batch' => 'file', |
|
| 3077 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 3078 | + 'filters' => urlencode( |
|
| 3079 | + serialize( |
|
| 3080 | + call_user_func( |
|
| 3081 | + array( $this, $method_name_for_getting_query_params ), |
|
| 3082 | + EEH_Array::is_set( |
|
| 3083 | + $this->_req_data, |
|
| 3084 | + 'filters', |
|
| 3085 | + array() |
|
| 3086 | + ) |
|
| 3087 | + ) |
|
| 3088 | + ) |
|
| 3089 | + ), |
|
| 3090 | + 'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false), |
|
| 3091 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'), |
|
| 3092 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 3093 | + ))); |
|
| 3094 | + } else { |
|
| 3095 | + $new_request_args = array( |
|
| 3096 | + 'export' => 'report', |
|
| 3097 | + 'action' => 'registrations_report_for_event', |
|
| 3098 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 3099 | + ); |
|
| 3100 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 3101 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3102 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3103 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3104 | + $EE_Export->export(); |
|
| 3105 | + } |
|
| 3106 | + } |
|
| 3107 | + } |
|
| 3108 | + |
|
| 3109 | + |
|
| 3110 | + |
|
| 3111 | + /** |
|
| 3112 | + * Creates a registration report using only query parameters in the request |
|
| 3113 | + * @return void |
|
| 3114 | + */ |
|
| 3115 | + public function _registrations_report() |
|
| 3116 | + { |
|
| 3117 | + $this->_registrations_report_base('_get_registration_query_parameters'); |
|
| 3118 | + } |
|
| 3119 | + |
|
| 3120 | + |
|
| 3121 | + public function _contact_list_export() |
|
| 3122 | + { |
|
| 3123 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3124 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3125 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3126 | + $EE_Export->export_attendees(); |
|
| 3127 | + } |
|
| 3128 | + } |
|
| 3129 | + |
|
| 3130 | + |
|
| 3131 | + public function _contact_list_report() |
|
| 3132 | + { |
|
| 3133 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 3134 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 3135 | + 'page' => 'espresso_batch', |
|
| 3136 | + 'batch' => 'file', |
|
| 3137 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'), |
|
| 3138 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 3139 | + ))); |
|
| 3140 | + } else { |
|
| 3141 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 3142 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 3143 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 3144 | + $EE_Export->report_attendees(); |
|
| 3145 | + } |
|
| 3146 | + } |
|
| 3147 | + } |
|
| 3148 | + |
|
| 3149 | + |
|
| 3150 | + |
|
| 3151 | + |
|
| 3152 | + |
|
| 3153 | + /*************************************** ATTENDEE DETAILS ***************************************/ |
|
| 3154 | + /** |
|
| 3155 | + * This duplicates the attendee object for the given incoming registration id and attendee_id. |
|
| 3156 | + * |
|
| 3157 | + * @return void |
|
| 3158 | + * @throws EE_Error |
|
| 3159 | + */ |
|
| 3160 | + protected function _duplicate_attendee() |
|
| 3161 | + { |
|
| 3162 | + $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default'; |
|
| 3163 | + //verify we have necessary info |
|
| 3164 | + if (empty($this->_req_data['_REG_ID'])) { |
|
| 3165 | + EE_Error::add_error( |
|
| 3166 | + esc_html__( |
|
| 3167 | + 'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', |
|
| 3168 | + 'event_espresso' |
|
| 3169 | + ), __FILE__, __LINE__, __FUNCTION__ |
|
| 3170 | + ); |
|
| 3171 | + $query_args = array('action' => $action); |
|
| 3172 | + $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 3173 | + } |
|
| 3174 | + //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
|
| 3175 | + $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']); |
|
| 3176 | + $attendee = $registration->attendee(); |
|
| 3177 | + //remove relation of existing attendee on registration |
|
| 3178 | + $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 3179 | + //new attendee |
|
| 3180 | + $new_attendee = clone $attendee; |
|
| 3181 | + $new_attendee->set('ATT_ID', 0); |
|
| 3182 | + $new_attendee->save(); |
|
| 3183 | + //add new attendee to reg |
|
| 3184 | + $registration->_add_relation_to($new_attendee, 'Attendee'); |
|
| 3185 | + EE_Error::add_success( |
|
| 3186 | + esc_html__( |
|
| 3187 | + 'New Contact record created. Now make any edits you wish to make for this contact.', |
|
| 3188 | + 'event_espresso' |
|
| 3189 | + ) |
|
| 3190 | + ); |
|
| 3191 | + //redirect to edit page for attendee |
|
| 3192 | + $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee'); |
|
| 3193 | + $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 3194 | + } |
|
| 3195 | + |
|
| 3196 | + |
|
| 3197 | + //related to cpt routes |
|
| 3198 | + protected function _insert_update_cpt_item($post_id, $post) |
|
| 3199 | + { |
|
| 3200 | + $success = true; |
|
| 3201 | + $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id); |
|
| 3202 | + //for attendee updates |
|
| 3203 | + if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) { |
|
| 3204 | + //note we should only be UPDATING attendees at this point. |
|
| 3205 | + $updated_fields = array( |
|
| 3206 | + 'ATT_fname' => $this->_req_data['ATT_fname'], |
|
| 3207 | + 'ATT_lname' => $this->_req_data['ATT_lname'], |
|
| 3208 | + 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
| 3209 | + 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
|
| 3210 | + 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
|
| 3211 | + 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
|
| 3212 | + 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', |
|
| 3213 | + 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', |
|
| 3214 | + 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', |
|
| 3215 | + 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', |
|
| 3216 | + 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '', |
|
| 3217 | + ); |
|
| 3218 | + foreach ($updated_fields as $field => $value) { |
|
| 3219 | + $attendee->set($field, $value); |
|
| 3220 | + } |
|
| 3221 | + $success = $attendee->save(); |
|
| 3222 | + $attendee_update_callbacks = apply_filters( |
|
| 3223 | + 'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', |
|
| 3224 | + array() |
|
| 3225 | + ); |
|
| 3226 | + foreach ($attendee_update_callbacks as $a_callback) { |
|
| 3227 | + if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) { |
|
| 3228 | + throw new EE_Error( |
|
| 3229 | + sprintf( |
|
| 3230 | + esc_html__( |
|
| 3231 | + 'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', |
|
| 3232 | + 'event_espresso' |
|
| 3233 | + ), |
|
| 3234 | + $a_callback |
|
| 3235 | + ) |
|
| 3236 | + ); |
|
| 3237 | + } |
|
| 3238 | + } |
|
| 3239 | + } |
|
| 3240 | + if ($success === false) { |
|
| 3241 | + EE_Error::add_error( |
|
| 3242 | + esc_html__( |
|
| 3243 | + 'Something went wrong with updating the meta table data for the registration.', |
|
| 3244 | + 'event_espresso' |
|
| 3245 | + ), |
|
| 3246 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 3247 | + ); |
|
| 3248 | + } |
|
| 3249 | + } |
|
| 3250 | + |
|
| 3251 | + |
|
| 3252 | + public function trash_cpt_item($post_id) |
|
| 3253 | + { |
|
| 3254 | + } |
|
| 3255 | + |
|
| 3256 | + |
|
| 3257 | + public function delete_cpt_item($post_id) |
|
| 3258 | + { |
|
| 3259 | + } |
|
| 3260 | + |
|
| 3261 | + |
|
| 3262 | + public function restore_cpt_item($post_id) |
|
| 3263 | + { |
|
| 3264 | + } |
|
| 3265 | + |
|
| 3266 | + |
|
| 3267 | + protected function _restore_cpt_item($post_id, $revision_id) |
|
| 3268 | + { |
|
| 3269 | + } |
|
| 3270 | + |
|
| 3271 | + |
|
| 3272 | + public function attendee_editor_metaboxes() |
|
| 3273 | + { |
|
| 3274 | + $this->verify_cpt_object(); |
|
| 3275 | + remove_meta_box( |
|
| 3276 | + 'postexcerpt', |
|
| 3277 | + esc_html__('Excerpt', 'event_espresso'), |
|
| 3278 | + 'post_excerpt_meta_box', |
|
| 3279 | + $this->_cpt_routes[$this->_req_action], |
|
| 3280 | + 'normal', |
|
| 3281 | + 'core' |
|
| 3282 | + ); |
|
| 3283 | + remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 3284 | + if (post_type_supports('espresso_attendees', 'excerpt')) { |
|
| 3285 | + add_meta_box( |
|
| 3286 | + 'postexcerpt', |
|
| 3287 | + esc_html__('Short Biography', 'event_espresso'), |
|
| 3288 | + 'post_excerpt_meta_box', |
|
| 3289 | + $this->_cpt_routes[$this->_req_action], |
|
| 3290 | + 'normal' |
|
| 3291 | + ); |
|
| 3292 | + } |
|
| 3293 | + if (post_type_supports('espresso_attendees', 'comments')) { |
|
| 3294 | + add_meta_box( |
|
| 3295 | + 'commentsdiv', |
|
| 3296 | + esc_html__('Notes on the Contact', 'event_espresso'), |
|
| 3297 | + 'post_comment_meta_box', |
|
| 3298 | + $this->_cpt_routes[$this->_req_action], |
|
| 3299 | + 'normal', |
|
| 3300 | + 'core' |
|
| 3301 | + ); |
|
| 3302 | + } |
|
| 3303 | + add_meta_box( |
|
| 3304 | + 'attendee_contact_info', |
|
| 3305 | + esc_html__('Contact Info', 'event_espresso'), |
|
| 3306 | + array($this, 'attendee_contact_info'), |
|
| 3307 | + $this->_cpt_routes[$this->_req_action], |
|
| 3308 | + 'side', |
|
| 3309 | + 'core' |
|
| 3310 | + ); |
|
| 3311 | + add_meta_box( |
|
| 3312 | + 'attendee_details_address', |
|
| 3313 | + esc_html__('Address Details', 'event_espresso'), |
|
| 3314 | + array($this, 'attendee_address_details'), |
|
| 3315 | + $this->_cpt_routes[$this->_req_action], |
|
| 3316 | + 'normal', |
|
| 3317 | + 'core' |
|
| 3318 | + ); |
|
| 3319 | + add_meta_box( |
|
| 3320 | + 'attendee_registrations', |
|
| 3321 | + esc_html__('Registrations for this Contact', 'event_espresso'), |
|
| 3322 | + array($this, 'attendee_registrations_meta_box'), |
|
| 3323 | + $this->_cpt_routes[$this->_req_action], |
|
| 3324 | + 'normal', |
|
| 3325 | + 'high' |
|
| 3326 | + ); |
|
| 3327 | + } |
|
| 3328 | + |
|
| 3329 | + |
|
| 3330 | + /** |
|
| 3331 | + * Metabox for attendee contact info |
|
| 3332 | + * |
|
| 3333 | + * @param WP_Post $post wp post object |
|
| 3334 | + * @return string attendee contact info ( and form ) |
|
| 3335 | + * @throws DomainException |
|
| 3336 | + */ |
|
| 3337 | + public function attendee_contact_info($post) |
|
| 3338 | + { |
|
| 3339 | + //get attendee object ( should already have it ) |
|
| 3340 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3341 | + $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
| 3342 | + EEH_Template::display_template($template, $this->_template_args); |
|
| 3343 | + } |
|
| 3344 | + |
|
| 3345 | + |
|
| 3346 | + /** |
|
| 3347 | + * Metabox for attendee details |
|
| 3348 | + * |
|
| 3349 | + * @param WP_Post $post wp post object |
|
| 3350 | + * @return string attendee address details (and form) |
|
| 3351 | + * @throws DomainException |
|
| 3352 | + */ |
|
| 3353 | + public function attendee_address_details($post) |
|
| 3354 | + { |
|
| 3355 | + //get attendee object (should already have it) |
|
| 3356 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3357 | + $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input( |
|
| 3358 | + new EE_Question_Form_Input( |
|
| 3359 | + EE_Question::new_instance( |
|
| 3360 | + array( |
|
| 3361 | + 'QST_ID' => 0, |
|
| 3362 | + 'QST_display_text' => esc_html__('State/Province', 'event_espresso'), |
|
| 3363 | + 'QST_system' => 'admin-state', |
|
| 3364 | + ) |
|
| 3365 | + ), |
|
| 3366 | + EE_Answer::new_instance( |
|
| 3367 | + array( |
|
| 3368 | + 'ANS_ID' => 0, |
|
| 3369 | + 'ANS_value' => $this->_cpt_model_obj->state_ID(), |
|
| 3370 | + ) |
|
| 3371 | + ), |
|
| 3372 | + array( |
|
| 3373 | + 'input_id' => 'STA_ID', |
|
| 3374 | + 'input_name' => 'STA_ID', |
|
| 3375 | + 'input_prefix' => '', |
|
| 3376 | + 'append_qstn_id' => false, |
|
| 3377 | + ) |
|
| 3378 | + ) |
|
| 3379 | + ); |
|
| 3380 | + $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input( |
|
| 3381 | + new EE_Question_Form_Input( |
|
| 3382 | + EE_Question::new_instance( |
|
| 3383 | + array( |
|
| 3384 | + 'QST_ID' => 0, |
|
| 3385 | + 'QST_display_text' => esc_html__('Country', 'event_espresso'), |
|
| 3386 | + 'QST_system' => 'admin-country', |
|
| 3387 | + ) |
|
| 3388 | + ), |
|
| 3389 | + EE_Answer::new_instance( |
|
| 3390 | + array( |
|
| 3391 | + 'ANS_ID' => 0, |
|
| 3392 | + 'ANS_value' => $this->_cpt_model_obj->country_ID(), |
|
| 3393 | + ) |
|
| 3394 | + ), |
|
| 3395 | + array( |
|
| 3396 | + 'input_id' => 'CNT_ISO', |
|
| 3397 | + 'input_name' => 'CNT_ISO', |
|
| 3398 | + 'input_prefix' => '', |
|
| 3399 | + 'append_qstn_id' => false, |
|
| 3400 | + ) |
|
| 3401 | + ) |
|
| 3402 | + ); |
|
| 3403 | + $template = |
|
| 3404 | + REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
| 3405 | + EEH_Template::display_template($template, $this->_template_args); |
|
| 3406 | + } |
|
| 3407 | + |
|
| 3408 | + |
|
| 3409 | + /** |
|
| 3410 | + * _attendee_details |
|
| 3411 | + * |
|
| 3412 | + * @access protected |
|
| 3413 | + * @param $post |
|
| 3414 | + * @return void |
|
| 3415 | + * @throws DomainException |
|
| 3416 | + * @throws EE_Error |
|
| 3417 | + */ |
|
| 3418 | + public function attendee_registrations_meta_box($post) |
|
| 3419 | + { |
|
| 3420 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3421 | + $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
|
| 3422 | + $template = |
|
| 3423 | + REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
| 3424 | + EEH_Template::display_template($template, $this->_template_args); |
|
| 3425 | + } |
|
| 3426 | + |
|
| 3427 | + |
|
| 3428 | + /** |
|
| 3429 | + * add in the form fields for the attendee edit |
|
| 3430 | + * |
|
| 3431 | + * @param WP_Post $post wp post object |
|
| 3432 | + * @return string html for new form. |
|
| 3433 | + * @throws DomainException |
|
| 3434 | + */ |
|
| 3435 | + public function after_title_form_fields($post) |
|
| 3436 | + { |
|
| 3437 | + if ($post->post_type == 'espresso_attendees') { |
|
| 3438 | + $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
| 3439 | + $template_args['attendee'] = $this->_cpt_model_obj; |
|
| 3440 | + EEH_Template::display_template($template, $template_args); |
|
| 3441 | + } |
|
| 3442 | + } |
|
| 3443 | + |
|
| 3444 | + |
|
| 3445 | + /** |
|
| 3446 | + * _trash_or_restore_attendee |
|
| 3447 | + * |
|
| 3448 | + * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 3449 | + * @return void |
|
| 3450 | + * @throws EE_Error |
|
| 3451 | + * @access protected |
|
| 3452 | + */ |
|
| 3453 | + protected function _trash_or_restore_attendees($trash = true) |
|
| 3454 | + { |
|
| 3455 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 3456 | + $ATT_MDL = EEM_Attendee::instance(); |
|
| 3457 | + $success = 1; |
|
| 3458 | + //Checkboxes |
|
| 3459 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 3460 | + // if array has more than one element than success message should be plural |
|
| 3461 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 3462 | + // cycle thru checkboxes |
|
| 3463 | + while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 3464 | + $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) |
|
| 3465 | + : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID); |
|
| 3466 | + if ( ! $updated) { |
|
| 3467 | + $success = 0; |
|
| 3468 | + } |
|
| 3469 | + } |
|
| 3470 | + } else { |
|
| 3471 | + // grab single id and delete |
|
| 3472 | + $ATT_ID = absint($this->_req_data['ATT_ID']); |
|
| 3473 | + //get attendee |
|
| 3474 | + $att = $ATT_MDL->get_one_by_ID($ATT_ID); |
|
| 3475 | + $updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
|
| 3476 | + $updated = $att->save(); |
|
| 3477 | + if ( ! $updated) { |
|
| 3478 | + $success = 0; |
|
| 3479 | + } |
|
| 3480 | + } |
|
| 3481 | + $what = $success > 1 |
|
| 3482 | + ? esc_html__('Contacts', 'event_espresso') |
|
| 3483 | + : esc_html__('Contact', 'event_espresso'); |
|
| 3484 | + $action_desc = $trash |
|
| 3485 | + ? esc_html__('moved to the trash', 'event_espresso') |
|
| 3486 | + : esc_html__('restored', 'event_espresso'); |
|
| 3487 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list')); |
|
| 3488 | + } |
|
| 3489 | 3489 | |
| 3490 | 3490 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | class EE_Attendee_Contact_List_Table extends EE_Admin_List_Table { |
| 5 | 5 | |
| 6 | 6 | |
| 7 | - public function __construct( $admin_page ) { |
|
| 7 | + public function __construct($admin_page) { |
|
| 8 | 8 | parent::__construct($admin_page); |
| 9 | 9 | } |
| 10 | 10 | |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | protected function _setup_data() { |
| 15 | - $this->_data = $this->_view != 'trash' ? $this->_admin_page->get_attendees( $this->_per_page ) : $this->_admin_page->get_attendees( $this->_per_page, FALSE, TRUE ); |
|
| 16 | - $this->_all_data_count = $this->_view != 'trash' ? $this->_admin_page->get_attendees( $this->_per_page, TRUE ) : $this->_admin_page->get_attendees( $this->_per_page,TRUE, TRUE ); |
|
| 15 | + $this->_data = $this->_view != 'trash' ? $this->_admin_page->get_attendees($this->_per_page) : $this->_admin_page->get_attendees($this->_per_page, FALSE, TRUE); |
|
| 16 | + $this->_all_data_count = $this->_view != 'trash' ? $this->_admin_page->get_attendees($this->_per_page, TRUE) : $this->_admin_page->get_attendees($this->_per_page, TRUE, TRUE); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | |
@@ -41,13 +41,13 @@ discard block |
||
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | $this->_sortable_columns = array( |
| 44 | - 'ATT_ID' => array( 'ATT_ID' => FALSE ), |
|
| 45 | - 'ATT_lname' => array( 'ATT_lname' => TRUE ), //true means its already sorted |
|
| 46 | - 'ATT_fname' => array( 'ATT_fname' => FALSE ), |
|
| 47 | - 'ATT_email' => array( 'ATT_email' => FALSE ), |
|
| 48 | - 'ATT_city' => array( 'ATT_city' => FALSE ), |
|
| 49 | - 'STA_ID' => array( 'STA_ID' => FALSE ), |
|
| 50 | - 'CNT_ISO' => array( 'CNT_ISO' => FALSE ) |
|
| 44 | + 'ATT_ID' => array('ATT_ID' => FALSE), |
|
| 45 | + 'ATT_lname' => array('ATT_lname' => TRUE), //true means its already sorted |
|
| 46 | + 'ATT_fname' => array('ATT_fname' => FALSE), |
|
| 47 | + 'ATT_email' => array('ATT_email' => FALSE), |
|
| 48 | + 'ATT_city' => array('ATT_city' => FALSE), |
|
| 49 | + 'STA_ID' => array('STA_ID' => FALSE), |
|
| 50 | + 'CNT_ISO' => array('CNT_ISO' => FALSE) |
|
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | 53 | $this->_hidden_columns = array(); |
@@ -64,9 +64,9 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | protected function _add_view_counts() { |
| 67 | - $this->_views['in_use']['count'] = $this->_admin_page->get_attendees( $this->_per_page, TRUE ); |
|
| 68 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_contacts', 'espresso_registrations_delete_registration' ) ) { |
|
| 69 | - $this->_views['trash']['count'] = $this->_admin_page->get_attendees( $this->_per_page,TRUE, TRUE ); |
|
| 67 | + $this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, TRUE); |
|
| 68 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', 'espresso_registrations_delete_registration')) { |
|
| 69 | + $this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, TRUE, TRUE); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | |
| 91 | 91 | function column_cb($item) { |
| 92 | - return sprintf( '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', /* $1%s */ $item->ID() ); |
|
| 92 | + return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', /* $1%s */ $item->ID()); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | |
| 99 | 99 | function column_ATT_ID($item) { |
| 100 | - $content = $item->ID(); |
|
| 100 | + $content = $item->ID(); |
|
| 101 | 101 | $attendee_name = $item instanceof EE_Attendee ? $item->full_name() : ''; |
| 102 | - $content .= ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
| 102 | + $content .= ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>'; |
|
| 103 | 103 | return $content; |
| 104 | 104 | } |
| 105 | 105 | |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | function column_ATT_lname($item) { |
| 111 | 111 | |
| 112 | 112 | // edit attendee link |
| 113 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$item->ID() ), REG_ADMIN_URL ); |
|
| 114 | - $name_link = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_contacts', 'espresso_registrations_edit_attendee' ) ? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Contact', 'event_espresso' ) . '">' . $item->lname() . '</a>' : $item->lname(); |
|
| 113 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$item->ID()), REG_ADMIN_URL); |
|
| 114 | + $name_link = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', 'espresso_registrations_edit_attendee') ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Contact', 'event_espresso').'">'.$item->lname().'</a>' : $item->lname(); |
|
| 115 | 115 | return $name_link; |
| 116 | 116 | |
| 117 | 117 | } |
@@ -124,30 +124,30 @@ discard block |
||
| 124 | 124 | //Build row actions |
| 125 | 125 | $actions = array(); |
| 126 | 126 | // edit attendee link |
| 127 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_contacts', 'espresso_registrations_edit_attendee' ) ) { |
|
| 128 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$item->ID() ), REG_ADMIN_URL ); |
|
| 129 | - $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Contact', 'event_espresso' ) . '">' . __( 'Edit', 'event_espresso' ) . '</a>'; |
|
| 127 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', 'espresso_registrations_edit_attendee')) { |
|
| 128 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$item->ID()), REG_ADMIN_URL); |
|
| 129 | + $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Contact', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>'; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if ( $this->_view == 'in_use' ) { |
|
| 132 | + if ($this->_view == 'in_use') { |
|
| 133 | 133 | // trash attendee link |
| 134 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_contacts', 'espresso_registrations_trash_attendees' ) ) { |
|
| 135 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'trash_attendee', 'ATT_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
| 136 | - $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="' . esc_attr__( 'Move Contact to Trash', 'event_espresso' ) . '">' . __( 'Trash', 'event_espresso' ) . '</a>'; |
|
| 134 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', 'espresso_registrations_trash_attendees')) { |
|
| 135 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'trash_attendee', 'ATT_ID'=>$item->ID()), REG_ADMIN_URL); |
|
| 136 | + $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'.esc_attr__('Move Contact to Trash', 'event_espresso').'">'.__('Trash', 'event_espresso').'</a>'; |
|
| 137 | 137 | } |
| 138 | 138 | } else { |
| 139 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_contacts', 'espresso_registrations_restore_attendees' ) ) { |
|
| 139 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', 'espresso_registrations_restore_attendees')) { |
|
| 140 | 140 | // restore attendee link |
| 141 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'restore_attendees', 'ATT_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
| 142 | - $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="' . esc_attr__( 'Restore Contact', 'event_espresso' ) . '">' . __( 'Restore', 'event_espresso' ) . '</a>'; |
|
| 141 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'restore_attendees', 'ATT_ID'=>$item->ID()), REG_ADMIN_URL); |
|
| 142 | + $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'.esc_attr__('Restore Contact', 'event_espresso').'">'.__('Restore', 'event_espresso').'</a>'; |
|
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$item->ID() ), REG_ADMIN_URL ); |
|
| 147 | - $name_link = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_contacts', 'espresso_registrations_edit_attendee' ) ? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Contact', 'event_espresso' ) . '">' . $item->fname() . '</a>' : $item->fname(); |
|
| 146 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$item->ID()), REG_ADMIN_URL); |
|
| 147 | + $name_link = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', 'espresso_registrations_edit_attendee') ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Contact', 'event_espresso').'">'.$item->fname().'</a>' : $item->fname(); |
|
| 148 | 148 | |
| 149 | 149 | //Return the name contents |
| 150 | - return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions) ); |
|
| 150 | + return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions)); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | |
| 157 | 157 | function column_ATT_email($item) { |
| 158 | - return '<a href="mailto:' . $item->email() . '">' . $item->email() . '</a>'; |
|
| 158 | + return '<a href="mailto:'.$item->email().'">'.$item->email().'</a>'; |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | |
@@ -175,8 +175,8 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | function column_STA_ID($item) { |
| 177 | 177 | $states = EEM_State::instance()->get_all_states(); |
| 178 | - $state = isset( $states[ $item->state_ID() ] ) ? $states[ $item->state_ID() ]->get( 'STA_name' ) : $item->state_ID(); |
|
| 179 | - return ! is_numeric( $state ) ? $state : ''; |
|
| 178 | + $state = isset($states[$item->state_ID()]) ? $states[$item->state_ID()]->get('STA_name') : $item->state_ID(); |
|
| 179 | + return ! is_numeric($state) ? $state : ''; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
@@ -184,8 +184,8 @@ discard block |
||
| 184 | 184 | function column_CNT_ISO($item) { |
| 185 | 185 | $countries = EEM_Country::instance()->get_all_countries(); |
| 186 | 186 | //EEH_Debug_Tools::printr( $countries, '$countries <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 187 | - $country = isset( $countries[ $item->country_ID() ] ) ? $countries[ $item->country_ID() ]->get( 'CNT_name' ) : $item->country_ID(); |
|
| 188 | - return ! is_numeric( $country ) ? $country : ''; |
|
| 187 | + $country = isset($countries[$item->country_ID()]) ? $countries[$item->country_ID()]->get('CNT_name') : $item->country_ID(); |
|
| 188 | + return ! is_numeric($country) ? $country : ''; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | * this method will add that "1" into your date regardless of the format. |
| 945 | 945 | * |
| 946 | 946 | * @param string $month |
| 947 | - * @return string |
|
| 947 | + * @return integer |
|
| 948 | 948 | */ |
| 949 | 949 | public static function first_of_month_timestamp($month = '') |
| 950 | 950 | { |
@@ -1105,7 +1105,7 @@ discard block |
||
| 1105 | 1105 | /** |
| 1106 | 1106 | * Shim for the WP function `get_user_locale` that was added in WordPress 4.7.0 |
| 1107 | 1107 | * |
| 1108 | - * @param int|WP_User $user_id |
|
| 1108 | + * @param integer $user_id |
|
| 1109 | 1109 | * @return string |
| 1110 | 1110 | */ |
| 1111 | 1111 | public static function get_user_locale($user_id = 0) |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 3 | - exit('NO direct script access allowed'); |
|
| 3 | + exit('NO direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -26,233 +26,233 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * return the timezone set for the WP install |
|
| 31 | - * |
|
| 32 | - * @return string valid timezone string for PHP DateTimeZone() class |
|
| 33 | - */ |
|
| 34 | - public static function get_timezone() |
|
| 35 | - { |
|
| 36 | - return EEH_DTT_Helper::get_valid_timezone_string(); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * get_valid_timezone_string |
|
| 42 | - * ensures that a valid timezone string is returned |
|
| 43 | - * |
|
| 44 | - * @access protected |
|
| 45 | - * @param string $timezone_string |
|
| 46 | - * @return string |
|
| 47 | - * @throws \EE_Error |
|
| 48 | - */ |
|
| 49 | - public static function get_valid_timezone_string($timezone_string = '') |
|
| 50 | - { |
|
| 51 | - // if passed a value, then use that, else get WP option |
|
| 52 | - $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
| 53 | - // value from above exists, use that, else get timezone string from gmt_offset |
|
| 54 | - $timezone_string = ! empty($timezone_string) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset(); |
|
| 55 | - EEH_DTT_Helper::validate_timezone($timezone_string); |
|
| 56 | - return $timezone_string; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * This only purpose for this static method is to validate that the incoming timezone is a valid php timezone. |
|
| 62 | - * |
|
| 63 | - * @static |
|
| 64 | - * @access public |
|
| 65 | - * @param string $timezone_string Timezone string to check |
|
| 66 | - * @param bool $throw_error |
|
| 67 | - * @return bool |
|
| 68 | - * @throws \EE_Error |
|
| 69 | - */ |
|
| 70 | - public static function validate_timezone($timezone_string, $throw_error = true) |
|
| 71 | - { |
|
| 72 | - // easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it |
|
| 73 | - try { |
|
| 74 | - new DateTimeZone($timezone_string); |
|
| 75 | - } catch (Exception $e) { |
|
| 76 | - // sometimes we take exception to exceptions |
|
| 77 | - if (! $throw_error) { |
|
| 78 | - return false; |
|
| 79 | - } |
|
| 80 | - throw new EE_Error( |
|
| 81 | - sprintf( |
|
| 82 | - __('The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', |
|
| 83 | - 'event_espresso'), |
|
| 84 | - $timezone_string, |
|
| 85 | - '<a href="http://www.php.net/manual/en/timezones.php">', |
|
| 86 | - '</a>' |
|
| 87 | - ) |
|
| 88 | - ); |
|
| 89 | - } |
|
| 90 | - return true; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * _create_timezone_object_from_timezone_name |
|
| 96 | - * |
|
| 97 | - * @access protected |
|
| 98 | - * @param string $gmt_offset |
|
| 99 | - * @return string |
|
| 100 | - */ |
|
| 101 | - public static function get_timezone_string_from_gmt_offset($gmt_offset = '') |
|
| 102 | - { |
|
| 103 | - $timezone_string = 'UTC'; |
|
| 104 | - $gmt_offset = ! empty($gmt_offset) ? $gmt_offset : get_option('gmt_offset'); |
|
| 105 | - if ($gmt_offset !== '') { |
|
| 106 | - // convert GMT offset to seconds |
|
| 107 | - $gmt_offset = $gmt_offset * HOUR_IN_SECONDS; |
|
| 108 | - // account for WP offsets that aren't valid UTC |
|
| 109 | - $gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets($gmt_offset); |
|
| 110 | - // although we don't know the TZ abbreviation, we know the UTC offset |
|
| 111 | - $timezone_string = timezone_name_from_abbr(null, $gmt_offset); |
|
| 112 | - } |
|
| 113 | - // better have a valid timezone string by now, but if not, sigh... loop thru the timezone_abbreviations_list()... |
|
| 114 | - $timezone_string = $timezone_string !== false |
|
| 115 | - ? $timezone_string |
|
| 116 | - : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset); |
|
| 117 | - return $timezone_string; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Gets the site's GMT offset based on either the timezone string |
|
| 122 | - * (in which case teh gmt offset will vary depending on the location's |
|
| 123 | - * observance of daylight savings time) or the gmt_offset wp option |
|
| 124 | - * |
|
| 125 | - * @return int seconds offset |
|
| 126 | - */ |
|
| 127 | - public static function get_site_timezone_gmt_offset() |
|
| 128 | - { |
|
| 129 | - $timezone_string = get_option('timezone_string'); |
|
| 130 | - if ($timezone_string) { |
|
| 131 | - try { |
|
| 132 | - $timezone = new DateTimeZone($timezone_string); |
|
| 133 | - return $timezone->getOffset(new DateTime()); //in WordPress DateTime defaults to UTC |
|
| 134 | - } catch (Exception $e) { |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - $offset = get_option('gmt_offset'); |
|
| 138 | - return (int)($offset * HOUR_IN_SECONDS); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * _create_timezone_object_from_timezone_name |
|
| 144 | - * |
|
| 145 | - * @access public |
|
| 146 | - * @param int $gmt_offset |
|
| 147 | - * @return int |
|
| 148 | - */ |
|
| 149 | - public static function adjust_invalid_gmt_offsets($gmt_offset = 0) |
|
| 150 | - { |
|
| 151 | - //make sure $gmt_offset is int |
|
| 152 | - $gmt_offset = (int)$gmt_offset; |
|
| 153 | - switch ($gmt_offset) { |
|
| 154 | - |
|
| 155 | - // case -30600 : |
|
| 156 | - // $gmt_offset = -28800; |
|
| 157 | - // break; |
|
| 158 | - |
|
| 159 | - case -27000 : |
|
| 160 | - $gmt_offset = -25200; |
|
| 161 | - break; |
|
| 162 | - |
|
| 163 | - case -23400 : |
|
| 164 | - $gmt_offset = -21600; |
|
| 165 | - break; |
|
| 166 | - |
|
| 167 | - case -19800 : |
|
| 168 | - $gmt_offset = -18000; |
|
| 169 | - break; |
|
| 170 | - |
|
| 171 | - case -9000 : |
|
| 172 | - $gmt_offset = -7200; |
|
| 173 | - break; |
|
| 174 | - |
|
| 175 | - case -5400 : |
|
| 176 | - $gmt_offset = -3600; |
|
| 177 | - break; |
|
| 178 | - |
|
| 179 | - case -1800 : |
|
| 180 | - $gmt_offset = 0; |
|
| 181 | - break; |
|
| 182 | - |
|
| 183 | - case 1800 : |
|
| 184 | - $gmt_offset = 3600; |
|
| 185 | - break; |
|
| 186 | - |
|
| 187 | - case 49500 : |
|
| 188 | - $gmt_offset = 50400; |
|
| 189 | - break; |
|
| 190 | - |
|
| 191 | - } |
|
| 192 | - return $gmt_offset; |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * get_timezone_string_from_abbreviations_list |
|
| 198 | - * |
|
| 199 | - * @access public |
|
| 200 | - * @param int $gmt_offset |
|
| 201 | - * @return string |
|
| 202 | - * @throws \EE_Error |
|
| 203 | - */ |
|
| 204 | - public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0) |
|
| 205 | - { |
|
| 206 | - $abbreviations = timezone_abbreviations_list(); |
|
| 207 | - foreach ($abbreviations as $abbreviation) { |
|
| 208 | - foreach ($abbreviation as $city) { |
|
| 209 | - if ($city['offset'] === $gmt_offset && $city['dst'] === false) { |
|
| 210 | - // check if the timezone is valid but don't throw any errors if it isn't |
|
| 211 | - if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) { |
|
| 212 | - return $city['timezone_id']; |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - throw new EE_Error( |
|
| 218 | - sprintf( |
|
| 219 | - __('The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', |
|
| 220 | - 'event_espresso'), |
|
| 221 | - $gmt_offset, |
|
| 222 | - '<a href="http://www.php.net/manual/en/timezones.php">', |
|
| 223 | - '</a>' |
|
| 224 | - ) |
|
| 225 | - ); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * @access public |
|
| 231 | - * @param string $timezone_string |
|
| 232 | - */ |
|
| 233 | - public static function timezone_select_input($timezone_string = '') |
|
| 234 | - { |
|
| 235 | - // get WP date time format |
|
| 236 | - $datetime_format = get_option('date_format') . ' ' . get_option('time_format'); |
|
| 237 | - // if passed a value, then use that, else get WP option |
|
| 238 | - $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
| 239 | - // check if the timezone is valid but don't throw any errors if it isn't |
|
| 240 | - $timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false); |
|
| 241 | - $gmt_offset = get_option('gmt_offset'); |
|
| 242 | - |
|
| 243 | - $check_zone_info = true; |
|
| 244 | - if (empty($timezone_string)) { |
|
| 245 | - // Create a UTC+- zone if no timezone string exists |
|
| 246 | - $check_zone_info = false; |
|
| 247 | - if ($gmt_offset > 0) { |
|
| 248 | - $timezone_string = 'UTC+' . $gmt_offset; |
|
| 249 | - } elseif ($gmt_offset < 0) { |
|
| 250 | - $timezone_string = 'UTC' . $gmt_offset; |
|
| 251 | - } else { |
|
| 252 | - $timezone_string = 'UTC'; |
|
| 253 | - } |
|
| 254 | - } |
|
| 255 | - ?> |
|
| 29 | + /** |
|
| 30 | + * return the timezone set for the WP install |
|
| 31 | + * |
|
| 32 | + * @return string valid timezone string for PHP DateTimeZone() class |
|
| 33 | + */ |
|
| 34 | + public static function get_timezone() |
|
| 35 | + { |
|
| 36 | + return EEH_DTT_Helper::get_valid_timezone_string(); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * get_valid_timezone_string |
|
| 42 | + * ensures that a valid timezone string is returned |
|
| 43 | + * |
|
| 44 | + * @access protected |
|
| 45 | + * @param string $timezone_string |
|
| 46 | + * @return string |
|
| 47 | + * @throws \EE_Error |
|
| 48 | + */ |
|
| 49 | + public static function get_valid_timezone_string($timezone_string = '') |
|
| 50 | + { |
|
| 51 | + // if passed a value, then use that, else get WP option |
|
| 52 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
| 53 | + // value from above exists, use that, else get timezone string from gmt_offset |
|
| 54 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset(); |
|
| 55 | + EEH_DTT_Helper::validate_timezone($timezone_string); |
|
| 56 | + return $timezone_string; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * This only purpose for this static method is to validate that the incoming timezone is a valid php timezone. |
|
| 62 | + * |
|
| 63 | + * @static |
|
| 64 | + * @access public |
|
| 65 | + * @param string $timezone_string Timezone string to check |
|
| 66 | + * @param bool $throw_error |
|
| 67 | + * @return bool |
|
| 68 | + * @throws \EE_Error |
|
| 69 | + */ |
|
| 70 | + public static function validate_timezone($timezone_string, $throw_error = true) |
|
| 71 | + { |
|
| 72 | + // easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it |
|
| 73 | + try { |
|
| 74 | + new DateTimeZone($timezone_string); |
|
| 75 | + } catch (Exception $e) { |
|
| 76 | + // sometimes we take exception to exceptions |
|
| 77 | + if (! $throw_error) { |
|
| 78 | + return false; |
|
| 79 | + } |
|
| 80 | + throw new EE_Error( |
|
| 81 | + sprintf( |
|
| 82 | + __('The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', |
|
| 83 | + 'event_espresso'), |
|
| 84 | + $timezone_string, |
|
| 85 | + '<a href="http://www.php.net/manual/en/timezones.php">', |
|
| 86 | + '</a>' |
|
| 87 | + ) |
|
| 88 | + ); |
|
| 89 | + } |
|
| 90 | + return true; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * _create_timezone_object_from_timezone_name |
|
| 96 | + * |
|
| 97 | + * @access protected |
|
| 98 | + * @param string $gmt_offset |
|
| 99 | + * @return string |
|
| 100 | + */ |
|
| 101 | + public static function get_timezone_string_from_gmt_offset($gmt_offset = '') |
|
| 102 | + { |
|
| 103 | + $timezone_string = 'UTC'; |
|
| 104 | + $gmt_offset = ! empty($gmt_offset) ? $gmt_offset : get_option('gmt_offset'); |
|
| 105 | + if ($gmt_offset !== '') { |
|
| 106 | + // convert GMT offset to seconds |
|
| 107 | + $gmt_offset = $gmt_offset * HOUR_IN_SECONDS; |
|
| 108 | + // account for WP offsets that aren't valid UTC |
|
| 109 | + $gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets($gmt_offset); |
|
| 110 | + // although we don't know the TZ abbreviation, we know the UTC offset |
|
| 111 | + $timezone_string = timezone_name_from_abbr(null, $gmt_offset); |
|
| 112 | + } |
|
| 113 | + // better have a valid timezone string by now, but if not, sigh... loop thru the timezone_abbreviations_list()... |
|
| 114 | + $timezone_string = $timezone_string !== false |
|
| 115 | + ? $timezone_string |
|
| 116 | + : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset); |
|
| 117 | + return $timezone_string; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Gets the site's GMT offset based on either the timezone string |
|
| 122 | + * (in which case teh gmt offset will vary depending on the location's |
|
| 123 | + * observance of daylight savings time) or the gmt_offset wp option |
|
| 124 | + * |
|
| 125 | + * @return int seconds offset |
|
| 126 | + */ |
|
| 127 | + public static function get_site_timezone_gmt_offset() |
|
| 128 | + { |
|
| 129 | + $timezone_string = get_option('timezone_string'); |
|
| 130 | + if ($timezone_string) { |
|
| 131 | + try { |
|
| 132 | + $timezone = new DateTimeZone($timezone_string); |
|
| 133 | + return $timezone->getOffset(new DateTime()); //in WordPress DateTime defaults to UTC |
|
| 134 | + } catch (Exception $e) { |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + $offset = get_option('gmt_offset'); |
|
| 138 | + return (int)($offset * HOUR_IN_SECONDS); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * _create_timezone_object_from_timezone_name |
|
| 144 | + * |
|
| 145 | + * @access public |
|
| 146 | + * @param int $gmt_offset |
|
| 147 | + * @return int |
|
| 148 | + */ |
|
| 149 | + public static function adjust_invalid_gmt_offsets($gmt_offset = 0) |
|
| 150 | + { |
|
| 151 | + //make sure $gmt_offset is int |
|
| 152 | + $gmt_offset = (int)$gmt_offset; |
|
| 153 | + switch ($gmt_offset) { |
|
| 154 | + |
|
| 155 | + // case -30600 : |
|
| 156 | + // $gmt_offset = -28800; |
|
| 157 | + // break; |
|
| 158 | + |
|
| 159 | + case -27000 : |
|
| 160 | + $gmt_offset = -25200; |
|
| 161 | + break; |
|
| 162 | + |
|
| 163 | + case -23400 : |
|
| 164 | + $gmt_offset = -21600; |
|
| 165 | + break; |
|
| 166 | + |
|
| 167 | + case -19800 : |
|
| 168 | + $gmt_offset = -18000; |
|
| 169 | + break; |
|
| 170 | + |
|
| 171 | + case -9000 : |
|
| 172 | + $gmt_offset = -7200; |
|
| 173 | + break; |
|
| 174 | + |
|
| 175 | + case -5400 : |
|
| 176 | + $gmt_offset = -3600; |
|
| 177 | + break; |
|
| 178 | + |
|
| 179 | + case -1800 : |
|
| 180 | + $gmt_offset = 0; |
|
| 181 | + break; |
|
| 182 | + |
|
| 183 | + case 1800 : |
|
| 184 | + $gmt_offset = 3600; |
|
| 185 | + break; |
|
| 186 | + |
|
| 187 | + case 49500 : |
|
| 188 | + $gmt_offset = 50400; |
|
| 189 | + break; |
|
| 190 | + |
|
| 191 | + } |
|
| 192 | + return $gmt_offset; |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * get_timezone_string_from_abbreviations_list |
|
| 198 | + * |
|
| 199 | + * @access public |
|
| 200 | + * @param int $gmt_offset |
|
| 201 | + * @return string |
|
| 202 | + * @throws \EE_Error |
|
| 203 | + */ |
|
| 204 | + public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0) |
|
| 205 | + { |
|
| 206 | + $abbreviations = timezone_abbreviations_list(); |
|
| 207 | + foreach ($abbreviations as $abbreviation) { |
|
| 208 | + foreach ($abbreviation as $city) { |
|
| 209 | + if ($city['offset'] === $gmt_offset && $city['dst'] === false) { |
|
| 210 | + // check if the timezone is valid but don't throw any errors if it isn't |
|
| 211 | + if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) { |
|
| 212 | + return $city['timezone_id']; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + throw new EE_Error( |
|
| 218 | + sprintf( |
|
| 219 | + __('The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', |
|
| 220 | + 'event_espresso'), |
|
| 221 | + $gmt_offset, |
|
| 222 | + '<a href="http://www.php.net/manual/en/timezones.php">', |
|
| 223 | + '</a>' |
|
| 224 | + ) |
|
| 225 | + ); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * @access public |
|
| 231 | + * @param string $timezone_string |
|
| 232 | + */ |
|
| 233 | + public static function timezone_select_input($timezone_string = '') |
|
| 234 | + { |
|
| 235 | + // get WP date time format |
|
| 236 | + $datetime_format = get_option('date_format') . ' ' . get_option('time_format'); |
|
| 237 | + // if passed a value, then use that, else get WP option |
|
| 238 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
| 239 | + // check if the timezone is valid but don't throw any errors if it isn't |
|
| 240 | + $timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false); |
|
| 241 | + $gmt_offset = get_option('gmt_offset'); |
|
| 242 | + |
|
| 243 | + $check_zone_info = true; |
|
| 244 | + if (empty($timezone_string)) { |
|
| 245 | + // Create a UTC+- zone if no timezone string exists |
|
| 246 | + $check_zone_info = false; |
|
| 247 | + if ($gmt_offset > 0) { |
|
| 248 | + $timezone_string = 'UTC+' . $gmt_offset; |
|
| 249 | + } elseif ($gmt_offset < 0) { |
|
| 250 | + $timezone_string = 'UTC' . $gmt_offset; |
|
| 251 | + } else { |
|
| 252 | + $timezone_string = 'UTC'; |
|
| 253 | + } |
|
| 254 | + } |
|
| 255 | + ?> |
|
| 256 | 256 | |
| 257 | 257 | <p> |
| 258 | 258 | <label for="timezone_string"><?php _e('timezone'); ?></label> |
@@ -265,13 +265,13 @@ discard block |
||
| 265 | 265 | |
| 266 | 266 | <p> |
| 267 | 267 | <span><?php |
| 268 | - printf( |
|
| 269 | - __('%1$sUTC%2$s time is %3$s'), |
|
| 270 | - '<abbr title="Coordinated Universal Time">', |
|
| 271 | - '</abbr>', |
|
| 272 | - '<code>' . date_i18n($datetime_format, false, true) . '</code>' |
|
| 273 | - ); |
|
| 274 | - ?></span> |
|
| 268 | + printf( |
|
| 269 | + __('%1$sUTC%2$s time is %3$s'), |
|
| 270 | + '<abbr title="Coordinated Universal Time">', |
|
| 271 | + '</abbr>', |
|
| 272 | + '<code>' . date_i18n($datetime_format, false, true) . '</code>' |
|
| 273 | + ); |
|
| 274 | + ?></span> |
|
| 275 | 275 | <?php if (! empty($timezone_string) || ! empty($gmt_offset)) : ?> |
| 276 | 276 | <br/><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n($datetime_format) . '</code>'); ?></span> |
| 277 | 277 | <?php endif; ?> |
@@ -280,693 +280,693 @@ discard block |
||
| 280 | 280 | <br/> |
| 281 | 281 | <span> |
| 282 | 282 | <?php |
| 283 | - // Set TZ so localtime works. |
|
| 284 | - date_default_timezone_set($timezone_string); |
|
| 285 | - $now = localtime(time(), true); |
|
| 286 | - if ($now['tm_isdst']) { |
|
| 287 | - _e('This timezone is currently in daylight saving time.'); |
|
| 288 | - } else { |
|
| 289 | - _e('This timezone is currently in standard time.'); |
|
| 290 | - } |
|
| 291 | - ?> |
|
| 283 | + // Set TZ so localtime works. |
|
| 284 | + date_default_timezone_set($timezone_string); |
|
| 285 | + $now = localtime(time(), true); |
|
| 286 | + if ($now['tm_isdst']) { |
|
| 287 | + _e('This timezone is currently in daylight saving time.'); |
|
| 288 | + } else { |
|
| 289 | + _e('This timezone is currently in standard time.'); |
|
| 290 | + } |
|
| 291 | + ?> |
|
| 292 | 292 | <br/> |
| 293 | 293 | <?php |
| 294 | - if (function_exists('timezone_transitions_get')) { |
|
| 295 | - $found = false; |
|
| 296 | - $date_time_zone_selected = new DateTimeZone($timezone_string); |
|
| 297 | - $tz_offset = timezone_offset_get($date_time_zone_selected, date_create()); |
|
| 298 | - $right_now = time(); |
|
| 299 | - $tr['isdst'] = false; |
|
| 300 | - foreach (timezone_transitions_get($date_time_zone_selected) as $tr) { |
|
| 301 | - if ($tr['ts'] > $right_now) { |
|
| 302 | - $found = true; |
|
| 303 | - break; |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - if ($found) { |
|
| 308 | - $message = $tr['isdst'] ? |
|
| 309 | - __(' Daylight saving time begins on: %s.') : |
|
| 310 | - __(' Standard time begins on: %s.'); |
|
| 311 | - // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). |
|
| 312 | - printf($message, |
|
| 313 | - '<code >' . date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])) . '</code >'); |
|
| 314 | - } else { |
|
| 315 | - _e('This timezone does not observe daylight saving time.'); |
|
| 316 | - } |
|
| 317 | - } |
|
| 318 | - // Set back to UTC. |
|
| 319 | - date_default_timezone_set('UTC'); |
|
| 320 | - ?> |
|
| 294 | + if (function_exists('timezone_transitions_get')) { |
|
| 295 | + $found = false; |
|
| 296 | + $date_time_zone_selected = new DateTimeZone($timezone_string); |
|
| 297 | + $tz_offset = timezone_offset_get($date_time_zone_selected, date_create()); |
|
| 298 | + $right_now = time(); |
|
| 299 | + $tr['isdst'] = false; |
|
| 300 | + foreach (timezone_transitions_get($date_time_zone_selected) as $tr) { |
|
| 301 | + if ($tr['ts'] > $right_now) { |
|
| 302 | + $found = true; |
|
| 303 | + break; |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + if ($found) { |
|
| 308 | + $message = $tr['isdst'] ? |
|
| 309 | + __(' Daylight saving time begins on: %s.') : |
|
| 310 | + __(' Standard time begins on: %s.'); |
|
| 311 | + // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). |
|
| 312 | + printf($message, |
|
| 313 | + '<code >' . date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])) . '</code >'); |
|
| 314 | + } else { |
|
| 315 | + _e('This timezone does not observe daylight saving time.'); |
|
| 316 | + } |
|
| 317 | + } |
|
| 318 | + // Set back to UTC. |
|
| 319 | + date_default_timezone_set('UTC'); |
|
| 320 | + ?> |
|
| 321 | 321 | </span></p> |
| 322 | 322 | <?php |
| 323 | - endif; |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - |
|
| 327 | - /** |
|
| 328 | - * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string. |
|
| 329 | - * If no unix timestamp is given then time() is used. If no timezone is given then the set timezone string for |
|
| 330 | - * the site is used. |
|
| 331 | - * This is used typically when using a Unix timestamp any core WP functions that expect their specially |
|
| 332 | - * computed timestamp (i.e. date_i18n() ) |
|
| 333 | - * |
|
| 334 | - * @param int $unix_timestamp if 0, then time() will be used. |
|
| 335 | - * @param string $timezone_string timezone_string. If empty, then the current set timezone for the |
|
| 336 | - * site will be used. |
|
| 337 | - * @return int $unix_timestamp with the offset applied for the given timezone. |
|
| 338 | - */ |
|
| 339 | - public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '') |
|
| 340 | - { |
|
| 341 | - $unix_timestamp = $unix_timestamp === 0 ? time() : (int)$unix_timestamp; |
|
| 342 | - $timezone_string = self::get_valid_timezone_string($timezone_string); |
|
| 343 | - $TimeZone = new DateTimeZone($timezone_string); |
|
| 344 | - |
|
| 345 | - $DateTime = new DateTime('@' . $unix_timestamp, $TimeZone); |
|
| 346 | - $offset = timezone_offset_get($TimeZone, $DateTime); |
|
| 347 | - return (int)$DateTime->format('U') + (int)$offset; |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - |
|
| 351 | - /** |
|
| 352 | - * _set_date_time_field |
|
| 353 | - * modifies EE_Base_Class EE_Datetime_Field objects |
|
| 354 | - * |
|
| 355 | - * @param EE_Base_Class $obj EE_Base_Class object |
|
| 356 | - * @param DateTime $DateTime PHP DateTime object |
|
| 357 | - * @param string $datetime_field_name the datetime fieldname to be manipulated |
|
| 358 | - * @return EE_Base_Class |
|
| 359 | - */ |
|
| 360 | - protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name) |
|
| 361 | - { |
|
| 362 | - // grab current datetime format |
|
| 363 | - $current_format = $obj->get_format(); |
|
| 364 | - // set new full timestamp format |
|
| 365 | - $obj->set_date_format(EE_Datetime_Field::mysql_date_format); |
|
| 366 | - $obj->set_time_format(EE_Datetime_Field::mysql_time_format); |
|
| 367 | - // set the new date value using a full timestamp format so that no data is lost |
|
| 368 | - $obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format)); |
|
| 369 | - // reset datetime formats |
|
| 370 | - $obj->set_date_format($current_format[0]); |
|
| 371 | - $obj->set_time_format($current_format[1]); |
|
| 372 | - return $obj; |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * date_time_add |
|
| 378 | - * helper for doing simple datetime calculations on a given datetime from EE_Base_Class |
|
| 379 | - * and modifying it IN the EE_Base_Class so you don't have to do anything else. |
|
| 380 | - * |
|
| 381 | - * @param EE_Base_Class $obj EE_Base_Class object |
|
| 382 | - * @param string $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated |
|
| 383 | - * @param string $period what you are adding. The options are (years, months, days, hours, |
|
| 384 | - * minutes, seconds) defaults to years |
|
| 385 | - * @param integer $value what you want to increment the time by |
|
| 386 | - * @return EE_Base_Class return the EE_Base_Class object so right away you can do something with it |
|
| 387 | - * (chaining) |
|
| 388 | - */ |
|
| 389 | - public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) |
|
| 390 | - { |
|
| 391 | - //get the raw UTC date. |
|
| 392 | - $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
| 393 | - $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value); |
|
| 394 | - return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - |
|
| 398 | - /** |
|
| 399 | - * date_time_subtract |
|
| 400 | - * same as date_time_add except subtracting value instead of adding. |
|
| 401 | - * |
|
| 402 | - * @param \EE_Base_Class $obj |
|
| 403 | - * @param string $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated |
|
| 404 | - * @param string $period |
|
| 405 | - * @param int $value |
|
| 406 | - * @return \EE_Base_Class |
|
| 407 | - */ |
|
| 408 | - public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) |
|
| 409 | - { |
|
| 410 | - //get the raw UTC date |
|
| 411 | - $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
| 412 | - $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-'); |
|
| 413 | - return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
| 414 | - } |
|
| 415 | - |
|
| 416 | - |
|
| 417 | - /** |
|
| 418 | - * Simply takes an incoming DateTime object and does calculations on it based on the incoming parameters |
|
| 419 | - * |
|
| 420 | - * @param DateTime $DateTime DateTime object |
|
| 421 | - * @param string $period a value to indicate what interval is being used in the calculation. The options are |
|
| 422 | - * 'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years. |
|
| 423 | - * @param integer $value What you want to increment the date by |
|
| 424 | - * @param string $operand What operand you wish to use for the calculation |
|
| 425 | - * @return \DateTime return whatever type came in. |
|
| 426 | - * @throws \EE_Error |
|
| 427 | - */ |
|
| 428 | - protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+') |
|
| 429 | - { |
|
| 430 | - if (! $DateTime instanceof DateTime) { |
|
| 431 | - throw new EE_Error( |
|
| 432 | - sprintf( |
|
| 433 | - __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'), |
|
| 434 | - print_r($DateTime, true) |
|
| 435 | - ) |
|
| 436 | - ); |
|
| 437 | - } |
|
| 438 | - switch ($period) { |
|
| 439 | - case 'years' : |
|
| 440 | - $value = 'P' . $value . 'Y'; |
|
| 441 | - break; |
|
| 442 | - case 'months' : |
|
| 443 | - $value = 'P' . $value . 'M'; |
|
| 444 | - break; |
|
| 445 | - case 'weeks' : |
|
| 446 | - $value = 'P' . $value . 'W'; |
|
| 447 | - break; |
|
| 448 | - case 'days' : |
|
| 449 | - $value = 'P' . $value . 'D'; |
|
| 450 | - break; |
|
| 451 | - case 'hours' : |
|
| 452 | - $value = 'PT' . $value . 'H'; |
|
| 453 | - break; |
|
| 454 | - case 'minutes' : |
|
| 455 | - $value = 'PT' . $value . 'M'; |
|
| 456 | - break; |
|
| 457 | - case 'seconds' : |
|
| 458 | - $value = 'PT' . $value . 'S'; |
|
| 459 | - break; |
|
| 460 | - } |
|
| 461 | - switch ($operand) { |
|
| 462 | - case '+': |
|
| 463 | - $DateTime->add(new DateInterval($value)); |
|
| 464 | - break; |
|
| 465 | - case '-': |
|
| 466 | - $DateTime->sub(new DateInterval($value)); |
|
| 467 | - break; |
|
| 468 | - } |
|
| 469 | - return $DateTime; |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - |
|
| 473 | - /** |
|
| 474 | - * Simply takes an incoming Unix timestamp and does calculations on it based on the incoming parameters |
|
| 475 | - * |
|
| 476 | - * @param int $timestamp Unix timestamp |
|
| 477 | - * @param string $period a value to indicate what interval is being used in the calculation. The options are |
|
| 478 | - * 'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years. |
|
| 479 | - * @param integer $value What you want to increment the date by |
|
| 480 | - * @param string $operand What operand you wish to use for the calculation |
|
| 481 | - * @return \DateTime return whatever type came in. |
|
| 482 | - * @throws \EE_Error |
|
| 483 | - */ |
|
| 484 | - protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+') |
|
| 485 | - { |
|
| 486 | - if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) { |
|
| 487 | - throw new EE_Error( |
|
| 488 | - sprintf( |
|
| 489 | - __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'), |
|
| 490 | - print_r($timestamp, true) |
|
| 491 | - ) |
|
| 492 | - ); |
|
| 493 | - } |
|
| 494 | - switch ($period) { |
|
| 495 | - case 'years' : |
|
| 496 | - $value = YEAR_IN_SECONDS * $value; |
|
| 497 | - break; |
|
| 498 | - case 'months' : |
|
| 499 | - $value = YEAR_IN_SECONDS / 12 * $value; |
|
| 500 | - break; |
|
| 501 | - case 'weeks' : |
|
| 502 | - $value = WEEK_IN_SECONDS * $value; |
|
| 503 | - break; |
|
| 504 | - case 'days' : |
|
| 505 | - $value = DAY_IN_SECONDS * $value; |
|
| 506 | - break; |
|
| 507 | - case 'hours' : |
|
| 508 | - $value = HOUR_IN_SECONDS * $value; |
|
| 509 | - break; |
|
| 510 | - case 'minutes' : |
|
| 511 | - $value = MINUTE_IN_SECONDS * $value; |
|
| 512 | - break; |
|
| 513 | - } |
|
| 514 | - switch ($operand) { |
|
| 515 | - case '+': |
|
| 516 | - $timestamp += $value; |
|
| 517 | - break; |
|
| 518 | - case '-': |
|
| 519 | - $timestamp -= $value; |
|
| 520 | - break; |
|
| 521 | - } |
|
| 522 | - return $timestamp; |
|
| 523 | - } |
|
| 524 | - |
|
| 525 | - |
|
| 526 | - /** |
|
| 527 | - * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming |
|
| 528 | - * parameters and returns the new timestamp or DateTime. |
|
| 529 | - * |
|
| 530 | - * @param int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp |
|
| 531 | - * @param string $period a value to indicate what interval is being used in the |
|
| 532 | - * calculation. The options are 'years', 'months', 'days', 'hours', |
|
| 533 | - * 'minutes', 'seconds'. Defaults to years. |
|
| 534 | - * @param integer $value What you want to increment the date by |
|
| 535 | - * @param string $operand What operand you wish to use for the calculation |
|
| 536 | - * @return mixed string|DateTime return whatever type came in. |
|
| 537 | - */ |
|
| 538 | - public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+') |
|
| 539 | - { |
|
| 540 | - if ($DateTime_or_timestamp instanceof DateTime) { |
|
| 541 | - return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand); |
|
| 542 | - } else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) { |
|
| 543 | - return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand); |
|
| 544 | - } else { |
|
| 545 | - //error |
|
| 546 | - return $DateTime_or_timestamp; |
|
| 547 | - } |
|
| 548 | - } |
|
| 549 | - |
|
| 550 | - |
|
| 551 | - /** |
|
| 552 | - * The purpose of this helper method is to receive an incoming format string in php date/time format |
|
| 553 | - * and spit out the js and moment.js equivalent formats. |
|
| 554 | - * Note, if no format string is given, then it is assumed the user wants what is set for WP. |
|
| 555 | - * Note, js date and time formats are those used by the jquery-ui datepicker and the jquery-ui date- |
|
| 556 | - * time picker. |
|
| 557 | - * |
|
| 558 | - * @see http://stackoverflow.com/posts/16725290/ for the code inspiration. |
|
| 559 | - * @param null $date_format_string |
|
| 560 | - * @param null $time_format_string |
|
| 561 | - * @return array |
|
| 562 | - * array( |
|
| 563 | - * 'js' => array ( |
|
| 564 | - * 'date' => //date format |
|
| 565 | - * 'time' => //time format |
|
| 566 | - * ), |
|
| 567 | - * 'moment' => //date and time format. |
|
| 568 | - * ) |
|
| 569 | - */ |
|
| 570 | - public static function convert_php_to_js_and_moment_date_formats( |
|
| 571 | - $date_format_string = null, |
|
| 572 | - $time_format_string = null |
|
| 573 | - ) { |
|
| 574 | - if ($date_format_string === null) { |
|
| 575 | - $date_format_string = get_option('date_format'); |
|
| 576 | - } |
|
| 577 | - |
|
| 578 | - if ($time_format_string === null) { |
|
| 579 | - $time_format_string = get_option('time_format'); |
|
| 580 | - } |
|
| 581 | - |
|
| 582 | - $date_format = self::_php_to_js_moment_converter($date_format_string); |
|
| 583 | - $time_format = self::_php_to_js_moment_converter($time_format_string); |
|
| 584 | - |
|
| 585 | - return array( |
|
| 586 | - 'js' => array( |
|
| 587 | - 'date' => $date_format['js'], |
|
| 588 | - 'time' => $time_format['js'], |
|
| 589 | - ), |
|
| 590 | - 'moment' => $date_format['moment'] . ' ' . $time_format['moment'], |
|
| 591 | - ); |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - |
|
| 595 | - /** |
|
| 596 | - * This converts incoming format string into js and moment variations. |
|
| 597 | - * |
|
| 598 | - * @param string $format_string incoming php format string |
|
| 599 | - * @return array js and moment formats. |
|
| 600 | - */ |
|
| 601 | - protected static function _php_to_js_moment_converter($format_string) |
|
| 602 | - { |
|
| 603 | - /** |
|
| 604 | - * This is a map of symbols for formats. |
|
| 605 | - * The index is the php symbol, the equivalent values are in the array. |
|
| 606 | - * |
|
| 607 | - * @var array |
|
| 608 | - */ |
|
| 609 | - $symbols_map = array( |
|
| 610 | - // Day |
|
| 611 | - //01 |
|
| 612 | - 'd' => array( |
|
| 613 | - 'js' => 'dd', |
|
| 614 | - 'moment' => 'DD', |
|
| 615 | - ), |
|
| 616 | - //Mon |
|
| 617 | - 'D' => array( |
|
| 618 | - 'js' => 'D', |
|
| 619 | - 'moment' => 'ddd', |
|
| 620 | - ), |
|
| 621 | - //1,2,...31 |
|
| 622 | - 'j' => array( |
|
| 623 | - 'js' => 'd', |
|
| 624 | - 'moment' => 'D', |
|
| 625 | - ), |
|
| 626 | - //Monday |
|
| 627 | - 'l' => array( |
|
| 628 | - 'js' => 'DD', |
|
| 629 | - 'moment' => 'dddd', |
|
| 630 | - ), |
|
| 631 | - //ISO numeric representation of the day of the week (1-6) |
|
| 632 | - 'N' => array( |
|
| 633 | - 'js' => '', |
|
| 634 | - 'moment' => 'E', |
|
| 635 | - ), |
|
| 636 | - //st,nd.rd |
|
| 637 | - 'S' => array( |
|
| 638 | - 'js' => '', |
|
| 639 | - 'moment' => 'o', |
|
| 640 | - ), |
|
| 641 | - //numeric representation of day of week (0-6) |
|
| 642 | - 'w' => array( |
|
| 643 | - 'js' => '', |
|
| 644 | - 'moment' => 'd', |
|
| 645 | - ), |
|
| 646 | - //day of year starting from 0 (0-365) |
|
| 647 | - 'z' => array( |
|
| 648 | - 'js' => 'o', |
|
| 649 | - 'moment' => 'DDD' //note moment does not start with 0 so will need to modify by subtracting 1 |
|
| 650 | - ), |
|
| 651 | - // Week |
|
| 652 | - //ISO-8601 week number of year (weeks starting on monday) |
|
| 653 | - 'W' => array( |
|
| 654 | - 'js' => '', |
|
| 655 | - 'moment' => 'w', |
|
| 656 | - ), |
|
| 657 | - // Month |
|
| 658 | - // January...December |
|
| 659 | - 'F' => array( |
|
| 660 | - 'js' => 'MM', |
|
| 661 | - 'moment' => 'MMMM', |
|
| 662 | - ), |
|
| 663 | - //01...12 |
|
| 664 | - 'm' => array( |
|
| 665 | - 'js' => 'mm', |
|
| 666 | - 'moment' => 'MM', |
|
| 667 | - ), |
|
| 668 | - //Jan...Dec |
|
| 669 | - 'M' => array( |
|
| 670 | - 'js' => 'M', |
|
| 671 | - 'moment' => 'MMM', |
|
| 672 | - ), |
|
| 673 | - //1-12 |
|
| 674 | - 'n' => array( |
|
| 675 | - 'js' => 'm', |
|
| 676 | - 'moment' => 'M', |
|
| 677 | - ), |
|
| 678 | - //number of days in given month |
|
| 679 | - 't' => array( |
|
| 680 | - 'js' => '', |
|
| 681 | - 'moment' => '', |
|
| 682 | - ), |
|
| 683 | - // Year |
|
| 684 | - //whether leap year or not 1/0 |
|
| 685 | - 'L' => array( |
|
| 686 | - 'js' => '', |
|
| 687 | - 'moment' => '', |
|
| 688 | - ), |
|
| 689 | - //ISO-8601 year number |
|
| 690 | - 'o' => array( |
|
| 691 | - 'js' => '', |
|
| 692 | - 'moment' => 'GGGG', |
|
| 693 | - ), |
|
| 694 | - //1999...2003 |
|
| 695 | - 'Y' => array( |
|
| 696 | - 'js' => 'yy', |
|
| 697 | - 'moment' => 'YYYY', |
|
| 698 | - ), |
|
| 699 | - //99...03 |
|
| 700 | - 'y' => array( |
|
| 701 | - 'js' => 'y', |
|
| 702 | - 'moment' => 'YY', |
|
| 703 | - ), |
|
| 704 | - // Time |
|
| 705 | - // am/pm |
|
| 706 | - 'a' => array( |
|
| 707 | - 'js' => 'tt', |
|
| 708 | - 'moment' => 'a', |
|
| 709 | - ), |
|
| 710 | - // AM/PM |
|
| 711 | - 'A' => array( |
|
| 712 | - 'js' => 'TT', |
|
| 713 | - 'moment' => 'A', |
|
| 714 | - ), |
|
| 715 | - // Swatch Internet Time?!? |
|
| 716 | - 'B' => array( |
|
| 717 | - 'js' => '', |
|
| 718 | - 'moment' => '', |
|
| 719 | - ), |
|
| 720 | - //1...12 |
|
| 721 | - 'g' => array( |
|
| 722 | - 'js' => 'h', |
|
| 723 | - 'moment' => 'h', |
|
| 724 | - ), |
|
| 725 | - //0...23 |
|
| 726 | - 'G' => array( |
|
| 727 | - 'js' => 'H', |
|
| 728 | - 'moment' => 'H', |
|
| 729 | - ), |
|
| 730 | - //01...12 |
|
| 731 | - 'h' => array( |
|
| 732 | - 'js' => 'hh', |
|
| 733 | - 'moment' => 'hh', |
|
| 734 | - ), |
|
| 735 | - //00...23 |
|
| 736 | - 'H' => array( |
|
| 737 | - 'js' => 'HH', |
|
| 738 | - 'moment' => 'HH', |
|
| 739 | - ), |
|
| 740 | - //00..59 |
|
| 741 | - 'i' => array( |
|
| 742 | - 'js' => 'mm', |
|
| 743 | - 'moment' => 'mm', |
|
| 744 | - ), |
|
| 745 | - //seconds... 00...59 |
|
| 746 | - 's' => array( |
|
| 747 | - 'js' => 'ss', |
|
| 748 | - 'moment' => 'ss', |
|
| 749 | - ), |
|
| 750 | - //microseconds |
|
| 751 | - 'u' => array( |
|
| 752 | - 'js' => '', |
|
| 753 | - 'moment' => '', |
|
| 754 | - ), |
|
| 755 | - ); |
|
| 756 | - $jquery_ui_format = ""; |
|
| 757 | - $moment_format = ""; |
|
| 758 | - $escaping = false; |
|
| 759 | - for ($i = 0; $i < strlen($format_string); $i++) { |
|
| 760 | - $char = $format_string[$i]; |
|
| 761 | - if ($char === '\\') { // PHP date format escaping character |
|
| 762 | - $i++; |
|
| 763 | - if ($escaping) { |
|
| 764 | - $jquery_ui_format .= $format_string[$i]; |
|
| 765 | - $moment_format .= $format_string[$i]; |
|
| 766 | - } else { |
|
| 767 | - $jquery_ui_format .= '\'' . $format_string[$i]; |
|
| 768 | - $moment_format .= $format_string[$i]; |
|
| 769 | - } |
|
| 770 | - $escaping = true; |
|
| 771 | - } else { |
|
| 772 | - if ($escaping) { |
|
| 773 | - $jquery_ui_format .= "'"; |
|
| 774 | - $moment_format .= "'"; |
|
| 775 | - $escaping = false; |
|
| 776 | - } |
|
| 777 | - if (isset($symbols_map[$char])) { |
|
| 778 | - $jquery_ui_format .= $symbols_map[$char]['js']; |
|
| 779 | - $moment_format .= $symbols_map[$char]['moment']; |
|
| 780 | - } else { |
|
| 781 | - $jquery_ui_format .= $char; |
|
| 782 | - $moment_format .= $char; |
|
| 783 | - } |
|
| 784 | - } |
|
| 785 | - } |
|
| 786 | - return array('js' => $jquery_ui_format, 'moment' => $moment_format); |
|
| 787 | - } |
|
| 788 | - |
|
| 789 | - |
|
| 790 | - /** |
|
| 791 | - * This takes an incoming format string and validates it to ensure it will work fine with PHP. |
|
| 792 | - * |
|
| 793 | - * @param string $format_string Incoming format string for php date(). |
|
| 794 | - * @return mixed bool|array If all is okay then TRUE is returned. Otherwise an array of validation |
|
| 795 | - * errors is returned. So for client code calling, check for is_array() to |
|
| 796 | - * indicate failed validations. |
|
| 797 | - */ |
|
| 798 | - public static function validate_format_string($format_string) |
|
| 799 | - { |
|
| 800 | - $error_msg = array(); |
|
| 801 | - //time format checks |
|
| 802 | - switch (true) { |
|
| 803 | - case strpos($format_string, 'h') !== false : |
|
| 804 | - case strpos($format_string, 'g') !== false : |
|
| 805 | - /** |
|
| 806 | - * if the time string has a lowercase 'h' which == 12 hour time format and there |
|
| 807 | - * is not any ante meridiem format ('a' or 'A'). Then throw an error because its |
|
| 808 | - * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am. |
|
| 809 | - */ |
|
| 810 | - if (strpos(strtoupper($format_string), 'A') === false) { |
|
| 811 | - $error_msg[] = __('There is a time format for 12 hour time but no "a" or "A" to indicate am/pm. Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', |
|
| 812 | - 'event_espresso'); |
|
| 813 | - } |
|
| 814 | - break; |
|
| 815 | - |
|
| 816 | - } |
|
| 817 | - |
|
| 818 | - return empty($error_msg) ? true : $error_msg; |
|
| 819 | - } |
|
| 820 | - |
|
| 821 | - |
|
| 822 | - /** |
|
| 823 | - * If the the first date starts at midnight on one day, and the next date ends at midnight on the |
|
| 824 | - * very next day then this method will return true. |
|
| 825 | - * If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-16 00:00:00 then this function will return true. |
|
| 826 | - * If $date_1 = 2015-12-15 03:00:00 and $date_2 = 2015-12_16 03:00:00 then this function will return false. |
|
| 827 | - * If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-15 00:00:00 then this function will return true. |
|
| 828 | - * |
|
| 829 | - * @param mixed $date_1 |
|
| 830 | - * @param mixed $date_2 |
|
| 831 | - * @return bool |
|
| 832 | - */ |
|
| 833 | - public static function dates_represent_one_24_hour_date($date_1, $date_2) |
|
| 834 | - { |
|
| 835 | - |
|
| 836 | - if ( |
|
| 837 | - (! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) || |
|
| 838 | - ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00') |
|
| 839 | - ) { |
|
| 840 | - return false; |
|
| 841 | - } |
|
| 842 | - return $date_2->format('U') - $date_1->format('U') == 86400 ? true : false; |
|
| 843 | - } |
|
| 844 | - |
|
| 845 | - |
|
| 846 | - /** |
|
| 847 | - * This returns the appropriate query interval string that can be used in sql queries involving mysql Date |
|
| 848 | - * Functions. |
|
| 849 | - * |
|
| 850 | - * @param string $timezone_string A timezone string in a valid format to instantiate a DateTimeZone object. |
|
| 851 | - * @param string $field_for_interval The Database field that is the interval is applied to in the query. |
|
| 852 | - * @return string |
|
| 853 | - */ |
|
| 854 | - public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval) |
|
| 855 | - { |
|
| 856 | - try { |
|
| 857 | - /** need to account for timezone offset on the selects */ |
|
| 858 | - $DateTimeZone = new DateTimeZone($timezone_string); |
|
| 859 | - } catch (Exception $e) { |
|
| 860 | - $DateTimeZone = null; |
|
| 861 | - } |
|
| 862 | - |
|
| 863 | - /** |
|
| 864 | - * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds. |
|
| 865 | - * Hence we do the calc for DateTimeZone::getOffset. |
|
| 866 | - */ |
|
| 867 | - $offset = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset'); |
|
| 868 | - $query_interval = $offset < 0 |
|
| 869 | - ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)' |
|
| 870 | - : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)'; |
|
| 871 | - return $query_interval; |
|
| 872 | - } |
|
| 873 | - |
|
| 874 | - /** |
|
| 875 | - * Retrieves the site's default timezone and returns it formatted so it's ready for display |
|
| 876 | - * to users. If you want to customize how its displayed feel free to fetch the 'timezone_string' |
|
| 877 | - * and 'gmt_offset' WordPress options directly; or use the filter |
|
| 878 | - * FHEE__EEH_DTT_Helper__get_timezone_string_for_display |
|
| 879 | - * (although note that we remove any HTML that may be added) |
|
| 880 | - * |
|
| 881 | - * @return string |
|
| 882 | - */ |
|
| 883 | - public static function get_timezone_string_for_display() |
|
| 884 | - { |
|
| 885 | - $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', ''); |
|
| 886 | - if (! empty($pretty_timezone)) { |
|
| 887 | - return esc_html($pretty_timezone); |
|
| 888 | - } |
|
| 889 | - $timezone_string = get_option('timezone_string'); |
|
| 890 | - if ($timezone_string) { |
|
| 891 | - static $mo_loaded = false; |
|
| 892 | - // Load translations for continents and cities just like wp_timezone_choice does |
|
| 893 | - if (! $mo_loaded) { |
|
| 894 | - $locale = get_locale(); |
|
| 895 | - $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo'; |
|
| 896 | - load_textdomain('continents-cities', $mofile); |
|
| 897 | - $mo_loaded = true; |
|
| 898 | - } |
|
| 899 | - //well that was easy. |
|
| 900 | - $parts = explode('/', $timezone_string); |
|
| 901 | - //remove the continent |
|
| 902 | - unset($parts[0]); |
|
| 903 | - $t_parts = array(); |
|
| 904 | - foreach ($parts as $part) { |
|
| 905 | - $t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities'); |
|
| 906 | - } |
|
| 907 | - return implode(' - ', $t_parts); |
|
| 908 | - } |
|
| 909 | - //they haven't set the timezone string, so let's return a string like "UTC+1" |
|
| 910 | - $gmt_offset = get_option('gmt_offset'); |
|
| 911 | - if (intval($gmt_offset) >= 0) { |
|
| 912 | - $prefix = '+'; |
|
| 913 | - } else { |
|
| 914 | - $prefix = ''; |
|
| 915 | - } |
|
| 916 | - $parts = explode('.', (string)$gmt_offset); |
|
| 917 | - if (count($parts) === 1) { |
|
| 918 | - $parts[1] = '00'; |
|
| 919 | - } else { |
|
| 920 | - //convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25) |
|
| 921 | - //to minutes, eg 30 or 15, respectively |
|
| 922 | - $hour_fraction = (float)('0.' . $parts[1]); |
|
| 923 | - $parts[1] = (string)$hour_fraction * 60; |
|
| 924 | - } |
|
| 925 | - return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts)); |
|
| 926 | - } |
|
| 927 | - |
|
| 928 | - |
|
| 929 | - |
|
| 930 | - /** |
|
| 931 | - * So PHP does this awesome thing where if you are trying to get a timestamp |
|
| 932 | - * for a month using a string like "February" or "February 2017", |
|
| 933 | - * and you don't specify a day as part of your string, |
|
| 934 | - * then PHP will use whatever the current day of the month is. |
|
| 935 | - * IF the current day of the month happens to be the 30th or 31st, |
|
| 936 | - * then PHP gets really confused by a date like February 30, |
|
| 937 | - * so instead of saying |
|
| 938 | - * "Hey February only has 28 days (this year)... |
|
| 939 | - * ...you must have meant the last day of the month!" |
|
| 940 | - * PHP does the next most logical thing, and bumps the date up to March 2nd, |
|
| 941 | - * because someone requesting February 30th obviously meant March 1st! |
|
| 942 | - * The way around this is to always set the day to the first, |
|
| 943 | - * so that the month will stay on the month you wanted. |
|
| 944 | - * this method will add that "1" into your date regardless of the format. |
|
| 945 | - * |
|
| 946 | - * @param string $month |
|
| 947 | - * @return string |
|
| 948 | - */ |
|
| 949 | - public static function first_of_month_timestamp($month = '') |
|
| 950 | - { |
|
| 951 | - $month = (string)$month; |
|
| 952 | - $year = ''; |
|
| 953 | - // check if the incoming string has a year in it or not |
|
| 954 | - if (preg_match('/\b\d{4}\b/', $month, $matches)) { |
|
| 955 | - $year = $matches[0]; |
|
| 956 | - // ten remove that from the month string as well as any spaces |
|
| 957 | - $month = trim(str_replace($year, '', $month)); |
|
| 958 | - // add a space before the year |
|
| 959 | - $year = " {$year}"; |
|
| 960 | - } |
|
| 961 | - // return timestamp for something like "February 1 2017" |
|
| 962 | - return strtotime("{$month} 1{$year}"); |
|
| 963 | - } |
|
| 323 | + endif; |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + |
|
| 327 | + /** |
|
| 328 | + * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string. |
|
| 329 | + * If no unix timestamp is given then time() is used. If no timezone is given then the set timezone string for |
|
| 330 | + * the site is used. |
|
| 331 | + * This is used typically when using a Unix timestamp any core WP functions that expect their specially |
|
| 332 | + * computed timestamp (i.e. date_i18n() ) |
|
| 333 | + * |
|
| 334 | + * @param int $unix_timestamp if 0, then time() will be used. |
|
| 335 | + * @param string $timezone_string timezone_string. If empty, then the current set timezone for the |
|
| 336 | + * site will be used. |
|
| 337 | + * @return int $unix_timestamp with the offset applied for the given timezone. |
|
| 338 | + */ |
|
| 339 | + public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '') |
|
| 340 | + { |
|
| 341 | + $unix_timestamp = $unix_timestamp === 0 ? time() : (int)$unix_timestamp; |
|
| 342 | + $timezone_string = self::get_valid_timezone_string($timezone_string); |
|
| 343 | + $TimeZone = new DateTimeZone($timezone_string); |
|
| 344 | + |
|
| 345 | + $DateTime = new DateTime('@' . $unix_timestamp, $TimeZone); |
|
| 346 | + $offset = timezone_offset_get($TimeZone, $DateTime); |
|
| 347 | + return (int)$DateTime->format('U') + (int)$offset; |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + |
|
| 351 | + /** |
|
| 352 | + * _set_date_time_field |
|
| 353 | + * modifies EE_Base_Class EE_Datetime_Field objects |
|
| 354 | + * |
|
| 355 | + * @param EE_Base_Class $obj EE_Base_Class object |
|
| 356 | + * @param DateTime $DateTime PHP DateTime object |
|
| 357 | + * @param string $datetime_field_name the datetime fieldname to be manipulated |
|
| 358 | + * @return EE_Base_Class |
|
| 359 | + */ |
|
| 360 | + protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name) |
|
| 361 | + { |
|
| 362 | + // grab current datetime format |
|
| 363 | + $current_format = $obj->get_format(); |
|
| 364 | + // set new full timestamp format |
|
| 365 | + $obj->set_date_format(EE_Datetime_Field::mysql_date_format); |
|
| 366 | + $obj->set_time_format(EE_Datetime_Field::mysql_time_format); |
|
| 367 | + // set the new date value using a full timestamp format so that no data is lost |
|
| 368 | + $obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format)); |
|
| 369 | + // reset datetime formats |
|
| 370 | + $obj->set_date_format($current_format[0]); |
|
| 371 | + $obj->set_time_format($current_format[1]); |
|
| 372 | + return $obj; |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * date_time_add |
|
| 378 | + * helper for doing simple datetime calculations on a given datetime from EE_Base_Class |
|
| 379 | + * and modifying it IN the EE_Base_Class so you don't have to do anything else. |
|
| 380 | + * |
|
| 381 | + * @param EE_Base_Class $obj EE_Base_Class object |
|
| 382 | + * @param string $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated |
|
| 383 | + * @param string $period what you are adding. The options are (years, months, days, hours, |
|
| 384 | + * minutes, seconds) defaults to years |
|
| 385 | + * @param integer $value what you want to increment the time by |
|
| 386 | + * @return EE_Base_Class return the EE_Base_Class object so right away you can do something with it |
|
| 387 | + * (chaining) |
|
| 388 | + */ |
|
| 389 | + public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) |
|
| 390 | + { |
|
| 391 | + //get the raw UTC date. |
|
| 392 | + $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
| 393 | + $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value); |
|
| 394 | + return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + |
|
| 398 | + /** |
|
| 399 | + * date_time_subtract |
|
| 400 | + * same as date_time_add except subtracting value instead of adding. |
|
| 401 | + * |
|
| 402 | + * @param \EE_Base_Class $obj |
|
| 403 | + * @param string $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated |
|
| 404 | + * @param string $period |
|
| 405 | + * @param int $value |
|
| 406 | + * @return \EE_Base_Class |
|
| 407 | + */ |
|
| 408 | + public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) |
|
| 409 | + { |
|
| 410 | + //get the raw UTC date |
|
| 411 | + $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
| 412 | + $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-'); |
|
| 413 | + return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
| 414 | + } |
|
| 415 | + |
|
| 416 | + |
|
| 417 | + /** |
|
| 418 | + * Simply takes an incoming DateTime object and does calculations on it based on the incoming parameters |
|
| 419 | + * |
|
| 420 | + * @param DateTime $DateTime DateTime object |
|
| 421 | + * @param string $period a value to indicate what interval is being used in the calculation. The options are |
|
| 422 | + * 'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years. |
|
| 423 | + * @param integer $value What you want to increment the date by |
|
| 424 | + * @param string $operand What operand you wish to use for the calculation |
|
| 425 | + * @return \DateTime return whatever type came in. |
|
| 426 | + * @throws \EE_Error |
|
| 427 | + */ |
|
| 428 | + protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+') |
|
| 429 | + { |
|
| 430 | + if (! $DateTime instanceof DateTime) { |
|
| 431 | + throw new EE_Error( |
|
| 432 | + sprintf( |
|
| 433 | + __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'), |
|
| 434 | + print_r($DateTime, true) |
|
| 435 | + ) |
|
| 436 | + ); |
|
| 437 | + } |
|
| 438 | + switch ($period) { |
|
| 439 | + case 'years' : |
|
| 440 | + $value = 'P' . $value . 'Y'; |
|
| 441 | + break; |
|
| 442 | + case 'months' : |
|
| 443 | + $value = 'P' . $value . 'M'; |
|
| 444 | + break; |
|
| 445 | + case 'weeks' : |
|
| 446 | + $value = 'P' . $value . 'W'; |
|
| 447 | + break; |
|
| 448 | + case 'days' : |
|
| 449 | + $value = 'P' . $value . 'D'; |
|
| 450 | + break; |
|
| 451 | + case 'hours' : |
|
| 452 | + $value = 'PT' . $value . 'H'; |
|
| 453 | + break; |
|
| 454 | + case 'minutes' : |
|
| 455 | + $value = 'PT' . $value . 'M'; |
|
| 456 | + break; |
|
| 457 | + case 'seconds' : |
|
| 458 | + $value = 'PT' . $value . 'S'; |
|
| 459 | + break; |
|
| 460 | + } |
|
| 461 | + switch ($operand) { |
|
| 462 | + case '+': |
|
| 463 | + $DateTime->add(new DateInterval($value)); |
|
| 464 | + break; |
|
| 465 | + case '-': |
|
| 466 | + $DateTime->sub(new DateInterval($value)); |
|
| 467 | + break; |
|
| 468 | + } |
|
| 469 | + return $DateTime; |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + |
|
| 473 | + /** |
|
| 474 | + * Simply takes an incoming Unix timestamp and does calculations on it based on the incoming parameters |
|
| 475 | + * |
|
| 476 | + * @param int $timestamp Unix timestamp |
|
| 477 | + * @param string $period a value to indicate what interval is being used in the calculation. The options are |
|
| 478 | + * 'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years. |
|
| 479 | + * @param integer $value What you want to increment the date by |
|
| 480 | + * @param string $operand What operand you wish to use for the calculation |
|
| 481 | + * @return \DateTime return whatever type came in. |
|
| 482 | + * @throws \EE_Error |
|
| 483 | + */ |
|
| 484 | + protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+') |
|
| 485 | + { |
|
| 486 | + if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) { |
|
| 487 | + throw new EE_Error( |
|
| 488 | + sprintf( |
|
| 489 | + __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'), |
|
| 490 | + print_r($timestamp, true) |
|
| 491 | + ) |
|
| 492 | + ); |
|
| 493 | + } |
|
| 494 | + switch ($period) { |
|
| 495 | + case 'years' : |
|
| 496 | + $value = YEAR_IN_SECONDS * $value; |
|
| 497 | + break; |
|
| 498 | + case 'months' : |
|
| 499 | + $value = YEAR_IN_SECONDS / 12 * $value; |
|
| 500 | + break; |
|
| 501 | + case 'weeks' : |
|
| 502 | + $value = WEEK_IN_SECONDS * $value; |
|
| 503 | + break; |
|
| 504 | + case 'days' : |
|
| 505 | + $value = DAY_IN_SECONDS * $value; |
|
| 506 | + break; |
|
| 507 | + case 'hours' : |
|
| 508 | + $value = HOUR_IN_SECONDS * $value; |
|
| 509 | + break; |
|
| 510 | + case 'minutes' : |
|
| 511 | + $value = MINUTE_IN_SECONDS * $value; |
|
| 512 | + break; |
|
| 513 | + } |
|
| 514 | + switch ($operand) { |
|
| 515 | + case '+': |
|
| 516 | + $timestamp += $value; |
|
| 517 | + break; |
|
| 518 | + case '-': |
|
| 519 | + $timestamp -= $value; |
|
| 520 | + break; |
|
| 521 | + } |
|
| 522 | + return $timestamp; |
|
| 523 | + } |
|
| 524 | + |
|
| 964 | 525 | |
| 965 | 526 | /** |
| 966 | - * This simply returns the timestamp for tomorrow (midnight next day) in this sites timezone. So it may be midnight |
|
| 967 | - * for this sites timezone, but the timestamp could be some other time GMT. |
|
| 968 | - */ |
|
| 969 | - public static function tomorrow() |
|
| 527 | + * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming |
|
| 528 | + * parameters and returns the new timestamp or DateTime. |
|
| 529 | + * |
|
| 530 | + * @param int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp |
|
| 531 | + * @param string $period a value to indicate what interval is being used in the |
|
| 532 | + * calculation. The options are 'years', 'months', 'days', 'hours', |
|
| 533 | + * 'minutes', 'seconds'. Defaults to years. |
|
| 534 | + * @param integer $value What you want to increment the date by |
|
| 535 | + * @param string $operand What operand you wish to use for the calculation |
|
| 536 | + * @return mixed string|DateTime return whatever type came in. |
|
| 537 | + */ |
|
| 538 | + public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+') |
|
| 539 | + { |
|
| 540 | + if ($DateTime_or_timestamp instanceof DateTime) { |
|
| 541 | + return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand); |
|
| 542 | + } else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) { |
|
| 543 | + return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand); |
|
| 544 | + } else { |
|
| 545 | + //error |
|
| 546 | + return $DateTime_or_timestamp; |
|
| 547 | + } |
|
| 548 | + } |
|
| 549 | + |
|
| 550 | + |
|
| 551 | + /** |
|
| 552 | + * The purpose of this helper method is to receive an incoming format string in php date/time format |
|
| 553 | + * and spit out the js and moment.js equivalent formats. |
|
| 554 | + * Note, if no format string is given, then it is assumed the user wants what is set for WP. |
|
| 555 | + * Note, js date and time formats are those used by the jquery-ui datepicker and the jquery-ui date- |
|
| 556 | + * time picker. |
|
| 557 | + * |
|
| 558 | + * @see http://stackoverflow.com/posts/16725290/ for the code inspiration. |
|
| 559 | + * @param null $date_format_string |
|
| 560 | + * @param null $time_format_string |
|
| 561 | + * @return array |
|
| 562 | + * array( |
|
| 563 | + * 'js' => array ( |
|
| 564 | + * 'date' => //date format |
|
| 565 | + * 'time' => //time format |
|
| 566 | + * ), |
|
| 567 | + * 'moment' => //date and time format. |
|
| 568 | + * ) |
|
| 569 | + */ |
|
| 570 | + public static function convert_php_to_js_and_moment_date_formats( |
|
| 571 | + $date_format_string = null, |
|
| 572 | + $time_format_string = null |
|
| 573 | + ) { |
|
| 574 | + if ($date_format_string === null) { |
|
| 575 | + $date_format_string = get_option('date_format'); |
|
| 576 | + } |
|
| 577 | + |
|
| 578 | + if ($time_format_string === null) { |
|
| 579 | + $time_format_string = get_option('time_format'); |
|
| 580 | + } |
|
| 581 | + |
|
| 582 | + $date_format = self::_php_to_js_moment_converter($date_format_string); |
|
| 583 | + $time_format = self::_php_to_js_moment_converter($time_format_string); |
|
| 584 | + |
|
| 585 | + return array( |
|
| 586 | + 'js' => array( |
|
| 587 | + 'date' => $date_format['js'], |
|
| 588 | + 'time' => $time_format['js'], |
|
| 589 | + ), |
|
| 590 | + 'moment' => $date_format['moment'] . ' ' . $time_format['moment'], |
|
| 591 | + ); |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + |
|
| 595 | + /** |
|
| 596 | + * This converts incoming format string into js and moment variations. |
|
| 597 | + * |
|
| 598 | + * @param string $format_string incoming php format string |
|
| 599 | + * @return array js and moment formats. |
|
| 600 | + */ |
|
| 601 | + protected static function _php_to_js_moment_converter($format_string) |
|
| 602 | + { |
|
| 603 | + /** |
|
| 604 | + * This is a map of symbols for formats. |
|
| 605 | + * The index is the php symbol, the equivalent values are in the array. |
|
| 606 | + * |
|
| 607 | + * @var array |
|
| 608 | + */ |
|
| 609 | + $symbols_map = array( |
|
| 610 | + // Day |
|
| 611 | + //01 |
|
| 612 | + 'd' => array( |
|
| 613 | + 'js' => 'dd', |
|
| 614 | + 'moment' => 'DD', |
|
| 615 | + ), |
|
| 616 | + //Mon |
|
| 617 | + 'D' => array( |
|
| 618 | + 'js' => 'D', |
|
| 619 | + 'moment' => 'ddd', |
|
| 620 | + ), |
|
| 621 | + //1,2,...31 |
|
| 622 | + 'j' => array( |
|
| 623 | + 'js' => 'd', |
|
| 624 | + 'moment' => 'D', |
|
| 625 | + ), |
|
| 626 | + //Monday |
|
| 627 | + 'l' => array( |
|
| 628 | + 'js' => 'DD', |
|
| 629 | + 'moment' => 'dddd', |
|
| 630 | + ), |
|
| 631 | + //ISO numeric representation of the day of the week (1-6) |
|
| 632 | + 'N' => array( |
|
| 633 | + 'js' => '', |
|
| 634 | + 'moment' => 'E', |
|
| 635 | + ), |
|
| 636 | + //st,nd.rd |
|
| 637 | + 'S' => array( |
|
| 638 | + 'js' => '', |
|
| 639 | + 'moment' => 'o', |
|
| 640 | + ), |
|
| 641 | + //numeric representation of day of week (0-6) |
|
| 642 | + 'w' => array( |
|
| 643 | + 'js' => '', |
|
| 644 | + 'moment' => 'd', |
|
| 645 | + ), |
|
| 646 | + //day of year starting from 0 (0-365) |
|
| 647 | + 'z' => array( |
|
| 648 | + 'js' => 'o', |
|
| 649 | + 'moment' => 'DDD' //note moment does not start with 0 so will need to modify by subtracting 1 |
|
| 650 | + ), |
|
| 651 | + // Week |
|
| 652 | + //ISO-8601 week number of year (weeks starting on monday) |
|
| 653 | + 'W' => array( |
|
| 654 | + 'js' => '', |
|
| 655 | + 'moment' => 'w', |
|
| 656 | + ), |
|
| 657 | + // Month |
|
| 658 | + // January...December |
|
| 659 | + 'F' => array( |
|
| 660 | + 'js' => 'MM', |
|
| 661 | + 'moment' => 'MMMM', |
|
| 662 | + ), |
|
| 663 | + //01...12 |
|
| 664 | + 'm' => array( |
|
| 665 | + 'js' => 'mm', |
|
| 666 | + 'moment' => 'MM', |
|
| 667 | + ), |
|
| 668 | + //Jan...Dec |
|
| 669 | + 'M' => array( |
|
| 670 | + 'js' => 'M', |
|
| 671 | + 'moment' => 'MMM', |
|
| 672 | + ), |
|
| 673 | + //1-12 |
|
| 674 | + 'n' => array( |
|
| 675 | + 'js' => 'm', |
|
| 676 | + 'moment' => 'M', |
|
| 677 | + ), |
|
| 678 | + //number of days in given month |
|
| 679 | + 't' => array( |
|
| 680 | + 'js' => '', |
|
| 681 | + 'moment' => '', |
|
| 682 | + ), |
|
| 683 | + // Year |
|
| 684 | + //whether leap year or not 1/0 |
|
| 685 | + 'L' => array( |
|
| 686 | + 'js' => '', |
|
| 687 | + 'moment' => '', |
|
| 688 | + ), |
|
| 689 | + //ISO-8601 year number |
|
| 690 | + 'o' => array( |
|
| 691 | + 'js' => '', |
|
| 692 | + 'moment' => 'GGGG', |
|
| 693 | + ), |
|
| 694 | + //1999...2003 |
|
| 695 | + 'Y' => array( |
|
| 696 | + 'js' => 'yy', |
|
| 697 | + 'moment' => 'YYYY', |
|
| 698 | + ), |
|
| 699 | + //99...03 |
|
| 700 | + 'y' => array( |
|
| 701 | + 'js' => 'y', |
|
| 702 | + 'moment' => 'YY', |
|
| 703 | + ), |
|
| 704 | + // Time |
|
| 705 | + // am/pm |
|
| 706 | + 'a' => array( |
|
| 707 | + 'js' => 'tt', |
|
| 708 | + 'moment' => 'a', |
|
| 709 | + ), |
|
| 710 | + // AM/PM |
|
| 711 | + 'A' => array( |
|
| 712 | + 'js' => 'TT', |
|
| 713 | + 'moment' => 'A', |
|
| 714 | + ), |
|
| 715 | + // Swatch Internet Time?!? |
|
| 716 | + 'B' => array( |
|
| 717 | + 'js' => '', |
|
| 718 | + 'moment' => '', |
|
| 719 | + ), |
|
| 720 | + //1...12 |
|
| 721 | + 'g' => array( |
|
| 722 | + 'js' => 'h', |
|
| 723 | + 'moment' => 'h', |
|
| 724 | + ), |
|
| 725 | + //0...23 |
|
| 726 | + 'G' => array( |
|
| 727 | + 'js' => 'H', |
|
| 728 | + 'moment' => 'H', |
|
| 729 | + ), |
|
| 730 | + //01...12 |
|
| 731 | + 'h' => array( |
|
| 732 | + 'js' => 'hh', |
|
| 733 | + 'moment' => 'hh', |
|
| 734 | + ), |
|
| 735 | + //00...23 |
|
| 736 | + 'H' => array( |
|
| 737 | + 'js' => 'HH', |
|
| 738 | + 'moment' => 'HH', |
|
| 739 | + ), |
|
| 740 | + //00..59 |
|
| 741 | + 'i' => array( |
|
| 742 | + 'js' => 'mm', |
|
| 743 | + 'moment' => 'mm', |
|
| 744 | + ), |
|
| 745 | + //seconds... 00...59 |
|
| 746 | + 's' => array( |
|
| 747 | + 'js' => 'ss', |
|
| 748 | + 'moment' => 'ss', |
|
| 749 | + ), |
|
| 750 | + //microseconds |
|
| 751 | + 'u' => array( |
|
| 752 | + 'js' => '', |
|
| 753 | + 'moment' => '', |
|
| 754 | + ), |
|
| 755 | + ); |
|
| 756 | + $jquery_ui_format = ""; |
|
| 757 | + $moment_format = ""; |
|
| 758 | + $escaping = false; |
|
| 759 | + for ($i = 0; $i < strlen($format_string); $i++) { |
|
| 760 | + $char = $format_string[$i]; |
|
| 761 | + if ($char === '\\') { // PHP date format escaping character |
|
| 762 | + $i++; |
|
| 763 | + if ($escaping) { |
|
| 764 | + $jquery_ui_format .= $format_string[$i]; |
|
| 765 | + $moment_format .= $format_string[$i]; |
|
| 766 | + } else { |
|
| 767 | + $jquery_ui_format .= '\'' . $format_string[$i]; |
|
| 768 | + $moment_format .= $format_string[$i]; |
|
| 769 | + } |
|
| 770 | + $escaping = true; |
|
| 771 | + } else { |
|
| 772 | + if ($escaping) { |
|
| 773 | + $jquery_ui_format .= "'"; |
|
| 774 | + $moment_format .= "'"; |
|
| 775 | + $escaping = false; |
|
| 776 | + } |
|
| 777 | + if (isset($symbols_map[$char])) { |
|
| 778 | + $jquery_ui_format .= $symbols_map[$char]['js']; |
|
| 779 | + $moment_format .= $symbols_map[$char]['moment']; |
|
| 780 | + } else { |
|
| 781 | + $jquery_ui_format .= $char; |
|
| 782 | + $moment_format .= $char; |
|
| 783 | + } |
|
| 784 | + } |
|
| 785 | + } |
|
| 786 | + return array('js' => $jquery_ui_format, 'moment' => $moment_format); |
|
| 787 | + } |
|
| 788 | + |
|
| 789 | + |
|
| 790 | + /** |
|
| 791 | + * This takes an incoming format string and validates it to ensure it will work fine with PHP. |
|
| 792 | + * |
|
| 793 | + * @param string $format_string Incoming format string for php date(). |
|
| 794 | + * @return mixed bool|array If all is okay then TRUE is returned. Otherwise an array of validation |
|
| 795 | + * errors is returned. So for client code calling, check for is_array() to |
|
| 796 | + * indicate failed validations. |
|
| 797 | + */ |
|
| 798 | + public static function validate_format_string($format_string) |
|
| 799 | + { |
|
| 800 | + $error_msg = array(); |
|
| 801 | + //time format checks |
|
| 802 | + switch (true) { |
|
| 803 | + case strpos($format_string, 'h') !== false : |
|
| 804 | + case strpos($format_string, 'g') !== false : |
|
| 805 | + /** |
|
| 806 | + * if the time string has a lowercase 'h' which == 12 hour time format and there |
|
| 807 | + * is not any ante meridiem format ('a' or 'A'). Then throw an error because its |
|
| 808 | + * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am. |
|
| 809 | + */ |
|
| 810 | + if (strpos(strtoupper($format_string), 'A') === false) { |
|
| 811 | + $error_msg[] = __('There is a time format for 12 hour time but no "a" or "A" to indicate am/pm. Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', |
|
| 812 | + 'event_espresso'); |
|
| 813 | + } |
|
| 814 | + break; |
|
| 815 | + |
|
| 816 | + } |
|
| 817 | + |
|
| 818 | + return empty($error_msg) ? true : $error_msg; |
|
| 819 | + } |
|
| 820 | + |
|
| 821 | + |
|
| 822 | + /** |
|
| 823 | + * If the the first date starts at midnight on one day, and the next date ends at midnight on the |
|
| 824 | + * very next day then this method will return true. |
|
| 825 | + * If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-16 00:00:00 then this function will return true. |
|
| 826 | + * If $date_1 = 2015-12-15 03:00:00 and $date_2 = 2015-12_16 03:00:00 then this function will return false. |
|
| 827 | + * If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-15 00:00:00 then this function will return true. |
|
| 828 | + * |
|
| 829 | + * @param mixed $date_1 |
|
| 830 | + * @param mixed $date_2 |
|
| 831 | + * @return bool |
|
| 832 | + */ |
|
| 833 | + public static function dates_represent_one_24_hour_date($date_1, $date_2) |
|
| 834 | + { |
|
| 835 | + |
|
| 836 | + if ( |
|
| 837 | + (! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) || |
|
| 838 | + ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00') |
|
| 839 | + ) { |
|
| 840 | + return false; |
|
| 841 | + } |
|
| 842 | + return $date_2->format('U') - $date_1->format('U') == 86400 ? true : false; |
|
| 843 | + } |
|
| 844 | + |
|
| 845 | + |
|
| 846 | + /** |
|
| 847 | + * This returns the appropriate query interval string that can be used in sql queries involving mysql Date |
|
| 848 | + * Functions. |
|
| 849 | + * |
|
| 850 | + * @param string $timezone_string A timezone string in a valid format to instantiate a DateTimeZone object. |
|
| 851 | + * @param string $field_for_interval The Database field that is the interval is applied to in the query. |
|
| 852 | + * @return string |
|
| 853 | + */ |
|
| 854 | + public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval) |
|
| 855 | + { |
|
| 856 | + try { |
|
| 857 | + /** need to account for timezone offset on the selects */ |
|
| 858 | + $DateTimeZone = new DateTimeZone($timezone_string); |
|
| 859 | + } catch (Exception $e) { |
|
| 860 | + $DateTimeZone = null; |
|
| 861 | + } |
|
| 862 | + |
|
| 863 | + /** |
|
| 864 | + * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds. |
|
| 865 | + * Hence we do the calc for DateTimeZone::getOffset. |
|
| 866 | + */ |
|
| 867 | + $offset = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset'); |
|
| 868 | + $query_interval = $offset < 0 |
|
| 869 | + ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)' |
|
| 870 | + : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)'; |
|
| 871 | + return $query_interval; |
|
| 872 | + } |
|
| 873 | + |
|
| 874 | + /** |
|
| 875 | + * Retrieves the site's default timezone and returns it formatted so it's ready for display |
|
| 876 | + * to users. If you want to customize how its displayed feel free to fetch the 'timezone_string' |
|
| 877 | + * and 'gmt_offset' WordPress options directly; or use the filter |
|
| 878 | + * FHEE__EEH_DTT_Helper__get_timezone_string_for_display |
|
| 879 | + * (although note that we remove any HTML that may be added) |
|
| 880 | + * |
|
| 881 | + * @return string |
|
| 882 | + */ |
|
| 883 | + public static function get_timezone_string_for_display() |
|
| 884 | + { |
|
| 885 | + $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', ''); |
|
| 886 | + if (! empty($pretty_timezone)) { |
|
| 887 | + return esc_html($pretty_timezone); |
|
| 888 | + } |
|
| 889 | + $timezone_string = get_option('timezone_string'); |
|
| 890 | + if ($timezone_string) { |
|
| 891 | + static $mo_loaded = false; |
|
| 892 | + // Load translations for continents and cities just like wp_timezone_choice does |
|
| 893 | + if (! $mo_loaded) { |
|
| 894 | + $locale = get_locale(); |
|
| 895 | + $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo'; |
|
| 896 | + load_textdomain('continents-cities', $mofile); |
|
| 897 | + $mo_loaded = true; |
|
| 898 | + } |
|
| 899 | + //well that was easy. |
|
| 900 | + $parts = explode('/', $timezone_string); |
|
| 901 | + //remove the continent |
|
| 902 | + unset($parts[0]); |
|
| 903 | + $t_parts = array(); |
|
| 904 | + foreach ($parts as $part) { |
|
| 905 | + $t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities'); |
|
| 906 | + } |
|
| 907 | + return implode(' - ', $t_parts); |
|
| 908 | + } |
|
| 909 | + //they haven't set the timezone string, so let's return a string like "UTC+1" |
|
| 910 | + $gmt_offset = get_option('gmt_offset'); |
|
| 911 | + if (intval($gmt_offset) >= 0) { |
|
| 912 | + $prefix = '+'; |
|
| 913 | + } else { |
|
| 914 | + $prefix = ''; |
|
| 915 | + } |
|
| 916 | + $parts = explode('.', (string)$gmt_offset); |
|
| 917 | + if (count($parts) === 1) { |
|
| 918 | + $parts[1] = '00'; |
|
| 919 | + } else { |
|
| 920 | + //convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25) |
|
| 921 | + //to minutes, eg 30 or 15, respectively |
|
| 922 | + $hour_fraction = (float)('0.' . $parts[1]); |
|
| 923 | + $parts[1] = (string)$hour_fraction * 60; |
|
| 924 | + } |
|
| 925 | + return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts)); |
|
| 926 | + } |
|
| 927 | + |
|
| 928 | + |
|
| 929 | + |
|
| 930 | + /** |
|
| 931 | + * So PHP does this awesome thing where if you are trying to get a timestamp |
|
| 932 | + * for a month using a string like "February" or "February 2017", |
|
| 933 | + * and you don't specify a day as part of your string, |
|
| 934 | + * then PHP will use whatever the current day of the month is. |
|
| 935 | + * IF the current day of the month happens to be the 30th or 31st, |
|
| 936 | + * then PHP gets really confused by a date like February 30, |
|
| 937 | + * so instead of saying |
|
| 938 | + * "Hey February only has 28 days (this year)... |
|
| 939 | + * ...you must have meant the last day of the month!" |
|
| 940 | + * PHP does the next most logical thing, and bumps the date up to March 2nd, |
|
| 941 | + * because someone requesting February 30th obviously meant March 1st! |
|
| 942 | + * The way around this is to always set the day to the first, |
|
| 943 | + * so that the month will stay on the month you wanted. |
|
| 944 | + * this method will add that "1" into your date regardless of the format. |
|
| 945 | + * |
|
| 946 | + * @param string $month |
|
| 947 | + * @return string |
|
| 948 | + */ |
|
| 949 | + public static function first_of_month_timestamp($month = '') |
|
| 950 | + { |
|
| 951 | + $month = (string)$month; |
|
| 952 | + $year = ''; |
|
| 953 | + // check if the incoming string has a year in it or not |
|
| 954 | + if (preg_match('/\b\d{4}\b/', $month, $matches)) { |
|
| 955 | + $year = $matches[0]; |
|
| 956 | + // ten remove that from the month string as well as any spaces |
|
| 957 | + $month = trim(str_replace($year, '', $month)); |
|
| 958 | + // add a space before the year |
|
| 959 | + $year = " {$year}"; |
|
| 960 | + } |
|
| 961 | + // return timestamp for something like "February 1 2017" |
|
| 962 | + return strtotime("{$month} 1{$year}"); |
|
| 963 | + } |
|
| 964 | + |
|
| 965 | + /** |
|
| 966 | + * This simply returns the timestamp for tomorrow (midnight next day) in this sites timezone. So it may be midnight |
|
| 967 | + * for this sites timezone, but the timestamp could be some other time GMT. |
|
| 968 | + */ |
|
| 969 | + public static function tomorrow() |
|
| 970 | 970 | { |
| 971 | 971 | //The multiplication of -1 ensures that we switch positive offsets to negative and negative offsets to positive |
| 972 | 972 | //before adding to the timestamp. Why? Because we want tomorrow to be for midnight the next day in THIS timezone |
@@ -976,135 +976,135 @@ discard block |
||
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | |
| 979 | - /** |
|
| 980 | - * ** |
|
| 981 | - * Gives a nicely-formatted list of timezone strings. |
|
| 982 | - * Copied from the core wp function by the same name so we could customize to remove UTC offsets. |
|
| 983 | - * |
|
| 984 | - * @since 4.9.40.rc.008 |
|
| 985 | - * @staticvar bool $mo_loaded |
|
| 986 | - * @staticvar string $locale_loaded |
|
| 987 | - * @param string $selected_zone Selected timezone. |
|
| 988 | - * @param string $locale Optional. Locale to load the timezones in. Default current site locale. |
|
| 989 | - * @return string |
|
| 990 | - */ |
|
| 991 | - public static function wp_timezone_choice($selected_zone, $locale = null) |
|
| 992 | - { |
|
| 993 | - static $mo_loaded = false, $locale_loaded = null; |
|
| 994 | - |
|
| 995 | - $continents = array( |
|
| 996 | - 'Africa', |
|
| 997 | - 'America', |
|
| 998 | - 'Antarctica', |
|
| 999 | - 'Arctic', |
|
| 1000 | - 'Asia', |
|
| 1001 | - 'Atlantic', |
|
| 1002 | - 'Australia', |
|
| 1003 | - 'Europe', |
|
| 1004 | - 'Indian', |
|
| 1005 | - 'Pacific', |
|
| 1006 | - ); |
|
| 1007 | - |
|
| 1008 | - // Load translations for continents and cities. |
|
| 1009 | - if (! $mo_loaded || $locale !== $locale_loaded) { |
|
| 1010 | - $locale_loaded = $locale ? $locale : get_locale(); |
|
| 1011 | - $mofile = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo'; |
|
| 1012 | - unload_textdomain('continents-cities'); |
|
| 1013 | - load_textdomain('continents-cities', $mofile); |
|
| 1014 | - $mo_loaded = true; |
|
| 1015 | - } |
|
| 1016 | - |
|
| 1017 | - $zonen = array(); |
|
| 1018 | - foreach (timezone_identifiers_list() as $zone) { |
|
| 1019 | - $zone = explode('/', $zone); |
|
| 1020 | - if (! in_array($zone[0], $continents)) { |
|
| 1021 | - continue; |
|
| 1022 | - } |
|
| 1023 | - |
|
| 1024 | - // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later |
|
| 1025 | - $exists = array( |
|
| 1026 | - 0 => (isset($zone[0]) && $zone[0]), |
|
| 1027 | - 1 => (isset($zone[1]) && $zone[1]), |
|
| 1028 | - 2 => (isset($zone[2]) && $zone[2]), |
|
| 1029 | - ); |
|
| 1030 | - $exists[3] = ($exists[0] && 'Etc' !== $zone[0]); |
|
| 1031 | - $exists[4] = ($exists[1] && $exists[3]); |
|
| 1032 | - $exists[5] = ($exists[2] && $exists[3]); |
|
| 1033 | - |
|
| 1034 | - $zonen[] = array( |
|
| 1035 | - 'continent' => ($exists[0] ? $zone[0] : ''), |
|
| 1036 | - 'city' => ($exists[1] ? $zone[1] : ''), |
|
| 1037 | - 'subcity' => ($exists[2] ? $zone[2] : ''), |
|
| 1038 | - 't_continent' => ($exists[3] ? translate(str_replace('_', ' ', $zone[0]), 'continents-cities') : ''), |
|
| 1039 | - 't_city' => ($exists[4] ? translate(str_replace('_', ' ', $zone[1]), 'continents-cities') : ''), |
|
| 1040 | - 't_subcity' => ($exists[5] ? translate(str_replace('_', ' ', $zone[2]), 'continents-cities') : ''), |
|
| 1041 | - ); |
|
| 1042 | - } |
|
| 1043 | - usort($zonen, '_wp_timezone_choice_usort_callback'); |
|
| 1044 | - |
|
| 1045 | - $structure = array(); |
|
| 1046 | - |
|
| 1047 | - if (empty($selected_zone)) { |
|
| 1048 | - $structure[] = '<option selected="selected" value="">' . __('Select a city') . '</option>'; |
|
| 1049 | - } |
|
| 1050 | - |
|
| 1051 | - foreach ($zonen as $key => $zone) { |
|
| 1052 | - // Build value in an array to join later |
|
| 1053 | - $value = array($zone['continent']); |
|
| 1054 | - |
|
| 1055 | - if (empty($zone['city'])) { |
|
| 1056 | - // It's at the continent level (generally won't happen) |
|
| 1057 | - $display = $zone['t_continent']; |
|
| 1058 | - } else { |
|
| 1059 | - // It's inside a continent group |
|
| 1060 | - |
|
| 1061 | - // Continent optgroup |
|
| 1062 | - if (! isset($zonen[$key - 1]) || $zonen[$key - 1]['continent'] !== $zone['continent']) { |
|
| 1063 | - $label = $zone['t_continent']; |
|
| 1064 | - $structure[] = '<optgroup label="' . esc_attr($label) . '">'; |
|
| 1065 | - } |
|
| 1066 | - |
|
| 1067 | - // Add the city to the value |
|
| 1068 | - $value[] = $zone['city']; |
|
| 1069 | - |
|
| 1070 | - $display = $zone['t_city']; |
|
| 1071 | - if (! empty($zone['subcity'])) { |
|
| 1072 | - // Add the subcity to the value |
|
| 1073 | - $value[] = $zone['subcity']; |
|
| 1074 | - $display .= ' - ' . $zone['t_subcity']; |
|
| 1075 | - } |
|
| 1076 | - } |
|
| 1077 | - |
|
| 1078 | - // Build the value |
|
| 1079 | - $value = join('/', $value); |
|
| 1080 | - $selected = ''; |
|
| 1081 | - if ($value === $selected_zone) { |
|
| 1082 | - $selected = 'selected="selected" '; |
|
| 1083 | - } |
|
| 1084 | - $structure[] = '<option ' . $selected . 'value="' . esc_attr($value) . '">' . esc_html($display) . "</option>"; |
|
| 1085 | - |
|
| 1086 | - // Close continent optgroup |
|
| 1087 | - if (! empty($zone['city']) && (! isset($zonen[$key + 1]) || (isset($zonen[$key + 1]) && $zonen[$key + 1]['continent'] !== $zone['continent']))) { |
|
| 1088 | - $structure[] = '</optgroup>'; |
|
| 1089 | - } |
|
| 1090 | - } |
|
| 1091 | - |
|
| 1092 | - return join("\n", $structure); |
|
| 1093 | - } |
|
| 1094 | - |
|
| 1095 | - |
|
| 1096 | - /** |
|
| 1097 | - * Shim for the WP function `get_user_locale` that was added in WordPress 4.7.0 |
|
| 1098 | - * |
|
| 1099 | - * @param int|WP_User $user_id |
|
| 1100 | - * @return string |
|
| 1101 | - */ |
|
| 1102 | - public static function get_user_locale($user_id = 0) |
|
| 1103 | - { |
|
| 1104 | - if (function_exists('get_user_locale')) { |
|
| 1105 | - return get_user_locale($user_id); |
|
| 1106 | - } |
|
| 1107 | - return get_locale(); |
|
| 1108 | - } |
|
| 979 | + /** |
|
| 980 | + * ** |
|
| 981 | + * Gives a nicely-formatted list of timezone strings. |
|
| 982 | + * Copied from the core wp function by the same name so we could customize to remove UTC offsets. |
|
| 983 | + * |
|
| 984 | + * @since 4.9.40.rc.008 |
|
| 985 | + * @staticvar bool $mo_loaded |
|
| 986 | + * @staticvar string $locale_loaded |
|
| 987 | + * @param string $selected_zone Selected timezone. |
|
| 988 | + * @param string $locale Optional. Locale to load the timezones in. Default current site locale. |
|
| 989 | + * @return string |
|
| 990 | + */ |
|
| 991 | + public static function wp_timezone_choice($selected_zone, $locale = null) |
|
| 992 | + { |
|
| 993 | + static $mo_loaded = false, $locale_loaded = null; |
|
| 994 | + |
|
| 995 | + $continents = array( |
|
| 996 | + 'Africa', |
|
| 997 | + 'America', |
|
| 998 | + 'Antarctica', |
|
| 999 | + 'Arctic', |
|
| 1000 | + 'Asia', |
|
| 1001 | + 'Atlantic', |
|
| 1002 | + 'Australia', |
|
| 1003 | + 'Europe', |
|
| 1004 | + 'Indian', |
|
| 1005 | + 'Pacific', |
|
| 1006 | + ); |
|
| 1007 | + |
|
| 1008 | + // Load translations for continents and cities. |
|
| 1009 | + if (! $mo_loaded || $locale !== $locale_loaded) { |
|
| 1010 | + $locale_loaded = $locale ? $locale : get_locale(); |
|
| 1011 | + $mofile = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo'; |
|
| 1012 | + unload_textdomain('continents-cities'); |
|
| 1013 | + load_textdomain('continents-cities', $mofile); |
|
| 1014 | + $mo_loaded = true; |
|
| 1015 | + } |
|
| 1016 | + |
|
| 1017 | + $zonen = array(); |
|
| 1018 | + foreach (timezone_identifiers_list() as $zone) { |
|
| 1019 | + $zone = explode('/', $zone); |
|
| 1020 | + if (! in_array($zone[0], $continents)) { |
|
| 1021 | + continue; |
|
| 1022 | + } |
|
| 1023 | + |
|
| 1024 | + // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later |
|
| 1025 | + $exists = array( |
|
| 1026 | + 0 => (isset($zone[0]) && $zone[0]), |
|
| 1027 | + 1 => (isset($zone[1]) && $zone[1]), |
|
| 1028 | + 2 => (isset($zone[2]) && $zone[2]), |
|
| 1029 | + ); |
|
| 1030 | + $exists[3] = ($exists[0] && 'Etc' !== $zone[0]); |
|
| 1031 | + $exists[4] = ($exists[1] && $exists[3]); |
|
| 1032 | + $exists[5] = ($exists[2] && $exists[3]); |
|
| 1033 | + |
|
| 1034 | + $zonen[] = array( |
|
| 1035 | + 'continent' => ($exists[0] ? $zone[0] : ''), |
|
| 1036 | + 'city' => ($exists[1] ? $zone[1] : ''), |
|
| 1037 | + 'subcity' => ($exists[2] ? $zone[2] : ''), |
|
| 1038 | + 't_continent' => ($exists[3] ? translate(str_replace('_', ' ', $zone[0]), 'continents-cities') : ''), |
|
| 1039 | + 't_city' => ($exists[4] ? translate(str_replace('_', ' ', $zone[1]), 'continents-cities') : ''), |
|
| 1040 | + 't_subcity' => ($exists[5] ? translate(str_replace('_', ' ', $zone[2]), 'continents-cities') : ''), |
|
| 1041 | + ); |
|
| 1042 | + } |
|
| 1043 | + usort($zonen, '_wp_timezone_choice_usort_callback'); |
|
| 1044 | + |
|
| 1045 | + $structure = array(); |
|
| 1046 | + |
|
| 1047 | + if (empty($selected_zone)) { |
|
| 1048 | + $structure[] = '<option selected="selected" value="">' . __('Select a city') . '</option>'; |
|
| 1049 | + } |
|
| 1050 | + |
|
| 1051 | + foreach ($zonen as $key => $zone) { |
|
| 1052 | + // Build value in an array to join later |
|
| 1053 | + $value = array($zone['continent']); |
|
| 1054 | + |
|
| 1055 | + if (empty($zone['city'])) { |
|
| 1056 | + // It's at the continent level (generally won't happen) |
|
| 1057 | + $display = $zone['t_continent']; |
|
| 1058 | + } else { |
|
| 1059 | + // It's inside a continent group |
|
| 1060 | + |
|
| 1061 | + // Continent optgroup |
|
| 1062 | + if (! isset($zonen[$key - 1]) || $zonen[$key - 1]['continent'] !== $zone['continent']) { |
|
| 1063 | + $label = $zone['t_continent']; |
|
| 1064 | + $structure[] = '<optgroup label="' . esc_attr($label) . '">'; |
|
| 1065 | + } |
|
| 1066 | + |
|
| 1067 | + // Add the city to the value |
|
| 1068 | + $value[] = $zone['city']; |
|
| 1069 | + |
|
| 1070 | + $display = $zone['t_city']; |
|
| 1071 | + if (! empty($zone['subcity'])) { |
|
| 1072 | + // Add the subcity to the value |
|
| 1073 | + $value[] = $zone['subcity']; |
|
| 1074 | + $display .= ' - ' . $zone['t_subcity']; |
|
| 1075 | + } |
|
| 1076 | + } |
|
| 1077 | + |
|
| 1078 | + // Build the value |
|
| 1079 | + $value = join('/', $value); |
|
| 1080 | + $selected = ''; |
|
| 1081 | + if ($value === $selected_zone) { |
|
| 1082 | + $selected = 'selected="selected" '; |
|
| 1083 | + } |
|
| 1084 | + $structure[] = '<option ' . $selected . 'value="' . esc_attr($value) . '">' . esc_html($display) . "</option>"; |
|
| 1085 | + |
|
| 1086 | + // Close continent optgroup |
|
| 1087 | + if (! empty($zone['city']) && (! isset($zonen[$key + 1]) || (isset($zonen[$key + 1]) && $zonen[$key + 1]['continent'] !== $zone['continent']))) { |
|
| 1088 | + $structure[] = '</optgroup>'; |
|
| 1089 | + } |
|
| 1090 | + } |
|
| 1091 | + |
|
| 1092 | + return join("\n", $structure); |
|
| 1093 | + } |
|
| 1094 | + |
|
| 1095 | + |
|
| 1096 | + /** |
|
| 1097 | + * Shim for the WP function `get_user_locale` that was added in WordPress 4.7.0 |
|
| 1098 | + * |
|
| 1099 | + * @param int|WP_User $user_id |
|
| 1100 | + * @return string |
|
| 1101 | + */ |
|
| 1102 | + public static function get_user_locale($user_id = 0) |
|
| 1103 | + { |
|
| 1104 | + if (function_exists('get_user_locale')) { |
|
| 1105 | + return get_user_locale($user_id); |
|
| 1106 | + } |
|
| 1107 | + return get_locale(); |
|
| 1108 | + } |
|
| 1109 | 1109 | |
| 1110 | 1110 | }// end class EEH_DTT_Helper |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | 3 | exit('NO direct script access allowed'); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | new DateTimeZone($timezone_string); |
| 75 | 75 | } catch (Exception $e) { |
| 76 | 76 | // sometimes we take exception to exceptions |
| 77 | - if (! $throw_error) { |
|
| 77 | + if ( ! $throw_error) { |
|
| 78 | 78 | return false; |
| 79 | 79 | } |
| 80 | 80 | throw new EE_Error( |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | $offset = get_option('gmt_offset'); |
| 138 | - return (int)($offset * HOUR_IN_SECONDS); |
|
| 138 | + return (int) ($offset * HOUR_IN_SECONDS); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | public static function adjust_invalid_gmt_offsets($gmt_offset = 0) |
| 150 | 150 | { |
| 151 | 151 | //make sure $gmt_offset is int |
| 152 | - $gmt_offset = (int)$gmt_offset; |
|
| 152 | + $gmt_offset = (int) $gmt_offset; |
|
| 153 | 153 | switch ($gmt_offset) { |
| 154 | 154 | |
| 155 | 155 | // case -30600 : |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | public static function timezone_select_input($timezone_string = '') |
| 234 | 234 | { |
| 235 | 235 | // get WP date time format |
| 236 | - $datetime_format = get_option('date_format') . ' ' . get_option('time_format'); |
|
| 236 | + $datetime_format = get_option('date_format').' '.get_option('time_format'); |
|
| 237 | 237 | // if passed a value, then use that, else get WP option |
| 238 | 238 | $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
| 239 | 239 | // check if the timezone is valid but don't throw any errors if it isn't |
@@ -245,9 +245,9 @@ discard block |
||
| 245 | 245 | // Create a UTC+- zone if no timezone string exists |
| 246 | 246 | $check_zone_info = false; |
| 247 | 247 | if ($gmt_offset > 0) { |
| 248 | - $timezone_string = 'UTC+' . $gmt_offset; |
|
| 248 | + $timezone_string = 'UTC+'.$gmt_offset; |
|
| 249 | 249 | } elseif ($gmt_offset < 0) { |
| 250 | - $timezone_string = 'UTC' . $gmt_offset; |
|
| 250 | + $timezone_string = 'UTC'.$gmt_offset; |
|
| 251 | 251 | } else { |
| 252 | 252 | $timezone_string = 'UTC'; |
| 253 | 253 | } |
@@ -269,11 +269,11 @@ discard block |
||
| 269 | 269 | __('%1$sUTC%2$s time is %3$s'), |
| 270 | 270 | '<abbr title="Coordinated Universal Time">', |
| 271 | 271 | '</abbr>', |
| 272 | - '<code>' . date_i18n($datetime_format, false, true) . '</code>' |
|
| 272 | + '<code>'.date_i18n($datetime_format, false, true).'</code>' |
|
| 273 | 273 | ); |
| 274 | 274 | ?></span> |
| 275 | - <?php if (! empty($timezone_string) || ! empty($gmt_offset)) : ?> |
|
| 276 | - <br/><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n($datetime_format) . '</code>'); ?></span> |
|
| 275 | + <?php if ( ! empty($timezone_string) || ! empty($gmt_offset)) : ?> |
|
| 276 | + <br/><span><?php printf(__('Local time is %1$s'), '<code>'.date_i18n($datetime_format).'</code>'); ?></span> |
|
| 277 | 277 | <?php endif; ?> |
| 278 | 278 | |
| 279 | 279 | <?php if ($check_zone_info && $timezone_string) : ?> |
@@ -306,11 +306,10 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | if ($found) { |
| 308 | 308 | $message = $tr['isdst'] ? |
| 309 | - __(' Daylight saving time begins on: %s.') : |
|
| 310 | - __(' Standard time begins on: %s.'); |
|
| 309 | + __(' Daylight saving time begins on: %s.') : __(' Standard time begins on: %s.'); |
|
| 311 | 310 | // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). |
| 312 | 311 | printf($message, |
| 313 | - '<code >' . date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])) . '</code >'); |
|
| 312 | + '<code >'.date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])).'</code >'); |
|
| 314 | 313 | } else { |
| 315 | 314 | _e('This timezone does not observe daylight saving time.'); |
| 316 | 315 | } |
@@ -338,13 +337,13 @@ discard block |
||
| 338 | 337 | */ |
| 339 | 338 | public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '') |
| 340 | 339 | { |
| 341 | - $unix_timestamp = $unix_timestamp === 0 ? time() : (int)$unix_timestamp; |
|
| 340 | + $unix_timestamp = $unix_timestamp === 0 ? time() : (int) $unix_timestamp; |
|
| 342 | 341 | $timezone_string = self::get_valid_timezone_string($timezone_string); |
| 343 | 342 | $TimeZone = new DateTimeZone($timezone_string); |
| 344 | 343 | |
| 345 | - $DateTime = new DateTime('@' . $unix_timestamp, $TimeZone); |
|
| 344 | + $DateTime = new DateTime('@'.$unix_timestamp, $TimeZone); |
|
| 346 | 345 | $offset = timezone_offset_get($TimeZone, $DateTime); |
| 347 | - return (int)$DateTime->format('U') + (int)$offset; |
|
| 346 | + return (int) $DateTime->format('U') + (int) $offset; |
|
| 348 | 347 | } |
| 349 | 348 | |
| 350 | 349 | |
@@ -427,7 +426,7 @@ discard block |
||
| 427 | 426 | */ |
| 428 | 427 | protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+') |
| 429 | 428 | { |
| 430 | - if (! $DateTime instanceof DateTime) { |
|
| 429 | + if ( ! $DateTime instanceof DateTime) { |
|
| 431 | 430 | throw new EE_Error( |
| 432 | 431 | sprintf( |
| 433 | 432 | __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'), |
@@ -437,25 +436,25 @@ discard block |
||
| 437 | 436 | } |
| 438 | 437 | switch ($period) { |
| 439 | 438 | case 'years' : |
| 440 | - $value = 'P' . $value . 'Y'; |
|
| 439 | + $value = 'P'.$value.'Y'; |
|
| 441 | 440 | break; |
| 442 | 441 | case 'months' : |
| 443 | - $value = 'P' . $value . 'M'; |
|
| 442 | + $value = 'P'.$value.'M'; |
|
| 444 | 443 | break; |
| 445 | 444 | case 'weeks' : |
| 446 | - $value = 'P' . $value . 'W'; |
|
| 445 | + $value = 'P'.$value.'W'; |
|
| 447 | 446 | break; |
| 448 | 447 | case 'days' : |
| 449 | - $value = 'P' . $value . 'D'; |
|
| 448 | + $value = 'P'.$value.'D'; |
|
| 450 | 449 | break; |
| 451 | 450 | case 'hours' : |
| 452 | - $value = 'PT' . $value . 'H'; |
|
| 451 | + $value = 'PT'.$value.'H'; |
|
| 453 | 452 | break; |
| 454 | 453 | case 'minutes' : |
| 455 | - $value = 'PT' . $value . 'M'; |
|
| 454 | + $value = 'PT'.$value.'M'; |
|
| 456 | 455 | break; |
| 457 | 456 | case 'seconds' : |
| 458 | - $value = 'PT' . $value . 'S'; |
|
| 457 | + $value = 'PT'.$value.'S'; |
|
| 459 | 458 | break; |
| 460 | 459 | } |
| 461 | 460 | switch ($operand) { |
@@ -483,7 +482,7 @@ discard block |
||
| 483 | 482 | */ |
| 484 | 483 | protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+') |
| 485 | 484 | { |
| 486 | - if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) { |
|
| 485 | + if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) { |
|
| 487 | 486 | throw new EE_Error( |
| 488 | 487 | sprintf( |
| 489 | 488 | __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'), |
@@ -587,7 +586,7 @@ discard block |
||
| 587 | 586 | 'date' => $date_format['js'], |
| 588 | 587 | 'time' => $time_format['js'], |
| 589 | 588 | ), |
| 590 | - 'moment' => $date_format['moment'] . ' ' . $time_format['moment'], |
|
| 589 | + 'moment' => $date_format['moment'].' '.$time_format['moment'], |
|
| 591 | 590 | ); |
| 592 | 591 | } |
| 593 | 592 | |
@@ -606,7 +605,7 @@ discard block |
||
| 606 | 605 | * |
| 607 | 606 | * @var array |
| 608 | 607 | */ |
| 609 | - $symbols_map = array( |
|
| 608 | + $symbols_map = array( |
|
| 610 | 609 | // Day |
| 611 | 610 | //01 |
| 612 | 611 | 'd' => array( |
@@ -764,7 +763,7 @@ discard block |
||
| 764 | 763 | $jquery_ui_format .= $format_string[$i]; |
| 765 | 764 | $moment_format .= $format_string[$i]; |
| 766 | 765 | } else { |
| 767 | - $jquery_ui_format .= '\'' . $format_string[$i]; |
|
| 766 | + $jquery_ui_format .= '\''.$format_string[$i]; |
|
| 768 | 767 | $moment_format .= $format_string[$i]; |
| 769 | 768 | } |
| 770 | 769 | $escaping = true; |
@@ -834,7 +833,7 @@ discard block |
||
| 834 | 833 | { |
| 835 | 834 | |
| 836 | 835 | if ( |
| 837 | - (! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) || |
|
| 836 | + ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) || |
|
| 838 | 837 | ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00') |
| 839 | 838 | ) { |
| 840 | 839 | return false; |
@@ -866,8 +865,8 @@ discard block |
||
| 866 | 865 | */ |
| 867 | 866 | $offset = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset'); |
| 868 | 867 | $query_interval = $offset < 0 |
| 869 | - ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)' |
|
| 870 | - : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)'; |
|
| 868 | + ? 'DATE_SUB('.$field_for_interval.', INTERVAL '.$offset * -1.' HOUR)' |
|
| 869 | + : 'DATE_ADD('.$field_for_interval.', INTERVAL '.$offset.' HOUR)'; |
|
| 871 | 870 | return $query_interval; |
| 872 | 871 | } |
| 873 | 872 | |
@@ -883,16 +882,16 @@ discard block |
||
| 883 | 882 | public static function get_timezone_string_for_display() |
| 884 | 883 | { |
| 885 | 884 | $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', ''); |
| 886 | - if (! empty($pretty_timezone)) { |
|
| 885 | + if ( ! empty($pretty_timezone)) { |
|
| 887 | 886 | return esc_html($pretty_timezone); |
| 888 | 887 | } |
| 889 | 888 | $timezone_string = get_option('timezone_string'); |
| 890 | 889 | if ($timezone_string) { |
| 891 | 890 | static $mo_loaded = false; |
| 892 | 891 | // Load translations for continents and cities just like wp_timezone_choice does |
| 893 | - if (! $mo_loaded) { |
|
| 892 | + if ( ! $mo_loaded) { |
|
| 894 | 893 | $locale = get_locale(); |
| 895 | - $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo'; |
|
| 894 | + $mofile = WP_LANG_DIR.'/continents-cities-'.$locale.'.mo'; |
|
| 896 | 895 | load_textdomain('continents-cities', $mofile); |
| 897 | 896 | $mo_loaded = true; |
| 898 | 897 | } |
@@ -913,16 +912,16 @@ discard block |
||
| 913 | 912 | } else { |
| 914 | 913 | $prefix = ''; |
| 915 | 914 | } |
| 916 | - $parts = explode('.', (string)$gmt_offset); |
|
| 915 | + $parts = explode('.', (string) $gmt_offset); |
|
| 917 | 916 | if (count($parts) === 1) { |
| 918 | 917 | $parts[1] = '00'; |
| 919 | 918 | } else { |
| 920 | 919 | //convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25) |
| 921 | 920 | //to minutes, eg 30 or 15, respectively |
| 922 | - $hour_fraction = (float)('0.' . $parts[1]); |
|
| 923 | - $parts[1] = (string)$hour_fraction * 60; |
|
| 921 | + $hour_fraction = (float) ('0.'.$parts[1]); |
|
| 922 | + $parts[1] = (string) $hour_fraction * 60; |
|
| 924 | 923 | } |
| 925 | - return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts)); |
|
| 924 | + return sprintf(__('UTC%1$s', 'event_espresso'), $prefix.implode(':', $parts)); |
|
| 926 | 925 | } |
| 927 | 926 | |
| 928 | 927 | |
@@ -948,7 +947,7 @@ discard block |
||
| 948 | 947 | */ |
| 949 | 948 | public static function first_of_month_timestamp($month = '') |
| 950 | 949 | { |
| 951 | - $month = (string)$month; |
|
| 950 | + $month = (string) $month; |
|
| 952 | 951 | $year = ''; |
| 953 | 952 | // check if the incoming string has a year in it or not |
| 954 | 953 | if (preg_match('/\b\d{4}\b/', $month, $matches)) { |
@@ -972,7 +971,7 @@ discard block |
||
| 972 | 971 | //before adding to the timestamp. Why? Because we want tomorrow to be for midnight the next day in THIS timezone |
| 973 | 972 | //not an offset from midnight in UTC. So if we're starting with UTC 00:00:00, then we want to make sure the |
| 974 | 973 | //final timestamp is equivalent to midnight in this timezone as represented in GMT. |
| 975 | - return strtotime('tomorrow') + (self::get_site_timezone_gmt_offset()*-1); |
|
| 974 | + return strtotime('tomorrow') + (self::get_site_timezone_gmt_offset() * -1); |
|
| 976 | 975 | } |
| 977 | 976 | |
| 978 | 977 | |
@@ -1006,9 +1005,9 @@ discard block |
||
| 1006 | 1005 | ); |
| 1007 | 1006 | |
| 1008 | 1007 | // Load translations for continents and cities. |
| 1009 | - if (! $mo_loaded || $locale !== $locale_loaded) { |
|
| 1008 | + if ( ! $mo_loaded || $locale !== $locale_loaded) { |
|
| 1010 | 1009 | $locale_loaded = $locale ? $locale : get_locale(); |
| 1011 | - $mofile = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo'; |
|
| 1010 | + $mofile = WP_LANG_DIR.'/continents-cities-'.$locale_loaded.'.mo'; |
|
| 1012 | 1011 | unload_textdomain('continents-cities'); |
| 1013 | 1012 | load_textdomain('continents-cities', $mofile); |
| 1014 | 1013 | $mo_loaded = true; |
@@ -1017,12 +1016,12 @@ discard block |
||
| 1017 | 1016 | $zonen = array(); |
| 1018 | 1017 | foreach (timezone_identifiers_list() as $zone) { |
| 1019 | 1018 | $zone = explode('/', $zone); |
| 1020 | - if (! in_array($zone[0], $continents)) { |
|
| 1019 | + if ( ! in_array($zone[0], $continents)) { |
|
| 1021 | 1020 | continue; |
| 1022 | 1021 | } |
| 1023 | 1022 | |
| 1024 | 1023 | // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later |
| 1025 | - $exists = array( |
|
| 1024 | + $exists = array( |
|
| 1026 | 1025 | 0 => (isset($zone[0]) && $zone[0]), |
| 1027 | 1026 | 1 => (isset($zone[1]) && $zone[1]), |
| 1028 | 1027 | 2 => (isset($zone[2]) && $zone[2]), |
@@ -1045,7 +1044,7 @@ discard block |
||
| 1045 | 1044 | $structure = array(); |
| 1046 | 1045 | |
| 1047 | 1046 | if (empty($selected_zone)) { |
| 1048 | - $structure[] = '<option selected="selected" value="">' . __('Select a city') . '</option>'; |
|
| 1047 | + $structure[] = '<option selected="selected" value="">'.__('Select a city').'</option>'; |
|
| 1049 | 1048 | } |
| 1050 | 1049 | |
| 1051 | 1050 | foreach ($zonen as $key => $zone) { |
@@ -1059,19 +1058,19 @@ discard block |
||
| 1059 | 1058 | // It's inside a continent group |
| 1060 | 1059 | |
| 1061 | 1060 | // Continent optgroup |
| 1062 | - if (! isset($zonen[$key - 1]) || $zonen[$key - 1]['continent'] !== $zone['continent']) { |
|
| 1061 | + if ( ! isset($zonen[$key - 1]) || $zonen[$key - 1]['continent'] !== $zone['continent']) { |
|
| 1063 | 1062 | $label = $zone['t_continent']; |
| 1064 | - $structure[] = '<optgroup label="' . esc_attr($label) . '">'; |
|
| 1063 | + $structure[] = '<optgroup label="'.esc_attr($label).'">'; |
|
| 1065 | 1064 | } |
| 1066 | 1065 | |
| 1067 | 1066 | // Add the city to the value |
| 1068 | 1067 | $value[] = $zone['city']; |
| 1069 | 1068 | |
| 1070 | 1069 | $display = $zone['t_city']; |
| 1071 | - if (! empty($zone['subcity'])) { |
|
| 1070 | + if ( ! empty($zone['subcity'])) { |
|
| 1072 | 1071 | // Add the subcity to the value |
| 1073 | 1072 | $value[] = $zone['subcity']; |
| 1074 | - $display .= ' - ' . $zone['t_subcity']; |
|
| 1073 | + $display .= ' - '.$zone['t_subcity']; |
|
| 1075 | 1074 | } |
| 1076 | 1075 | } |
| 1077 | 1076 | |
@@ -1081,10 +1080,10 @@ discard block |
||
| 1081 | 1080 | if ($value === $selected_zone) { |
| 1082 | 1081 | $selected = 'selected="selected" '; |
| 1083 | 1082 | } |
| 1084 | - $structure[] = '<option ' . $selected . 'value="' . esc_attr($value) . '">' . esc_html($display) . "</option>"; |
|
| 1083 | + $structure[] = '<option '.$selected.'value="'.esc_attr($value).'">'.esc_html($display)."</option>"; |
|
| 1085 | 1084 | |
| 1086 | 1085 | // Close continent optgroup |
| 1087 | - if (! empty($zone['city']) && (! isset($zonen[$key + 1]) || (isset($zonen[$key + 1]) && $zonen[$key + 1]['continent'] !== $zone['continent']))) { |
|
| 1086 | + if ( ! empty($zone['city']) && ( ! isset($zonen[$key + 1]) || (isset($zonen[$key + 1]) && $zonen[$key + 1]['continent'] !== $zone['continent']))) { |
|
| 1088 | 1087 | $structure[] = '</optgroup>'; |
| 1089 | 1088 | } |
| 1090 | 1089 | } |
@@ -1042,88 +1042,88 @@ |
||
| 1042 | 1042 | class EE_Event_List_Query extends WP_Query |
| 1043 | 1043 | { |
| 1044 | 1044 | |
| 1045 | - private $title; |
|
| 1046 | - |
|
| 1047 | - private $css_class; |
|
| 1048 | - |
|
| 1049 | - private $category_slug; |
|
| 1050 | - |
|
| 1051 | - /** |
|
| 1052 | - * EE_Event_List_Query constructor. |
|
| 1053 | - * |
|
| 1054 | - * @param array $args |
|
| 1055 | - */ |
|
| 1056 | - public function __construct($args = array()) |
|
| 1057 | - { |
|
| 1058 | - \EE_Error::doing_it_wrong( |
|
| 1059 | - __METHOD__, |
|
| 1060 | - __( |
|
| 1061 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.', |
|
| 1062 | - 'event_espresso' |
|
| 1063 | - ), |
|
| 1064 | - '4.9.27', |
|
| 1065 | - '5.0.0' |
|
| 1066 | - ); |
|
| 1067 | - $this->title = isset($args['title']) ? $args['title'] : ''; |
|
| 1068 | - $this->css_class = isset($args['css_class']) ? $args['css_class'] : ''; |
|
| 1069 | - $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : ''; |
|
| 1070 | - $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10; |
|
| 1071 | - // the current "page" we are viewing |
|
| 1072 | - $paged = max(1, get_query_var('paged')); |
|
| 1073 | - // Force these args |
|
| 1074 | - $args = array_merge( |
|
| 1075 | - $args, array( |
|
| 1076 | - 'post_type' => 'espresso_events', |
|
| 1077 | - 'posts_per_page' => $limit, |
|
| 1078 | - 'update_post_term_cache' => false, |
|
| 1079 | - 'update_post_meta_cache' => false, |
|
| 1080 | - 'paged' => $paged, |
|
| 1081 | - 'offset' => ($paged - 1) * $limit |
|
| 1082 | - ) |
|
| 1083 | - ); |
|
| 1084 | - // run the query |
|
| 1085 | - parent::__construct($args); |
|
| 1086 | - } |
|
| 1087 | - |
|
| 1088 | - |
|
| 1089 | - |
|
| 1090 | - /** |
|
| 1091 | - * event_list_title |
|
| 1092 | - * |
|
| 1093 | - * @param string $event_list_title |
|
| 1094 | - * @return string |
|
| 1095 | - */ |
|
| 1096 | - public function event_list_title($event_list_title = '') |
|
| 1097 | - { |
|
| 1098 | - if (! empty($this->title)) { |
|
| 1099 | - return $this->title; |
|
| 1100 | - } |
|
| 1101 | - return $event_list_title; |
|
| 1102 | - } |
|
| 1103 | - |
|
| 1104 | - |
|
| 1105 | - |
|
| 1106 | - /** |
|
| 1107 | - * event_list_css |
|
| 1108 | - * |
|
| 1109 | - * @param string $event_list_css |
|
| 1110 | - * @return string |
|
| 1111 | - */ |
|
| 1112 | - public function event_list_css($event_list_css = '') |
|
| 1113 | - { |
|
| 1114 | - $event_list_css .= ! empty($event_list_css) |
|
| 1115 | - ? ' ' |
|
| 1116 | - : ''; |
|
| 1117 | - $event_list_css .= ! empty($this->css_class) |
|
| 1118 | - ? $this->css_class |
|
| 1119 | - : ''; |
|
| 1120 | - $event_list_css .= ! empty($event_list_css) |
|
| 1121 | - ? ' ' |
|
| 1122 | - : ''; |
|
| 1123 | - $event_list_css .= ! empty($this->category_slug) |
|
| 1124 | - ? $this->category_slug |
|
| 1125 | - : ''; |
|
| 1126 | - return $event_list_css; |
|
| 1127 | - } |
|
| 1045 | + private $title; |
|
| 1046 | + |
|
| 1047 | + private $css_class; |
|
| 1048 | + |
|
| 1049 | + private $category_slug; |
|
| 1050 | + |
|
| 1051 | + /** |
|
| 1052 | + * EE_Event_List_Query constructor. |
|
| 1053 | + * |
|
| 1054 | + * @param array $args |
|
| 1055 | + */ |
|
| 1056 | + public function __construct($args = array()) |
|
| 1057 | + { |
|
| 1058 | + \EE_Error::doing_it_wrong( |
|
| 1059 | + __METHOD__, |
|
| 1060 | + __( |
|
| 1061 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.', |
|
| 1062 | + 'event_espresso' |
|
| 1063 | + ), |
|
| 1064 | + '4.9.27', |
|
| 1065 | + '5.0.0' |
|
| 1066 | + ); |
|
| 1067 | + $this->title = isset($args['title']) ? $args['title'] : ''; |
|
| 1068 | + $this->css_class = isset($args['css_class']) ? $args['css_class'] : ''; |
|
| 1069 | + $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : ''; |
|
| 1070 | + $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10; |
|
| 1071 | + // the current "page" we are viewing |
|
| 1072 | + $paged = max(1, get_query_var('paged')); |
|
| 1073 | + // Force these args |
|
| 1074 | + $args = array_merge( |
|
| 1075 | + $args, array( |
|
| 1076 | + 'post_type' => 'espresso_events', |
|
| 1077 | + 'posts_per_page' => $limit, |
|
| 1078 | + 'update_post_term_cache' => false, |
|
| 1079 | + 'update_post_meta_cache' => false, |
|
| 1080 | + 'paged' => $paged, |
|
| 1081 | + 'offset' => ($paged - 1) * $limit |
|
| 1082 | + ) |
|
| 1083 | + ); |
|
| 1084 | + // run the query |
|
| 1085 | + parent::__construct($args); |
|
| 1086 | + } |
|
| 1087 | + |
|
| 1088 | + |
|
| 1089 | + |
|
| 1090 | + /** |
|
| 1091 | + * event_list_title |
|
| 1092 | + * |
|
| 1093 | + * @param string $event_list_title |
|
| 1094 | + * @return string |
|
| 1095 | + */ |
|
| 1096 | + public function event_list_title($event_list_title = '') |
|
| 1097 | + { |
|
| 1098 | + if (! empty($this->title)) { |
|
| 1099 | + return $this->title; |
|
| 1100 | + } |
|
| 1101 | + return $event_list_title; |
|
| 1102 | + } |
|
| 1103 | + |
|
| 1104 | + |
|
| 1105 | + |
|
| 1106 | + /** |
|
| 1107 | + * event_list_css |
|
| 1108 | + * |
|
| 1109 | + * @param string $event_list_css |
|
| 1110 | + * @return string |
|
| 1111 | + */ |
|
| 1112 | + public function event_list_css($event_list_css = '') |
|
| 1113 | + { |
|
| 1114 | + $event_list_css .= ! empty($event_list_css) |
|
| 1115 | + ? ' ' |
|
| 1116 | + : ''; |
|
| 1117 | + $event_list_css .= ! empty($this->css_class) |
|
| 1118 | + ? $this->css_class |
|
| 1119 | + : ''; |
|
| 1120 | + $event_list_css .= ! empty($event_list_css) |
|
| 1121 | + ? ' ' |
|
| 1122 | + : ''; |
|
| 1123 | + $event_list_css .= ! empty($this->category_slug) |
|
| 1124 | + ? $this->category_slug |
|
| 1125 | + : ''; |
|
| 1126 | + return $event_list_css; |
|
| 1127 | + } |
|
| 1128 | 1128 | |
| 1129 | 1129 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | /** |
| 6 | 6 | * ************************************************************************ |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | $action_or_filter = 'action' |
| 44 | 44 | ) { |
| 45 | 45 | $action_or_filter = $action_or_filter === 'action' |
| 46 | - ? esc_html__( 'action', 'event_espresso' ) |
|
| 47 | - : esc_html__( 'filter', 'event_espresso' ); |
|
| 46 | + ? esc_html__('action', 'event_espresso') |
|
| 47 | + : esc_html__('filter', 'event_espresso'); |
|
| 48 | 48 | EE_Error::doing_it_wrong( |
| 49 | 49 | $deprecated_filter, |
| 50 | 50 | sprintf( |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param \EE_Checkout $checkout |
| 69 | 69 | * @return string |
| 70 | 70 | */ |
| 71 | -function ee_deprecated__registration_checkout__button_text( $submit_button_text, EE_Checkout $checkout ) { |
|
| 71 | +function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout) { |
|
| 72 | 72 | // list of old filters |
| 73 | 73 | $deprecated_filters = array( |
| 74 | 74 | 'update_registration_details' => true, |
@@ -78,16 +78,16 @@ discard block |
||
| 78 | 78 | 'proceed_to' => true, |
| 79 | 79 | ); |
| 80 | 80 | // loop thru and call doing_it_wrong() or remove any that aren't being used |
| 81 | - foreach ( $deprecated_filters as $deprecated_filter => $on ) { |
|
| 81 | + foreach ($deprecated_filters as $deprecated_filter => $on) { |
|
| 82 | 82 | // was this filter called ? |
| 83 | - if ( has_action( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter )) { |
|
| 83 | + if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) { |
|
| 84 | 84 | // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
| 85 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter' ) && ! defined( 'DOING_AJAX' ) ) { |
|
| 85 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter') && ! defined('DOING_AJAX')) { |
|
| 86 | 86 | EE_Error::doing_it_wrong( |
| 87 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
| 87 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
| 88 | 88 | sprintf( |
| 89 | - __( 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso' ), |
|
| 90 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
| 89 | + __('The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso'), |
|
| 90 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
| 91 | 91 | '<br />', |
| 92 | 92 | 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
| 93 | 93 | '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
@@ -96,24 +96,24 @@ discard block |
||
| 96 | 96 | ); |
| 97 | 97 | } |
| 98 | 98 | } else { |
| 99 | - unset( $deprecated_filters[ $deprecated_filter ] ); |
|
| 99 | + unset($deprecated_filters[$deprecated_filter]); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | - if ( ! empty( $deprecated_filters )) { |
|
| 103 | - |
|
| 104 | - if ( $checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset( $deprecated_filters[ 'update_registration_details' ] )) { |
|
| 105 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text ); |
|
| 106 | - } else if ( $checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset( $deprecated_filters[ 'process_payment' ] ) ) { |
|
| 107 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text ); |
|
| 108 | - } else if ( $checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset( $deprecated_filters[ 'finalize_registration' ] ) ) { |
|
| 109 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text ); |
|
| 102 | + if ( ! empty($deprecated_filters)) { |
|
| 103 | + |
|
| 104 | + if ($checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
|
| 105 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text); |
|
| 106 | + } else if ($checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) { |
|
| 107 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text); |
|
| 108 | + } else if ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) { |
|
| 109 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text); |
|
| 110 | 110 | } |
| 111 | - if ( $checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
| 112 | - if ( $checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset( $deprecated_filters[ 'and_proceed_to_payment' ] ) ) { |
|
| 113 | - $submit_button_text .= apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text ); |
|
| 111 | + if ($checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 112 | + if ($checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) { |
|
| 113 | + $submit_button_text .= apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text); |
|
| 114 | 114 | } |
| 115 | - if ( $checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset( $deprecated_filters[ 'proceed_to' ] ) ) { |
|
| 116 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text ) . $checkout->next_step->name(); |
|
| 115 | + if ($checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) { |
|
| 116 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text).$checkout->next_step->name(); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | return $submit_button_text; |
| 122 | 122 | |
| 123 | 123 | } |
| 124 | -add_filter( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2 ); |
|
| 124 | +add_filter('FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2); |
|
| 125 | 125 | |
| 126 | 126 | |
| 127 | 127 | |
@@ -132,16 +132,16 @@ discard block |
||
| 132 | 132 | * @param \EE_Checkout $checkout |
| 133 | 133 | * @param boolean $status_updates |
| 134 | 134 | */ |
| 135 | -function ee_deprecated_finalize_transaction( EE_Checkout $checkout, $status_updates ) { |
|
| 135 | +function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates) { |
|
| 136 | 136 | $action_ref = NULL; |
| 137 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__new_transaction' ) ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
| 138 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__all_transaction' ) ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
| 139 | - if ( $action_ref ) { |
|
| 137 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
| 138 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
| 139 | + if ($action_ref) { |
|
| 140 | 140 | |
| 141 | 141 | EE_Error::doing_it_wrong( |
| 142 | 142 | $action_ref, |
| 143 | 143 | sprintf( |
| 144 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso' ), |
|
| 144 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso'), |
|
| 145 | 145 | '<br />', |
| 146 | 146 | '/core/business/EE_Transaction_Processor.class.php', |
| 147 | 147 | 'AHEE__EE_Transaction_Processor__finalize', |
@@ -151,39 +151,39 @@ discard block |
||
| 151 | 151 | ), |
| 152 | 152 | '4.6.0' |
| 153 | 153 | ); |
| 154 | - switch ( $action_ref ) { |
|
| 154 | + switch ($action_ref) { |
|
| 155 | 155 | case 'AHEE__EE_Transaction__finalize__new_transaction' : |
| 156 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request ); |
|
| 156 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request); |
|
| 157 | 157 | break; |
| 158 | 158 | case 'AHEE__EE_Transaction__finalize__all_transaction' : |
| 159 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array( 'new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates ), $checkout->admin_request ); |
|
| 159 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), $checkout->admin_request); |
|
| 160 | 160 | break; |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | -add_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2 ); |
|
| 164 | +add_action('AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2); |
|
| 165 | 165 | /** |
| 166 | 166 | * ee_deprecated_finalize_registration |
| 167 | 167 | * |
| 168 | 168 | * @param EE_Registration $registration |
| 169 | 169 | */ |
| 170 | -function ee_deprecated_finalize_registration( EE_Registration $registration ) { |
|
| 171 | - $action_ref = has_action( 'AHEE__EE_Registration__finalize__update_and_new_reg' ) ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
| 172 | - if ( $action_ref ) { |
|
| 170 | +function ee_deprecated_finalize_registration(EE_Registration $registration) { |
|
| 171 | + $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
| 172 | + if ($action_ref) { |
|
| 173 | 173 | EE_Error::doing_it_wrong( |
| 174 | 174 | $action_ref, |
| 175 | 175 | sprintf( |
| 176 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso' ), |
|
| 176 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso'), |
|
| 177 | 177 | '<br />', |
| 178 | 178 | '/core/business/EE_Registration_Processor.class.php', |
| 179 | 179 | 'AHEE__EE_Registration_Processor__trigger_registration_status_changed_hook' |
| 180 | 180 | ), |
| 181 | 181 | '4.6.0' |
| 182 | 182 | ); |
| 183 | - do_action( 'AHEE__EE_Registration__finalize__update_and_new_reg', $registration, ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ))); |
|
| 183 | + do_action('AHEE__EE_Registration__finalize__update_and_new_reg', $registration, (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | -add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1 ); |
|
| 186 | +add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1); |
|
| 187 | 187 | |
| 188 | 188 | |
| 189 | 189 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * Called after EED_Module::set_hooks() and EED_Module::set_admin_hooks() was called. |
| 192 | 192 | * Checks if any deprecated hooks were hooked-into and provide doing_it_wrong messages appropriately. |
| 193 | 193 | */ |
| 194 | -function ee_deprecated_hooks(){ |
|
| 194 | +function ee_deprecated_hooks() { |
|
| 195 | 195 | /** |
| 196 | 196 | * @var $hooks array where keys are hook names, and their values are array{ |
| 197 | 197 | * @type string $version when deprecated |
@@ -202,25 +202,25 @@ discard block |
||
| 202 | 202 | $hooks = array( |
| 203 | 203 | 'AHEE__EE_System___do_setup_validations' => array( |
| 204 | 204 | 'version' => '4.6.0', |
| 205 | - 'alternative' => __( 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso' ), |
|
| 205 | + 'alternative' => __('Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso'), |
|
| 206 | 206 | 'still_works' => FALSE |
| 207 | 207 | ) |
| 208 | 208 | ); |
| 209 | - foreach( $hooks as $name => $deprecation_info ){ |
|
| 210 | - if( has_action( $name ) ){ |
|
| 209 | + foreach ($hooks as $name => $deprecation_info) { |
|
| 210 | + if (has_action($name)) { |
|
| 211 | 211 | EE_Error::doing_it_wrong( |
| 212 | 212 | $name, |
| 213 | 213 | sprintf( |
| 214 | - __('This filter is deprecated. %1$s%2$s','event_espresso'), |
|
| 215 | - $deprecation_info[ 'still_works' ] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __( 'It has been completely removed.', 'event_espresso' ), |
|
| 216 | - isset( $deprecation_info[ 'alternative' ] ) ? $deprecation_info[ 'alternative' ] : __( 'Please read the current EE4 documentation further or contact Support.', 'event_espresso' ) |
|
| 214 | + __('This filter is deprecated. %1$s%2$s', 'event_espresso'), |
|
| 215 | + $deprecation_info['still_works'] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __('It has been completely removed.', 'event_espresso'), |
|
| 216 | + isset($deprecation_info['alternative']) ? $deprecation_info['alternative'] : __('Please read the current EE4 documentation further or contact Support.', 'event_espresso') |
|
| 217 | 217 | ), |
| 218 | - isset( $deprecation_info[ 'version' ] ) ? $deprecation_info[ 'version' ] : __( 'recently', 'event_espresso' ) |
|
| 218 | + isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso') |
|
| 219 | 219 | ); |
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | -add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks' ); |
|
| 223 | +add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks'); |
|
| 224 | 224 | |
| 225 | 225 | |
| 226 | 226 | |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | * @return boolean |
| 232 | 232 | */ |
| 233 | 233 | function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() { |
| 234 | - $in_use = has_filter( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns' ) |
|
| 235 | - || has_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' ); |
|
| 236 | - if( $in_use ) { |
|
| 234 | + $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns') |
|
| 235 | + || has_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'); |
|
| 236 | + if ($in_use) { |
|
| 237 | 237 | $msg = __( |
| 238 | 238 | 'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.' |
| 239 | 239 | . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,' |
@@ -242,18 +242,18 @@ discard block |
||
| 242 | 242 | 'event_espresso' ) |
| 243 | 243 | ; |
| 244 | 244 | EE_Error::doing_it_wrong( |
| 245 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 245 | + __CLASS__.'::'.__FUNCTION__, |
|
| 246 | 246 | $msg, |
| 247 | 247 | '4.8.32.rc.000' |
| 248 | 248 | ); |
| 249 | 249 | //it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed |
| 250 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
| 251 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 250 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
| 251 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | return $in_use; |
| 255 | 255 | } |
| 256 | -add_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' ); |
|
| 256 | +add_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'); |
|
| 257 | 257 | |
| 258 | 258 | /** |
| 259 | 259 | * @deprecated since 4.8.32.rc.000 because it has issues on https://events.codebasehq.com/projects/event-espresso/tickets/9165 |
@@ -262,34 +262,34 @@ discard block |
||
| 262 | 262 | * @param EE_Admin_Page $admin_page |
| 263 | 263 | * @return void |
| 264 | 264 | */ |
| 265 | -function ee_deprecated_update_attendee_registration_form_old( $admin_page ) { |
|
| 265 | +function ee_deprecated_update_attendee_registration_form_old($admin_page) { |
|
| 266 | 266 | //check if the old hooks are in use. If not, do the default |
| 267 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 268 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
| 267 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 268 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
| 269 | 269 | return; |
| 270 | 270 | } |
| 271 | 271 | $req_data = $admin_page->get_request_data(); |
| 272 | - $qstns = isset( $req_data['qstn'] ) ? $req_data['qstn'] : FALSE; |
|
| 273 | - $REG_ID = isset( $req_data['_REG_ID'] ) ? absint( $req_data['_REG_ID'] ) : FALSE; |
|
| 274 | - $qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns ); |
|
| 275 | - if ( ! $REG_ID || ! $qstns ) { |
|
| 276 | - EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 272 | + $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : FALSE; |
|
| 273 | + $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : FALSE; |
|
| 274 | + $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
|
| 275 | + if ( ! $REG_ID || ! $qstns) { |
|
| 276 | + EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 277 | 277 | } |
| 278 | 278 | $success = TRUE; |
| 279 | 279 | |
| 280 | 280 | // allow others to get in on this awesome fun :D |
| 281 | - do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns ); |
|
| 281 | + do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns); |
|
| 282 | 282 | // loop thru questions... FINALLY!!! |
| 283 | 283 | |
| 284 | - foreach ( $qstns as $QST_ID => $qstn ) { |
|
| 284 | + foreach ($qstns as $QST_ID => $qstn) { |
|
| 285 | 285 | //if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
| 286 | - if ( !is_array($qstn) ) { |
|
| 287 | - $success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn); |
|
| 286 | + if ( ! is_array($qstn)) { |
|
| 287 | + $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
|
| 288 | 288 | continue; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
| 292 | - foreach ( $qstn as $ANS_ID => $ANS_value ) { |
|
| 292 | + foreach ($qstn as $ANS_ID => $ANS_value) { |
|
| 293 | 293 | //get answer |
| 294 | 294 | $query_params = array( |
| 295 | 295 | 0 => array( |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | ); |
| 301 | 301 | $answer = EEM_Answer::instance()->get_one($query_params); |
| 302 | 302 | //this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
| 303 | - if ( ! $answer instanceof EE_Answer ) { |
|
| 303 | + if ( ! $answer instanceof EE_Answer) { |
|
| 304 | 304 | $set_values = array( |
| 305 | 305 | 'QST_ID' => $QST_ID, |
| 306 | 306 | 'REG_ID' => $REG_ID, |
@@ -315,11 +315,11 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | $what = __('Registration Form', 'event_espresso'); |
| 318 | - $route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' ); |
|
| 319 | - $admin_page->redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route ); |
|
| 318 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
| 319 | + $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
| 320 | 320 | exit; |
| 321 | 321 | } |
| 322 | -add_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1 ); |
|
| 322 | +add_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1); |
|
| 323 | 323 | /** |
| 324 | 324 | * Render the registration admin page's custom questions area in the old fashion |
| 325 | 325 | * and firing the old hooks. When this method is removed, we can probably also |
@@ -332,31 +332,31 @@ discard block |
||
| 332 | 332 | * @return bool |
| 333 | 333 | * @throws \EE_Error |
| 334 | 334 | */ |
| 335 | -function ee_deprecated_reg_questions_meta_box_old( $do_default_action, $admin_page, $registration ) { |
|
| 335 | +function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) { |
|
| 336 | 336 | //check if the old hooks are in use. If not, do the default |
| 337 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 338 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
| 337 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 338 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
| 339 | 339 | return $do_default_action; |
| 340 | 340 | } |
| 341 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $admin_page, 'form_before_question_group' ), 10, 1 ); |
|
| 342 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $admin_page, 'form_after_question_group' ), 10, 1 ); |
|
| 343 | - add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $admin_page, 'form_form_field_label_wrap' ), 10, 1 ); |
|
| 344 | - add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $admin_page, 'form_form_field_input__wrap' ), 10, 1 ); |
|
| 341 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array($admin_page, 'form_before_question_group'), 10, 1); |
|
| 342 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array($admin_page, 'form_after_question_group'), 10, 1); |
|
| 343 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1); |
|
| 344 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1); |
|
| 345 | 345 | |
| 346 | - $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $registration, $registration->get('EVT_ID') ); |
|
| 346 | + $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options($registration, $registration->get('EVT_ID')); |
|
| 347 | 347 | |
| 348 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
| 348 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
| 349 | 349 | $template_args = array( |
| 350 | - 'att_questions' => EEH_Form_Fields::generate_question_groups_html( $question_groups ), |
|
| 350 | + 'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups), |
|
| 351 | 351 | 'reg_questions_form_action' => 'edit_registration', |
| 352 | 352 | 'REG_ID' => $registration->ID() |
| 353 | 353 | ); |
| 354 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 355 | - echo EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
| 354 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 355 | + echo EEH_Template::display_template($template_path, $template_args, TRUE); |
|
| 356 | 356 | //indicate that we should not do the default admin page code |
| 357 | 357 | return false; |
| 358 | 358 | } |
| 359 | -add_action( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3 ); |
|
| 359 | +add_action('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3); |
|
| 360 | 360 | |
| 361 | 361 | |
| 362 | 362 | |
@@ -397,9 +397,9 @@ discard block |
||
| 397 | 397 | '4.9.0' |
| 398 | 398 | ); |
| 399 | 399 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
| 400 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 401 | - $messenger = $message_resource_manager->get_messenger( $messenger_name ); |
|
| 402 | - $message_type = $message_resource_manager->get_message_type( $message_type_name ); |
|
| 400 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 401 | + $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
| 402 | + $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
| 403 | 403 | return EE_Registry::instance()->load_lib( |
| 404 | 404 | 'Messages_Template_Defaults', |
| 405 | 405 | array( |
@@ -464,15 +464,15 @@ discard block |
||
| 464 | 464 | /** |
| 465 | 465 | * @param string $method |
| 466 | 466 | */ |
| 467 | - public function _class_is_deprecated( $method ) { |
|
| 467 | + public function _class_is_deprecated($method) { |
|
| 468 | 468 | EE_Error::doing_it_wrong( |
| 469 | - 'EE_messages::' . $method, |
|
| 470 | - __( 'EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.' ), |
|
| 469 | + 'EE_messages::'.$method, |
|
| 470 | + __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
| 471 | 471 | '4.9.0', |
| 472 | 472 | '4.10.0.p' |
| 473 | 473 | ); |
| 474 | 474 | // Please use EE_Message_Resource_Manager instead |
| 475 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 475 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | |
@@ -482,10 +482,10 @@ discard block |
||
| 482 | 482 | * @param string $messenger_name |
| 483 | 483 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
| 484 | 484 | */ |
| 485 | - public function ensure_messenger_is_active( $messenger_name ) { |
|
| 485 | + public function ensure_messenger_is_active($messenger_name) { |
|
| 486 | 486 | // EE_messages has been deprecated |
| 487 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 488 | - return $this->_message_resource_manager->ensure_messenger_is_active( $messenger_name ); |
|
| 487 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 488 | + return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | |
@@ -497,10 +497,10 @@ discard block |
||
| 497 | 497 | * @return bool true if it got activated (or was active) and false if not. |
| 498 | 498 | * @throws \EE_Error |
| 499 | 499 | */ |
| 500 | - public function ensure_message_type_is_active( $message_type, $messenger ) { |
|
| 500 | + public function ensure_message_type_is_active($message_type, $messenger) { |
|
| 501 | 501 | // EE_messages has been deprecated |
| 502 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 503 | - return $this->_message_resource_manager->ensure_message_type_is_active( $message_type, $messenger ); |
|
| 502 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 503 | + return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | |
@@ -513,10 +513,10 @@ discard block |
||
| 513 | 513 | * they are already setup.) |
| 514 | 514 | * @return boolean an array of generated templates or false if nothing generated/activated. |
| 515 | 515 | */ |
| 516 | - public function activate_messenger( $messenger_name, $mts_to_activate = array() ) { |
|
| 516 | + public function activate_messenger($messenger_name, $mts_to_activate = array()) { |
|
| 517 | 517 | // EE_messages has been deprecated |
| 518 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 519 | - return $this->_message_resource_manager->activate_messenger( $messenger_name, $mts_to_activate ); |
|
| 518 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 519 | + return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | |
@@ -528,10 +528,10 @@ discard block |
||
| 528 | 528 | * |
| 529 | 529 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
| 530 | 530 | */ |
| 531 | - public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) { |
|
| 531 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) { |
|
| 532 | 532 | // EE_messages has been deprecated |
| 533 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 534 | - return $this->_message_resource_manager->is_generating_messenger_and_active( $messenger, $message_type ); |
|
| 533 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 534 | + return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | |
@@ -541,10 +541,10 @@ discard block |
||
| 541 | 541 | * @param string $messenger |
| 542 | 542 | * @return EE_messenger | null |
| 543 | 543 | */ |
| 544 | - public function get_messenger_if_active( $messenger ) { |
|
| 544 | + public function get_messenger_if_active($messenger) { |
|
| 545 | 545 | // EE_messages has been deprecated |
| 546 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 547 | - return $this->_message_resource_manager->get_active_messenger( $messenger ); |
|
| 546 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 547 | + return $this->_message_resource_manager->get_active_messenger($messenger); |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | |
@@ -565,9 +565,9 @@ discard block |
||
| 565 | 565 | * 'message_type' => null |
| 566 | 566 | * ) |
| 567 | 567 | */ |
| 568 | - public function validate_for_use( EE_Message $message ) { |
|
| 568 | + public function validate_for_use(EE_Message $message) { |
|
| 569 | 569 | // EE_messages has been deprecated |
| 570 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 570 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 571 | 571 | return array( |
| 572 | 572 | 'messenger' => $message->messenger_object(), |
| 573 | 573 | 'message_type' => $message->message_type_object(), |
@@ -595,41 +595,41 @@ discard block |
||
| 595 | 595 | $send = true |
| 596 | 596 | ) { |
| 597 | 597 | // EE_messages has been deprecated |
| 598 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 598 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 599 | 599 | /** @type EE_Messages_Processor $processor */ |
| 600 | - $processor = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
| 600 | + $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
| 601 | 601 | $error = false; |
| 602 | 602 | //try to intelligently determine what method we'll call based on the incoming data. |
| 603 | 603 | //if generating and sending are different then generate and send immediately. |
| 604 | - if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) { |
|
| 604 | + if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
| 605 | 605 | //in the legacy system, when generating and sending were different, that means all the |
| 606 | 606 | //vars are already in the request object. So let's just use that. |
| 607 | 607 | try { |
| 608 | 608 | /** @type EE_Message_To_Generate_From_Request $mtg */ |
| 609 | - $mtg = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' ); |
|
| 610 | - $processor->generate_and_send_now( $mtg ); |
|
| 611 | - } catch ( EE_Error $e ) { |
|
| 609 | + $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
| 610 | + $processor->generate_and_send_now($mtg); |
|
| 611 | + } catch (EE_Error $e) { |
|
| 612 | 612 | $error_msg = __( |
| 613 | 613 | 'Please note that a system message failed to send due to a technical issue.', |
| 614 | 614 | 'event_espresso' |
| 615 | 615 | ); |
| 616 | 616 | // add specific message for developers if WP_DEBUG in on |
| 617 | - $error_msg .= '||' . $e->getMessage(); |
|
| 618 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 617 | + $error_msg .= '||'.$e->getMessage(); |
|
| 618 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 619 | 619 | $error = true; |
| 620 | 620 | } |
| 621 | 621 | } else { |
| 622 | - $processor->generate_for_all_active_messengers( $type, $vars, $send ); |
|
| 622 | + $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
| 623 | 623 | //let's find out if there were any errors and how many successfully were queued. |
| 624 | 624 | $count_errors = $processor->get_queue()->count_STS_in_queue( |
| 625 | - array( EEM_Message::status_failed, EEM_Message::status_debug_only ) |
|
| 625 | + array(EEM_Message::status_failed, EEM_Message::status_debug_only) |
|
| 626 | 626 | ); |
| 627 | - $count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
| 628 | - $count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry ); |
|
| 627 | + $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
| 628 | + $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
| 629 | 629 | $count_errors = $count_errors + $count_retry; |
| 630 | - if ( $count_errors > 0 ) { |
|
| 630 | + if ($count_errors > 0) { |
|
| 631 | 631 | $error = true; |
| 632 | - if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1 ) { |
|
| 632 | + if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
| 633 | 633 | $message = sprintf( |
| 634 | 634 | __( |
| 635 | 635 | 'There were %d errors and %d messages successfully queued for generation and sending', |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | $count_errors, |
| 639 | 639 | $count_queued |
| 640 | 640 | ); |
| 641 | - } elseif ( $count_errors > 1 && $count_queued === 1 ) { |
|
| 641 | + } elseif ($count_errors > 1 && $count_queued === 1) { |
|
| 642 | 642 | $message = sprintf( |
| 643 | 643 | __( |
| 644 | 644 | 'There were %d errors and %d message successfully queued for generation.', |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | $count_errors, |
| 648 | 648 | $count_queued |
| 649 | 649 | ); |
| 650 | - } elseif ( $count_errors === 1 && $count_queued > 1 ) { |
|
| 650 | + } elseif ($count_errors === 1 && $count_queued > 1) { |
|
| 651 | 651 | $message = sprintf( |
| 652 | 652 | __( |
| 653 | 653 | 'There was %d error and %d messages successfully queued for generation.', |
@@ -665,9 +665,9 @@ discard block |
||
| 665 | 665 | $count_errors |
| 666 | 666 | ); |
| 667 | 667 | } |
| 668 | - EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 668 | + EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
| 669 | 669 | } else { |
| 670 | - if ( $count_queued === 1 ) { |
|
| 670 | + if ($count_queued === 1) { |
|
| 671 | 671 | $message = sprintf( |
| 672 | 672 | __( |
| 673 | 673 | '%d message successfully queued for generation.', |
@@ -684,18 +684,18 @@ discard block |
||
| 684 | 684 | $count_queued |
| 685 | 685 | ); |
| 686 | 686 | } |
| 687 | - EE_Error::add_success( $message ); |
|
| 687 | + EE_Error::add_success($message); |
|
| 688 | 688 | } |
| 689 | 689 | } |
| 690 | 690 | //if no error then return the generated message(s). |
| 691 | - if ( ! $error && ! $send ) { |
|
| 692 | - $generated_queue = $processor->generate_queue( false ); |
|
| 691 | + if ( ! $error && ! $send) { |
|
| 692 | + $generated_queue = $processor->generate_queue(false); |
|
| 693 | 693 | //get message and return. |
| 694 | 694 | $generated_queue->get_message_repository()->rewind(); |
| 695 | 695 | $messages = array(); |
| 696 | - while ( $generated_queue->get_message_repository()->valid() ) { |
|
| 696 | + while ($generated_queue->get_message_repository()->valid()) { |
|
| 697 | 697 | $message = $generated_queue->get_message_repository()->current(); |
| 698 | - if ( $message instanceof EE_Message ) { |
|
| 698 | + if ($message instanceof EE_Message) { |
|
| 699 | 699 | //set properties that might be expected by add-ons (backward compat) |
| 700 | 700 | $message->content = $message->content(); |
| 701 | 701 | $message->template_pack = $message->get_template_pack(); |
@@ -720,10 +720,10 @@ discard block |
||
| 720 | 720 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
| 721 | 721 | * @return string The body of the message. |
| 722 | 722 | */ |
| 723 | - public function preview_message( $type, $context, $messenger, $send = false ) { |
|
| 723 | + public function preview_message($type, $context, $messenger, $send = false) { |
|
| 724 | 724 | // EE_messages has been deprecated |
| 725 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 726 | - return EED_Messages::preview_message( $type, $context, $messenger, $send ); |
|
| 725 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 726 | + return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | |
@@ -737,14 +737,14 @@ discard block |
||
| 737 | 737 | * |
| 738 | 738 | * @return bool success or fail. |
| 739 | 739 | */ |
| 740 | - public function send_message_with_messenger_only( $messenger, $message_type, $message ) { |
|
| 740 | + public function send_message_with_messenger_only($messenger, $message_type, $message) { |
|
| 741 | 741 | // EE_messages has been deprecated |
| 742 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 742 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 743 | 743 | //setup for sending to new method. |
| 744 | 744 | /** @type EE_Messages_Queue $queue */ |
| 745 | - $queue = EE_Registry::instance()->load_lib( 'Messages_Queue' ); |
|
| 745 | + $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
| 746 | 746 | //make sure we have a proper message object |
| 747 | - if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) { |
|
| 747 | + if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
| 748 | 748 | $msg = EE_Message_Factory::create( |
| 749 | 749 | array( |
| 750 | 750 | 'MSG_messenger' => $messenger, |
@@ -756,15 +756,15 @@ discard block |
||
| 756 | 756 | } else { |
| 757 | 757 | $msg = $message; |
| 758 | 758 | } |
| 759 | - if ( ! $msg instanceof EE_Message ) { |
|
| 759 | + if ( ! $msg instanceof EE_Message) { |
|
| 760 | 760 | return false; |
| 761 | 761 | } |
| 762 | 762 | //make sure any content in a content property (if not empty) is set on the MSG_content. |
| 763 | - if ( ! empty( $msg->content ) ) { |
|
| 764 | - $msg->set( 'MSG_content', $msg->content ); |
|
| 763 | + if ( ! empty($msg->content)) { |
|
| 764 | + $msg->set('MSG_content', $msg->content); |
|
| 765 | 765 | } |
| 766 | - $queue->add( $msg ); |
|
| 767 | - return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue ); |
|
| 766 | + $queue->add($msg); |
|
| 767 | + return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | |
@@ -778,11 +778,11 @@ discard block |
||
| 778 | 778 | * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned. |
| 779 | 779 | * @throws \EE_Error |
| 780 | 780 | */ |
| 781 | - public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) { |
|
| 781 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) { |
|
| 782 | 782 | // EE_messages has been deprecated |
| 783 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 784 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 785 | - return EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $is_global ); |
|
| 783 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 784 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 785 | + return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | |
@@ -793,11 +793,11 @@ discard block |
||
| 793 | 793 | * @param string $message_type_name name of EE_message_type |
| 794 | 794 | * @return array |
| 795 | 795 | */ |
| 796 | - public function get_fields( $messenger_name, $message_type_name ) { |
|
| 796 | + public function get_fields($messenger_name, $message_type_name) { |
|
| 797 | 797 | // EE_messages has been deprecated |
| 798 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 799 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 800 | - return EEH_MSG_Template::get_fields( $messenger_name, $message_type_name ); |
|
| 798 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 799 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 800 | + return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | |
@@ -811,13 +811,13 @@ discard block |
||
| 811 | 811 | * @return array multidimensional array of messenger and message_type objects |
| 812 | 812 | * (messengers index, and message_type index); |
| 813 | 813 | */ |
| 814 | - public function get_installed( $type = 'all', $skip_cache = false ) { |
|
| 814 | + public function get_installed($type = 'all', $skip_cache = false) { |
|
| 815 | 815 | // EE_messages has been deprecated |
| 816 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 817 | - if ( $skip_cache ) { |
|
| 816 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 817 | + if ($skip_cache) { |
|
| 818 | 818 | $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
| 819 | 819 | } |
| 820 | - switch ( $type ) { |
|
| 820 | + switch ($type) { |
|
| 821 | 821 | case 'messengers' : |
| 822 | 822 | return array( |
| 823 | 823 | 'messenger' => $this->_message_resource_manager->installed_messengers(), |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | */ |
| 847 | 847 | public function get_active_messengers() { |
| 848 | 848 | // EE_messages has been deprecated |
| 849 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 849 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 850 | 850 | return $this->_message_resource_manager->active_messengers(); |
| 851 | 851 | } |
| 852 | 852 | |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | */ |
| 859 | 859 | public function get_active_message_types() { |
| 860 | 860 | // EE_messages has been deprecated |
| 861 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 861 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 862 | 862 | return $this->_message_resource_manager->list_of_active_message_types(); |
| 863 | 863 | } |
| 864 | 864 | |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | */ |
| 871 | 871 | public function get_active_message_type_objects() { |
| 872 | 872 | // EE_messages has been deprecated |
| 873 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 873 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 874 | 874 | return $this->_message_resource_manager->get_active_message_type_objects(); |
| 875 | 875 | } |
| 876 | 876 | |
@@ -882,10 +882,10 @@ discard block |
||
| 882 | 882 | * @param string $messenger The messenger being checked |
| 883 | 883 | * @return EE_message_type[] (or empty array if none present) |
| 884 | 884 | */ |
| 885 | - public function get_active_message_types_per_messenger( $messenger ) { |
|
| 885 | + public function get_active_message_types_per_messenger($messenger) { |
|
| 886 | 886 | // EE_messages has been deprecated |
| 887 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 888 | - return $this->_message_resource_manager->get_active_message_types_for_messenger( $messenger ); |
|
| 887 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 888 | + return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | |
@@ -896,10 +896,10 @@ discard block |
||
| 896 | 896 | * @param string $message_type The string should correspond to a message type. |
| 897 | 897 | * @return EE_message_type|null |
| 898 | 898 | */ |
| 899 | - public function get_active_message_type( $messenger, $message_type ) { |
|
| 899 | + public function get_active_message_type($messenger, $message_type) { |
|
| 900 | 900 | // EE_messages has been deprecated |
| 901 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 902 | - return $this->_message_resource_manager->get_active_message_type_for_messenger( $messenger, $message_type ); |
|
| 901 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 902 | + return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | |
@@ -910,7 +910,7 @@ discard block |
||
| 910 | 910 | */ |
| 911 | 911 | public function get_installed_message_types() { |
| 912 | 912 | // EE_messages has been deprecated |
| 913 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 913 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 914 | 914 | return $this->_message_resource_manager->installed_message_types(); |
| 915 | 915 | } |
| 916 | 916 | |
@@ -922,7 +922,7 @@ discard block |
||
| 922 | 922 | */ |
| 923 | 923 | public function get_installed_messengers() { |
| 924 | 924 | // EE_messages has been deprecated |
| 925 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 925 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 926 | 926 | return $this->_message_resource_manager->installed_messengers(); |
| 927 | 927 | } |
| 928 | 928 | |
@@ -933,10 +933,10 @@ discard block |
||
| 933 | 933 | * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type. |
| 934 | 934 | * @return array |
| 935 | 935 | */ |
| 936 | - public function get_all_contexts( $slugs_only = true ) { |
|
| 936 | + public function get_all_contexts($slugs_only = true) { |
|
| 937 | 937 | // EE_messages has been deprecated |
| 938 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 939 | - return $this->_message_resource_manager->get_all_contexts( $slugs_only ); |
|
| 938 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 939 | + return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | add_filter( |
| 996 | 996 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
| 997 | 997 | function($event_list_iframe_css) { |
| 998 | - if ( ! has_filter( 'FHEE__EventsArchiveIframe__event_list_iframe__css' )) { |
|
| 998 | + if ( ! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
| 999 | 999 | return $event_list_iframe_css; |
| 1000 | 1000 | } |
| 1001 | 1001 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | add_filter( |
| 1016 | 1016 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
| 1017 | 1017 | function($event_list_iframe_js) { |
| 1018 | - if ( ! has_filter( 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js' )) { |
|
| 1018 | + if ( ! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
| 1019 | 1019 | return $event_list_iframe_js; |
| 1020 | 1020 | } |
| 1021 | 1021 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | */ |
| 1096 | 1096 | public function event_list_title($event_list_title = '') |
| 1097 | 1097 | { |
| 1098 | - if (! empty($this->title)) { |
|
| 1098 | + if ( ! empty($this->title)) { |
|
| 1099 | 1099 | return $this->title; |
| 1100 | 1100 | } |
| 1101 | 1101 | return $event_list_title; |