Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Extend_Registrations_Admin_Page often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Extend_Registrations_Admin_Page, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 30 | class Extend_Registrations_Admin_Page extends Registrations_Admin_Page { |
||
| 31 | |||
| 32 | |||
| 33 | /** |
||
| 34 | * This is used to hold the reports template data which is setup early in the request. |
||
| 35 | * @type array |
||
| 36 | */ |
||
| 37 | protected $_reports_template_data = array(); |
||
| 38 | |||
| 39 | |||
| 40 | public function __construct( $routing = TRUE ) { |
||
| 46 | |||
| 47 | |||
| 48 | protected function _extend_page_config() { |
||
| 49 | $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
||
| 50 | |||
| 51 | $reg_id = ! empty( $this->_req_data['_REG_ID'] ) && ! is_array( $this->_req_data['_REG_ID'] ) ? $this->_req_data['_REG_ID'] : 0; |
||
| 52 | $att_id = ! empty( $this->_req_data[ 'ATT_ID' ] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0; |
||
| 53 | $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) ? $this->_req_data['post'] : $att_id; |
||
|
|
|||
| 54 | |||
| 55 | $new_page_routes = array( |
||
| 56 | 'reports' => array( |
||
| 57 | 'func' => '_registration_reports', |
||
| 58 | 'capability' => 'ee_read_registrations' |
||
| 59 | ), |
||
| 60 | 'registration_checkins' => array( |
||
| 61 | 'func' => '_registration_checkin_list_table', |
||
| 62 | 'capability' => 'ee_read_checkins' |
||
| 63 | ), |
||
| 64 | 'newsletter_selected_send' => array( |
||
| 65 | 'func' => '_newsletter_selected_send', |
||
| 66 | 'noheader' => TRUE, |
||
| 67 | 'capability' => 'ee_send_message' |
||
| 68 | ), |
||
| 69 | 'delete_checkin_rows' => array( |
||
| 70 | 'func' => '_delete_checkin_rows', |
||
| 71 | 'noheader' => TRUE, |
||
| 72 | 'capability' => 'ee_delete_checkins' |
||
| 73 | ), |
||
| 74 | 'delete_checkin_row' => array( |
||
| 75 | 'func' => '_delete_checkin_row', |
||
| 76 | 'noheader' => TRUE, |
||
| 77 | 'capability' => 'ee_delete_checkin', |
||
| 78 | 'obj_id' => $reg_id |
||
| 79 | ), |
||
| 80 | 'toggle_checkin_status' => array( |
||
| 81 | 'func' => '_toggle_checkin_status', |
||
| 82 | 'noheader' => TRUE, |
||
| 83 | 'capability' => 'ee_edit_checkin', |
||
| 84 | 'obj_id' => $reg_id |
||
| 85 | ), |
||
| 86 | 'event_registrations'=> array( |
||
| 87 | 'func' => '_event_registrations_list_table', |
||
| 88 | 'capability' => 'ee_read_checkins', |
||
| 89 | ) |
||
| 90 | ); |
||
| 91 | |||
| 92 | $this->_page_routes = array_merge( $this->_page_routes, $new_page_routes ); |
||
| 93 | |||
| 94 | $new_page_config = array( |
||
| 95 | 'reports' => array( |
||
| 96 | 'nav' => array( |
||
| 97 | 'label' => __('Reports', 'event_espresso'), |
||
| 98 | 'order' => 30 |
||
| 99 | ), |
||
| 100 | 'help_tabs' => array( |
||
| 101 | 'registrations_reports_help_tab' => array( |
||
| 102 | 'title' => __('Registration Reports', 'event_espresso'), |
||
| 103 | 'filename' => 'registrations_reports' |
||
| 104 | ) |
||
| 105 | ), |
||
| 106 | 'help_tour' => array( 'Registration_Reports_Help_Tour' ), |
||
| 107 | 'require_nonce' => FALSE |
||
| 108 | ), |
||
| 109 | 'event_registrations' => array( |
||
| 110 | 'nav' => array( |
||
| 111 | 'label' => __('Event Check-In', 'event_espresso'), |
||
| 112 | 'order' => 10, |
||
| 113 | 'persistent' => true |
||
| 114 | ), |
||
| 115 | 'help_tabs' => array( |
||
| 116 | 'registrations_event_checkin_help_tab' => array( |
||
| 117 | 'title' => __('Registrations Event Check-In', 'event_espresso'), |
||
| 118 | 'filename' => 'registrations_event_checkin' |
||
| 119 | ), |
||
| 120 | 'registrations_event_checkin_table_column_headings_help_tab' => array( |
||
| 121 | 'title' => __('Event Check-In Table Column Headings', 'event_espresso'), |
||
| 122 | 'filename' => 'registrations_event_checkin_table_column_headings' |
||
| 123 | ), |
||
| 124 | 'registrations_event_checkin_filters_help_tab' => array( |
||
| 125 | 'title' => __('Event Check-In Filters', 'event_espresso'), |
||
| 126 | 'filename' => 'registrations_event_checkin_filters' |
||
| 127 | ), |
||
| 128 | 'registrations_event_checkin_views_help_tab' => array( |
||
| 129 | 'title' => __('Event Check-In Views', 'event_espresso'), |
||
| 130 | 'filename' => 'registrations_event_checkin_views' |
||
| 131 | ), |
||
| 132 | 'registrations_event_checkin_other_help_tab' => array( |
||
| 133 | 'title' => __('Event Check-In Other', 'event_espresso'), |
||
| 134 | 'filename' => 'registrations_event_checkin_other' |
||
| 135 | ) |
||
| 136 | ), |
||
| 137 | 'help_tour' => array( 'Event_Checkin_Help_Tour' ), |
||
| 138 | 'qtips' => array('Registration_List_Table_Tips' ), |
||
| 139 | 'list_table' => 'EE_Event_Registrations_List_Table', |
||
| 140 | 'metaboxes' => array(), |
||
| 141 | 'require_nonce' => FALSE |
||
| 142 | ), |
||
| 143 | 'registration_checkins' => array( |
||
| 144 | 'nav' => array( |
||
| 145 | 'label' => __('Check-In Records', 'event_espresso'), |
||
| 146 | 'order' => 15, |
||
| 147 | 'persistent' => FALSE |
||
| 148 | ), |
||
| 149 | 'list_table' => 'EE_Registration_CheckIn_List_Table', |
||
| 150 | //'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ), |
||
| 151 | 'metaboxes' => array(), |
||
| 152 | 'require_nonce' => FALSE |
||
| 153 | ), |
||
| 154 | ); |
||
| 155 | |||
| 156 | // var_dump($this->_req_data); |
||
| 157 | // exit(); |
||
| 158 | |||
| 159 | $this->_page_config = array_merge( $this->_page_config, $new_page_config ); |
||
| 160 | $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
||
| 161 | $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
||
| 162 | } |
||
| 163 | |||
| 164 | |||
| 165 | |||
| 166 | protected function _ajax_hooks() { |
||
| 167 | parent::_ajax_hooks(); |
||
| 168 | add_action('wp_ajax_get_newsletter_form_content', array( $this, 'get_newsletter_form_content') ); |
||
| 169 | } |
||
| 170 | |||
| 171 | |||
| 172 | |||
| 173 | public function load_scripts_styles() { |
||
| 174 | parent::load_scripts_styles(); |
||
| 175 | |||
| 176 | //if newsletter message type is active then let's add filter and load js for it. |
||
| 177 | EE_Registry::instance()->load_helper('MSG_Template'); |
||
| 178 | if ( EEH_MSG_Template::is_mt_active('newsletter') ) { |
||
| 179 | //enqueue newsletter js |
||
| 180 | wp_enqueue_script( 'ee-newsletter-trigger', REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', array( 'ee-dialog'), EVENT_ESPRESSO_VERSION, TRUE ); |
||
| 181 | wp_enqueue_style( 'ee-newsletter-trigger-css', REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', array(), EVENT_ESPRESSO_VERSION ); |
||
| 182 | //hook in buttons for newsletter message type trigger. |
||
| 183 | add_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', array( $this, 'add_newsletter_action_buttons'), 10 ); |
||
| 184 | } |
||
| 185 | } |
||
| 186 | |||
| 187 | |||
| 188 | |||
| 189 | public function load_scripts_styles_reports() { |
||
| 194 | |||
| 195 | |||
| 196 | |||
| 197 | |||
| 198 | protected function _add_screen_options_event_registrations() { |
||
| 201 | |||
| 202 | |||
| 203 | |||
| 204 | |||
| 205 | |||
| 206 | View Code Duplication | protected function _add_screen_options_registration_checkins() { |
|
| 207 | $page_title = $this->_admin_page_title; |
||
| 208 | $this->_admin_page_title = __('Check-In Records', 'event_espresso'); |
||
| 209 | $this->_per_page_screen_option(); |
||
| 210 | $this->_admin_page_title = $page_title; |
||
| 211 | } |
||
| 212 | |||
| 213 | |||
| 214 | |||
| 215 | |||
| 216 | |||
| 217 | View Code Duplication | protected function _set_list_table_views_event_registrations() { |
|
| 218 | $this->_views = array( |
||
| 219 | 'all' => array( |
||
| 220 | 'slug' => 'all', |
||
| 221 | 'label' => __('All', 'event_espresso'), |
||
| 222 | 'count' => 0, |
||
| 223 | 'bulk_action' => !isset( $this->_req_data['event_id'] ) ? array() : array( |
||
| 224 | 'toggle_checkin_status' => __('Toggle Check-In', 'event_espresso'), |
||
| 225 | //'trash_registrations' => __('Trash Registrations', 'event_espresso') |
||
| 226 | ) |
||
| 227 | ), |
||
| 228 | ); |
||
| 229 | } |
||
| 230 | |||
| 231 | |||
| 232 | |||
| 233 | |||
| 234 | |||
| 235 | View Code Duplication | protected function _set_list_table_views_registration_checkins() { |
|
| 236 | $this->_views = array( |
||
| 237 | 'all' => array( |
||
| 238 | 'slug' => 'all', |
||
| 239 | 'label' => __('All', 'event_espresso'), |
||
| 240 | 'count' => 0, |
||
| 241 | 'bulk_action' => array( 'delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso') ) |
||
| 242 | ), |
||
| 243 | ); |
||
| 244 | } |
||
| 245 | |||
| 246 | |||
| 247 | |||
| 248 | /** |
||
| 249 | * callback for ajax action. |
||
| 250 | * |
||
| 251 | * @since 4.3.0 |
||
| 252 | * |
||
| 253 | * @return json |
||
| 254 | */ |
||
| 255 | public function get_newsletter_form_content() { |
||
| 256 | //do a nonce check cause we're not coming in from an normal route here. |
||
| 257 | $nonce = isset( $this->_req_data['get_newsletter_form_content_nonce'] ) ? sanitize_text_field( $this->_req_data['get_newsletter_form_content_nonce'] ) : ''; |
||
| 258 | $nonce_ref = 'get_newsletter_form_content_nonce'; |
||
| 259 | |||
| 260 | $this->_verify_nonce( $nonce, $nonce_ref ); |
||
| 261 | //let's get the mtp for the incoming MTP_ ID |
||
| 262 | View Code Duplication | if ( !isset( $this->_req_data['GRP_ID'] ) ) { |
|
| 263 | EE_Error::add_error( __('There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
||
| 264 | $this->_template_args['success'] = FALSE; |
||
| 265 | $this->_template_args['error'] = TRUE; |
||
| 266 | $this->_return_json(); |
||
| 267 | } |
||
| 268 | $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID( $this->_req_data['GRP_ID'] ); |
||
| 269 | View Code Duplication | if ( ! $MTPG instanceof EE_Message_Template_Group ) { |
|
| 270 | EE_Error::add_error( sprintf( __('The GRP_ID given (%d) does not appear to have a corresponding row in the database.', 'event_espresso'), $this->_req_data['GRP_ID'] ), __FILE__, __FUNCTION__, __LINE__ ); |
||
| 271 | $this->_template_args['success'] = FALSE; |
||
| 272 | $this->_template_args['error'] = TRUE; |
||
| 273 | $this->_return_json(); |
||
| 274 | } |
||
| 275 | |||
| 276 | $MTPs = $MTPG->context_templates(); |
||
| 277 | $MTPs = $MTPs['attendee']; |
||
| 278 | $template_fields = array(); |
||
| 279 | foreach ( $MTPs as $MTP ) { |
||
| 280 | $field = $MTP->get('MTP_template_field'); |
||
| 281 | if ( $field == 'content' ) { |
||
| 282 | $content = $MTP->get('MTP_content'); |
||
| 283 | if ( !empty( $content['newsletter_content'] ) ) { |
||
| 284 | $template_fields['newsletter_content'] = $content['newsletter_content']; |
||
| 285 | } |
||
| 286 | continue; |
||
| 287 | } |
||
| 288 | $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content'); |
||
| 289 | } |
||
| 290 | |||
| 291 | $this->_template_args['success'] = TRUE; |
||
| 292 | $this->_template_args['error'] = FALSE; |
||
| 293 | $this->_template_args['data'] = array( |
||
| 294 | 'batch_message_from' => isset($template_fields['from']) ? $template_fields['from'] : '', |
||
| 295 | 'batch_message_subject' => isset($template_fields['subject']) ? $template_fields['subject'] : '', |
||
| 296 | 'batch_message_content' => isset( $template_fields['newsletter_content'] ) ? $template_fields['newsletter_content'] : '' |
||
| 297 | ); |
||
| 298 | $this->_return_json(); |
||
| 299 | } |
||
| 300 | |||
| 301 | |||
| 302 | |||
| 303 | |||
| 304 | /** |
||
| 305 | * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
||
| 306 | * |
||
| 307 | * @since 4.3.0 |
||
| 308 | * |
||
| 309 | * @param EE_Admin_List_Table $list_table |
||
| 310 | * @return string html string for extra buttons |
||
| 311 | */ |
||
| 312 | public function add_newsletter_action_buttons( EE_Admin_List_Table $list_table ) { |
||
| 313 | if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_newsletter_selected_send' ) ) { |
||
| 314 | return ''; |
||
| 315 | } |
||
| 316 | |||
| 317 | $routes_to_add_to = array( |
||
| 318 | 'contact_list', |
||
| 319 | 'event_registrations', |
||
| 320 | 'default' |
||
| 321 | ); |
||
| 322 | if ( $this->_current_page == 'espresso_registrations' && in_array( $this->_req_action, $routes_to_add_to ) ) { |
||
| 323 | if ( ( $this->_req_action == 'event_registrations' && empty( $this->_req_data['event_id'] ) ) || ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] == 'trash' ) ) { |
||
| 324 | echo ''; |
||
| 325 | } else { |
||
| 326 | $button_text = sprintf( __('Send Batch Message (%s selected)', 'event_espresso'), '<span class="send-selected-newsletter-count">0</span>' ); |
||
| 327 | echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>' . $button_text . '</button>'; |
||
| 328 | add_action('admin_footer', array( $this, 'newsletter_send_form_skeleton') ); |
||
| 329 | } |
||
| 330 | } |
||
| 331 | } |
||
| 332 | |||
| 333 | |||
| 334 | |||
| 335 | |||
| 336 | public function newsletter_send_form_skeleton() { |
||
| 337 | $list_table = $this->_list_table_object; |
||
| 338 | $codes = array(); |
||
| 339 | //need to templates for the newsletter message type for the template selector. |
||
| 340 | $values[] = array( 'text' => __('Select Template to Use', 'event_espresso'), 'id' => 0 ); |
||
| 341 | $mtps = EEM_Message_Template_Group::instance()->get_all( array( array( 'MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email' ) ) ); |
||
| 342 | foreach ( $mtps as $mtp ) { |
||
| 343 | $name = $mtp->name(); |
||
| 344 | $values[] = array( |
||
| 345 | 'text' => empty( $name ) ? __('Global', 'event_espresso') : $name, |
||
| 346 | 'id' => $mtp->ID() |
||
| 347 | ); |
||
| 348 | } |
||
| 349 | |||
| 350 | //need to get a list of shortcodes that are available for the newsletter message type. |
||
| 351 | EE_Registry::instance()->load_helper('MSG_Template'); |
||
| 352 | $shortcodes = EEH_MSG_Template::get_shortcodes( 'newsletter', 'email', array(), 'attendee', FALSE ); |
||
| 353 | foreach ( $shortcodes as $field => $shortcode_array ) { |
||
| 354 | $codes[$field] = implode(', ', array_keys($shortcode_array ) ); |
||
| 355 | } |
||
| 356 | |||
| 357 | $shortcodes = $codes; |
||
| 358 | |||
| 359 | $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
||
| 360 | $form_template_args = array( |
||
| 361 | 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
||
| 362 | 'form_route' => 'newsletter_selected_send', |
||
| 363 | 'form_nonce_name' => 'newsletter_selected_send_nonce', |
||
| 364 | 'form_nonce' => wp_create_nonce( 'newsletter_selected_send_nonce' ), |
||
| 365 | 'redirect_back_to' => $this->_req_action, |
||
| 366 | 'ajax_nonce' => wp_create_nonce( 'get_newsletter_form_content_nonce'), |
||
| 367 | 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values ), |
||
| 368 | 'shortcodes' => $shortcodes, |
||
| 369 | 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration' |
||
| 370 | ); |
||
| 371 | EEH_Template::display_template( $form_template, $form_template_args ); |
||
| 372 | } |
||
| 373 | |||
| 374 | |||
| 375 | |||
| 376 | /** |
||
| 377 | * Handles sending selected registrations/contacts a newsletter. |
||
| 378 | * |
||
| 379 | * @since 4.3.0 |
||
| 380 | * |
||
| 381 | * @return void |
||
| 382 | */ |
||
| 383 | protected function _newsletter_selected_send() { |
||
| 384 | $success = TRUE; |
||
| 385 | //first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
||
| 386 | if ( empty( $this->_req_data['newsletter_mtp_selected'] ) ) { |
||
| 387 | EE_Error::add_error( __('In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
||
| 388 | $success = FALSE; |
||
| 389 | } |
||
| 390 | |||
| 391 | if ( $success ) { |
||
| 392 | //update Message template in case there are any changes |
||
| 393 | $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID( $this->_req_data['newsletter_mtp_selected'] ); |
||
| 394 | $MTPs = $MTPG instanceof EE_Message_Template_Group ? $MTPG->context_templates() : array(); |
||
| 395 | if ( empty( $MTPs ) ) { |
||
| 396 | EE_Error::add_error( __('Unable to retrieve message template fields from the db. Messages not sent.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
||
| 397 | $success = FALSE; |
||
| 398 | } |
||
| 399 | |||
| 400 | //let's just update the specific fields |
||
| 401 | foreach ( $MTPs['attendee'] as $MTP ) { |
||
| 402 | $field = $MTP->get('MTP_template_field'); |
||
| 403 | $content = $MTP->get('MTP_content'); |
||
| 404 | $new_content = $content; |
||
| 405 | switch( $field ) { |
||
| 406 | View Code Duplication | case 'from' : |
|
| 407 | $new_content = !empty( $this->_req_data['batch_message']['from'] ) ? $this->_req_data['batch_message']['from'] : $content; |
||
| 408 | break; |
||
| 409 | View Code Duplication | case 'subject' : |
|
| 410 | $new_content = !empty( $this->_req_data['batch_message']['subject'] ) ? $this->_req_data['batch_message']['subject'] : $content; |
||
| 411 | break; |
||
| 412 | case 'content' : |
||
| 413 | $new_content = $content; |
||
| 414 | $new_content['newsletter_content'] = !empty( $this->_req_data['batch_message']['content'] ) ? $this->_req_data['batch_message']['content'] : $content['newsletter_content']; |
||
| 415 | break; |
||
| 416 | default : |
||
| 417 | continue; |
||
| 418 | break; |
||
| 419 | } |
||
| 420 | $MTP->set('MTP_content', $new_content); |
||
| 421 | $MTP->save(); |
||
| 422 | } |
||
| 423 | |||
| 424 | //great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
||
| 425 | $id_type = !empty( $this->_req_data['batch_message']['id_type'] ) ? $this->_req_data['batch_message']['id_type'] : 'registration'; |
||
| 426 | |||
| 427 | //id_type will affect how we assemble the ids. |
||
| 428 | $ids = !empty( $this->_req_data['batch_message']['ids'] ) ? json_decode( stripslashes($this->_req_data['batch_message']['ids']) ) : array(); |
||
| 429 | |||
| 430 | $contacts = $id_type == 'registration' ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids( $ids ) : EEM_Attendee::instance()->get_all( array( array( 'ATT_ID' => array('in', $ids ) ) ) ); |
||
| 431 | |||
| 432 | //we do _action because ALL triggers are handled in EED_Messages. |
||
| 433 | do_action('AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', $contacts, $MTPG->ID() ); |
||
| 434 | } |
||
| 435 | $query_args = array( |
||
| 436 | 'action' => !empty( $this->_req_data['redirect_back_to'] ) ? $this->_req_data['redirect_back_to'] : 'default' |
||
| 437 | ); |
||
| 438 | $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
||
| 439 | } |
||
| 440 | |||
| 441 | |||
| 442 | /** |
||
| 443 | * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
||
| 444 | * Also $this->$_reports_template_data property is set for later usage by the _registration_reports method. |
||
| 445 | */ |
||
| 446 | protected function _registration_reports_js_setup() { |
||
| 450 | |||
| 451 | |||
| 452 | |||
| 453 | |||
| 454 | /** |
||
| 455 | * generates Business Reports regarding Registrations |
||
| 456 | * @access protected |
||
| 457 | * @return void |
||
| 458 | */ |
||
| 459 | View Code Duplication | protected function _registration_reports() { |
|
| 466 | |||
| 467 | |||
| 468 | /** |
||
| 469 | * Generates Business Report showing total registrations per day. |
||
| 470 | * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
||
| 471 | * |
||
| 472 | * @return string |
||
| 473 | */ |
||
| 474 | View Code Duplication | private function _registrations_per_day_report( $period = '-1 month' ) { |
|
| 512 | |||
| 513 | |||
| 514 | /** |
||
| 515 | * Generates Business Report showing total registrations per event. |
||
| 516 | * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
||
| 517 | * |
||
| 518 | * @return string |
||
| 519 | */ |
||
| 520 | View Code Duplication | private function _registrations_per_event_report( $period = '-1 month' ) { |
|
| 558 | |||
| 559 | |||
| 560 | |||
| 561 | |||
| 562 | /** |
||
| 563 | * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
||
| 564 | * @access protected |
||
| 565 | * @return void |
||
| 566 | */ |
||
| 567 | protected function _registration_checkin_list_table() { |
||
| 568 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
||
| 595 | |||
| 596 | |||
| 597 | |||
| 598 | /** |
||
| 599 | * toggle the Check-in status for the given registration (coming from ajax) |
||
| 600 | * @return json |
||
| 601 | */ |
||
| 602 | public function toggle_checkin_status() { |
||
| 625 | |||
| 626 | |||
| 627 | |||
| 628 | |||
| 629 | |||
| 630 | |||
| 631 | /** |
||
| 632 | * handles toggleing the checkin status for the registration, |
||
| 633 | * @access protected |
||
| 634 | * @param boolean $check_in |
||
| 635 | * @return void |
||
| 636 | */ |
||
| 637 | protected function _toggle_checkin_status() { |
||
| 669 | |||
| 670 | |||
| 671 | |||
| 672 | |||
| 673 | |||
| 674 | /** |
||
| 675 | * This is toggles a single Check-in for the given registration and datetime. |
||
| 676 | * @param int $REG_ID The registration we're toggling |
||
| 677 | * @param int $DTT_ID The datetime we're toggling |
||
| 678 | * @return int The new status toggled to. |
||
| 679 | */ |
||
| 680 | private function _toggle_checkin($REG_ID, $DTT_ID) { |
||
| 691 | |||
| 692 | |||
| 693 | /** |
||
| 694 | * Takes care of deleting multiple EE_Checkin table rows |
||
| 695 | * |
||
| 696 | * @access protected |
||
| 697 | * @return void |
||
| 698 | */ |
||
| 699 | protected function _delete_checkin_rows() { |
||
| 725 | |||
| 726 | |||
| 727 | |||
| 728 | /** |
||
| 729 | * Deletes a single EE_Checkin row |
||
| 730 | * @return void |
||
| 731 | */ |
||
| 732 | protected function _delete_checkin_row() { |
||
| 750 | |||
| 751 | |||
| 752 | |||
| 753 | |||
| 754 | |||
| 755 | /** |
||
| 756 | * generates HTML for the Event Registrations List Table |
||
| 757 | * @access protected |
||
| 758 | * @return void |
||
| 759 | */ |
||
| 760 | protected function _event_registrations_list_table() { |
||
| 814 | |||
| 815 | |||
| 816 | |||
| 817 | |||
| 818 | /** |
||
| 819 | * get_attendees |
||
| 820 | * @param bool $count whether to return count or data. |
||
| 821 | * @access public |
||
| 822 | * @return array |
||
| 823 | */ |
||
| 824 | public function get_event_attendees( $per_page = 10, $count = FALSE, $trash = FALSE, $orderby = '' ) { |
||
| 941 | |||
| 942 | } //end class Registrations Admin Page |
||
| 943 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.