Completed
Branch FET/event-question-group-refac... (2cd1c1)
by
unknown
55:42 queued 46:21
created
admin_pages/payments/Payments_Admin_Page.core.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
      *
478 478
      * @access protected
479 479
      * @param EE_Payment_Method $payment_method
480
-     * @return EE_Form_Section_Proper
480
+     * @return EE_Form_Section_HTML
481 481
      */
482 482
     protected function _pci_dss_compliance(EE_Payment_Method $payment_method)
483 483
     {
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
      *
521 521
      * @access protected
522 522
      * @param EE_Payment_Method $payment_method
523
-     * @return EE_Form_Section_Proper
523
+     * @return EE_Form_Section_HTML
524 524
      */
525 525
     protected function _currency_support(EE_Payment_Method $payment_method)
526 526
     {
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
      *
641 641
      * @access protected
642 642
      * @param EE_Payment_Method $payment_method
643
-     * @return EE_Form_Section_Proper
643
+     * @return EE_Form_Section_HTML
644 644
      */
645 645
     protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method)
646 646
     {
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types();
183 183
         $all_pmt_help_tabs_config = array();
184 184
         foreach ($payment_method_types as $payment_method_type) {
185
-            if (! EE_Registry::instance()->CAP->current_user_can(
185
+            if ( ! EE_Registry::instance()->CAP->current_user_can(
186 186
                 $payment_method_type->cap_name(),
187 187
                 'specific_payment_method_type_access'
188 188
             )
@@ -192,10 +192,10 @@  discard block
 block discarded – undo
192 192
             foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
193 193
                 $template_args = isset($config['template_args']) ? $config['template_args'] : array();
194 194
                 $template_args['admin_page_obj'] = $this;
195
-                $all_pmt_help_tabs_config[ $help_tab_name ] = array(
195
+                $all_pmt_help_tabs_config[$help_tab_name] = array(
196 196
                     'title'   => $config['title'],
197 197
                     'content' => EEH_Template::display_template(
198
-                        $payment_method_type->file_folder() . 'help_tabs' . DS . $config['filename'] . '.help_tab.php',
198
+                        $payment_method_type->file_folder().'help_tabs'.DS.$config['filename'].'.help_tab.php',
199 199
                         $template_args,
200 200
                         true
201 201
                     ),
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
         wp_enqueue_script('ee-text-links');
239 239
         wp_enqueue_script(
240 240
             'espresso_payments',
241
-            EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js',
241
+            EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js',
242 242
             array('espresso-ui-theme', 'ee-datepicker'),
243 243
             EVENT_ESPRESSO_VERSION,
244 244
             true
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         // styles
252 252
         wp_register_style(
253 253
             'espresso_payments',
254
-            EE_PAYMENTS_ASSETS_URL . 'ee-payments.css',
254
+            EE_PAYMENTS_ASSETS_URL.'ee-payments.css',
255 255
             array(),
256 256
             EVENT_ESPRESSO_VERSION
257 257
         );
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
                 continue;
281 281
             }
282 282
             // check access
283
-            if (! EE_Registry::instance()->CAP->current_user_can(
283
+            if ( ! EE_Registry::instance()->CAP->current_user_can(
284 284
                 $pmt_obj->cap_name(),
285 285
                 'specific_payment_method_type_access'
286 286
             )
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
             }
290 290
             // check for any active pms of that type
291 291
             $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
292
-            if (! $payment_method instanceof EE_Payment_Method) {
292
+            if ( ! $payment_method instanceof EE_Payment_Method) {
293 293
                 $payment_method = EE_Payment_Method::new_instance(
294 294
                     array(
295 295
                         'PMD_slug'       => sanitize_key($pmt_obj->system_name()),
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
                     )
300 300
                 );
301 301
             }
302
-            $payment_methods[ $payment_method->slug() ] = $payment_method;
302
+            $payment_methods[$payment_method->slug()] = $payment_method;
303 303
         }
304 304
         $payment_methods = apply_filters(
305 305
             'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
             if ($payment_method instanceof EE_Payment_Method) {
310 310
                 add_meta_box(
311 311
                     // html id
312
-                    'espresso_' . $payment_method->slug() . '_payment_settings',
312
+                    'espresso_'.$payment_method->slug().'_payment_settings',
313 313
                     // title
314 314
                     sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
315 315
                     // callback
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
                     array('payment_method' => $payment_method)
325 325
                 );
326 326
                 // setup for tabbed content
327
-                $tabs[ $payment_method->slug() ] = array(
327
+                $tabs[$payment_method->slug()] = array(
328 328
                     'label' => $payment_method->admin_name(),
329 329
                     'class' => $payment_method->active() ? 'gateway-active' : '',
330
-                    'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
330
+                    'href'  => 'espresso_'.$payment_method->slug().'_payment_settings',
331 331
                     'title' => __('Modify this Payment Method', 'event_espresso'),
332 332
                     'slug'  => $payment_method->slug(),
333 333
                 );
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
         }
359 359
         $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
360 360
         // if that didn't work or wasn't provided, find another way to select the current pm
361
-        if (! $this->_verify_payment_method($payment_method)) {
361
+        if ( ! $this->_verify_payment_method($payment_method)) {
362 362
             // like, looking for an active one
363 363
             $payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
364 364
             // test that one as well
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
     {
408 408
         $payment_method = isset($metabox['args'], $metabox['args']['payment_method'])
409 409
             ? $metabox['args']['payment_method'] : null;
410
-        if (! $payment_method instanceof EE_Payment_Method) {
410
+        if ( ! $payment_method instanceof EE_Payment_Method) {
411 411
             throw new EE_Error(
412 412
                 sprintf(
413 413
                     __(
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
             if ($form->form_data_present_in($this->_req_data)) {
425 425
                 $form->receive_form_submission($this->_req_data);
426 426
             }
427
-            echo $form->form_open() . $form->get_html_and_js() . $form->form_close();
427
+            echo $form->form_open().$form->get_html_and_js().$form->form_close();
428 428
         } else {
429 429
             echo $this->_activate_payment_method_button($payment_method)->get_html_and_js();
430 430
         }
@@ -440,13 +440,13 @@  discard block
 block discarded – undo
440 440
      */
441 441
     protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method)
442 442
     {
443
-        if (! $payment_method instanceof EE_Payment_Method) {
443
+        if ( ! $payment_method instanceof EE_Payment_Method) {
444 444
             return new EE_Form_Section_Proper();
445 445
         }
446 446
         return new EE_Form_Section_Proper(
447 447
             array(
448
-                'name'            => $payment_method->slug() . '_settings_form',
449
-                'html_id'         => $payment_method->slug() . '_settings_form',
448
+                'name'            => $payment_method->slug().'_settings_form',
449
+                'html_id'         => $payment_method->slug().'_settings_form',
450 450
                 'action'          => EE_Admin_Page::add_query_args_and_nonce(
451 451
                     array(
452 452
                         'action'         => 'update_payment_method',
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
                             EEH_HTML::label(
490 490
                                 EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
491 491
                             )
492
-                        ) .
492
+                        ).
493 493
                         EEH_HTML::td(
494 494
                             EEH_HTML::strong(
495 495
                                 __(
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
      */
525 525
     protected function _currency_support(EE_Payment_Method $payment_method)
526 526
     {
527
-        if (! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
527
+        if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
528 528
             return new EE_Form_Section_HTML(
529 529
                 EEH_HTML::table(
530 530
                     EEH_HTML::tr(
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
                             EEH_HTML::label(
533 533
                                 EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
534 534
                             )
535
-                        ) .
535
+                        ).
536 536
                         EEH_HTML::td(
537 537
                             EEH_HTML::strong(
538 538
                                 sprintf(
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
         $update_button = new EE_Submit_Input(
614 614
             array(
615 615
                 'name'       => 'submit',
616
-                'html_id'    => 'save_' . $payment_method->slug() . '_settings',
616
+                'html_id'    => 'save_'.$payment_method->slug().'_settings',
617 617
                 'default'    => sprintf(
618 618
                     __('Update %s Payment Settings', 'event_espresso'),
619 619
                     $payment_method->admin_name()
@@ -623,9 +623,9 @@  discard block
 block discarded – undo
623 623
         );
624 624
         return new EE_Form_Section_HTML(
625 625
             EEH_HTML::table(
626
-                EEH_HTML::no_row(EEH_HTML::br(2)) .
626
+                EEH_HTML::no_row(EEH_HTML::br(2)).
627 627
                 EEH_HTML::tr(
628
-                    EEH_HTML::th(__('Update Settings', 'event_espresso')) .
628
+                    EEH_HTML::th(__('Update Settings', 'event_espresso')).
629 629
                     EEH_HTML::td(
630 630
                         $update_button->get_html_for_input()
631 631
                     )
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
         return new EE_Form_Section_HTML(
652 652
             EEH_HTML::table(
653 653
                 EEH_HTML::tr(
654
-                    EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')) .
654
+                    EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')).
655 655
                     EEH_HTML::td(
656 656
                         EEH_HTML::link(
657 657
                             EE_Admin_Page::add_query_args_and_nonce(
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
                             ),
664 664
                             $link_text_and_title,
665 665
                             $link_text_and_title,
666
-                            'deactivate_' . $payment_method->slug(),
666
+                            'deactivate_'.$payment_method->slug(),
667 667
                             'espresso-button button-secondary'
668 668
                         )
669 669
                     )
@@ -688,8 +688,8 @@  discard block
 block discarded – undo
688 688
         );
689 689
         return new EE_Form_Section_Proper(
690 690
             array(
691
-                'name'            => 'activate_' . $payment_method->slug() . '_settings_form',
692
-                'html_id'         => 'activate_' . $payment_method->slug() . '_settings_form',
691
+                'name'            => 'activate_'.$payment_method->slug().'_settings_form',
692
+                'html_id'         => 'activate_'.$payment_method->slug().'_settings_form',
693 693
                 'action'          => '#',
694 694
                 'layout_strategy' => new EE_Admin_Two_Column_Layout(),
695 695
                 'subsections'     => apply_filters(
@@ -705,11 +705,11 @@  discard block
 block discarded – undo
705 705
                                         '',
706 706
                                         'colspan="2"'
707 707
                                     )
708
-                                ) .
708
+                                ).
709 709
                                 EEH_HTML::tr(
710 710
                                     EEH_HTML::th(
711 711
                                         EEH_HTML::label(__('Click to Activate ', 'event_espresso'))
712
-                                    ) .
712
+                                    ).
713 713
                                     EEH_HTML::td(
714 714
                                         EEH_HTML::link(
715 715
                                             EE_Admin_Page::add_query_args_and_nonce(
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
                                             ),
722 722
                                             $link_text_and_title,
723 723
                                             $link_text_and_title,
724
-                                            'activate_' . $payment_method->slug(),
724
+                                            'activate_'.$payment_method->slug(),
725 725
                                             'espresso-button-green button-primary'
726 726
                                         )
727 727
                                     )
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
         return new EE_Form_Section_HTML(
748 748
             EEH_HTML::table(
749 749
                 EEH_HTML::tr(
750
-                    EEH_HTML::th() .
750
+                    EEH_HTML::th().
751 751
                     EEH_HTML::td(
752 752
                         EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
753 753
                     )
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
                 }
832 832
             }
833 833
             // if we couldn't find the correct payment method type...
834
-            if (! $correct_pmt_form_to_use) {
834
+            if ( ! $correct_pmt_form_to_use) {
835 835
                 EE_Error::add_error(
836 836
                     __(
837 837
                         "We could not find which payment method type your form submission related to. Please contact support",
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
             $correct_pmt_form_to_use->receive_form_submission($this->_req_data);
847 847
             if ($correct_pmt_form_to_use->is_valid()) {
848 848
                 $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings');
849
-                if (! $payment_settings_subform instanceof EE_Payment_Method_Form) {
849
+                if ( ! $payment_settings_subform instanceof EE_Payment_Method_Form) {
850 850
                     throw new EE_Error(
851 851
                         sprintf(
852 852
                             __(
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
         $form = $this->getPaymentSettingsForm();
899 899
         $this->_set_add_edit_form_tags('update_payment_settings');
900 900
         $this->_set_publish_post_box_vars(null, false, false, null, false);
901
-        $this->_template_args['admin_page_content'] =  $form->get_html_and_js();
901
+        $this->_template_args['admin_page_content'] = $form->get_html_and_js();
902 902
         $this->display_admin_page_with_sidebar();
903 903
     }
904 904
 
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
             EE_Registry::instance()->CFG
935 935
         );
936 936
 
937
-        $cfg =  EE_Registry::instance()->CFG ;
937
+        $cfg = EE_Registry::instance()->CFG;
938 938
 
939 939
         $what = __('Payment Settings', 'event_espresso');
940 940
         $success = $this->_update_espresso_configuration(
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
         }
1036 1036
         // take into account search
1037 1037
         if (isset($this->_req_data['s']) && $this->_req_data['s']) {
1038
-            $similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%');
1038
+            $similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%');
1039 1039
             $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
1040 1040
             $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
1041 1041
             $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
@@ -1055,8 +1055,8 @@  discard block
 block discarded – undo
1055 1055
             $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
1056 1056
             $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
1057 1057
             // make sure our timestamps start and end right at the boundaries for each day
1058
-            $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
1059
-            $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
1058
+            $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
1059
+            $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
1060 1060
             // convert to timestamps
1061 1061
             $start_date = strtotime($start_date);
1062 1062
             $end_date = strtotime($end_date);
@@ -1089,15 +1089,15 @@  discard block
 block discarded – undo
1089 1089
             $query_params['order_by'] = array('LOG_time' => 'DESC');
1090 1090
         }
1091 1091
         $offset = ($current_page - 1) * $per_page;
1092
-        if (! isset($this->_req_data['download_results'])) {
1092
+        if ( ! isset($this->_req_data['download_results'])) {
1093 1093
             $query_params['limit'] = array($offset, $per_page);
1094 1094
         }
1095 1095
         // now they've requested to instead just download the file instead of viewing it.
1096 1096
         if (isset($this->_req_data['download_results'])) {
1097 1097
             $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
1098 1098
             header('Content-Disposition: attachment');
1099
-            header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url()));
1100
-            echo "<h1>Payment Logs for " . site_url() . "</h1>";
1099
+            header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url()));
1100
+            echo "<h1>Payment Logs for ".site_url()."</h1>";
1101 1101
             echo "<h3>Query:</h3>";
1102 1102
             var_dump($query_params);
1103 1103
             echo "<h3>Results:</h3>";
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
             }
1153 1153
         }
1154 1154
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1155
-            EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
1155
+            EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php',
1156 1156
             array(
1157 1157
                 'payment_log'    => $payment_log,
1158 1158
                 'payment_method' => $payment_method,
Please login to merge, or discard this patch.
Indentation   +1146 added lines, -1146 removed lines patch added patch discarded remove patch
@@ -16,1150 +16,1150 @@
 block discarded – undo
16 16
 class Payments_Admin_Page extends EE_Admin_Page
17 17
 {
18 18
 
19
-    /**
20
-     * Variables used for when we're re-sorting the logs results, in case
21
-     * we needed to do two queries and we need to resort
22
-     *
23
-     * @var string
24
-     */
25
-    private $_sort_logs_again_direction;
26
-
27
-
28
-    /**
29
-     * @Constructor
30
-     * @access public
31
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
32
-     * @throws EE_Error
33
-     * @throws InvalidArgumentException
34
-     * @throws InvalidDataTypeException
35
-     * @throws InvalidInterfaceException
36
-     * @throws ReflectionException
37
-     */
38
-    public function __construct($routing = true)
39
-    {
40
-        parent::__construct($routing);
41
-    }
42
-
43
-
44
-    protected function _init_page_props()
45
-    {
46
-        $this->page_slug = EE_PAYMENTS_PG_SLUG;
47
-        $this->page_label = __('Payment Methods', 'event_espresso');
48
-        $this->_admin_base_url = EE_PAYMENTS_ADMIN_URL;
49
-        $this->_admin_base_path = EE_PAYMENTS_ADMIN;
50
-    }
51
-
52
-
53
-    protected function _ajax_hooks()
54
-    {
55
-        // todo: all hooks for ajax goes here.
56
-    }
57
-
58
-
59
-    protected function _define_page_props()
60
-    {
61
-        $this->_admin_page_title = $this->page_label;
62
-        $this->_labels = array(
63
-            'publishbox' => __('Update Settings', 'event_espresso'),
64
-        );
65
-    }
66
-
67
-
68
-    protected function _set_page_routes()
69
-    {
70
-        /**
71
-         * note that with payment method capabilities, although we've implemented
72
-         * capability mapping which will be used for accessing payment methods owned by
73
-         * other users.  This is not fully implemented yet in the payment method ui.
74
-         * Currently only the "plural" caps are in active use.
75
-         * When cap mapping is implemented, some routes will need to use the singular form of
76
-         * capability method and also include the $id of the payment method for the route.
77
-         **/
78
-        $this->_page_routes = array(
79
-            'default'                   => array(
80
-                'func'       => '_payment_methods_list',
81
-                'capability' => 'ee_edit_payment_methods',
82
-            ),
83
-            'payment_settings'          => array(
84
-                'func'       => '_payment_settings',
85
-                'capability' => 'ee_manage_gateways',
86
-            ),
87
-            'activate_payment_method'   => array(
88
-                'func'       => '_activate_payment_method',
89
-                'noheader'   => true,
90
-                'capability' => 'ee_edit_payment_methods',
91
-            ),
92
-            'deactivate_payment_method' => array(
93
-                'func'       => '_deactivate_payment_method',
94
-                'noheader'   => true,
95
-                'capability' => 'ee_delete_payment_methods',
96
-            ),
97
-            'update_payment_method'     => array(
98
-                'func'               => '_update_payment_method',
99
-                'noheader'           => true,
100
-                'headers_sent_route' => 'default',
101
-                'capability'         => 'ee_edit_payment_methods',
102
-            ),
103
-            'update_payment_settings'   => array(
104
-                'func'       => '_update_payment_settings',
105
-                'noheader'   => true,
106
-                'capability' => 'ee_manage_gateways',
107
-            ),
108
-            'payment_log'               => array(
109
-                'func'       => '_payment_log_overview_list_table',
110
-                'capability' => 'ee_read_payment_methods',
111
-            ),
112
-            'payment_log_details'       => array(
113
-                'func'       => '_payment_log_details',
114
-                'capability' => 'ee_read_payment_methods',
115
-            ),
116
-        );
117
-    }
118
-
119
-
120
-    protected function _set_page_config()
121
-    {
122
-        $payment_method_list_config = array(
123
-            'nav'           => array(
124
-                'label' => __('Payment Methods', 'event_espresso'),
125
-                'order' => 10,
126
-            ),
127
-            'metaboxes'     => $this->_default_espresso_metaboxes,
128
-            'help_tabs'     => array_merge(
129
-                array(
130
-                    'payment_methods_overview_help_tab' => array(
131
-                        'title'    => __('Payment Methods Overview', 'event_espresso'),
132
-                        'filename' => 'payment_methods_overview',
133
-                    ),
134
-                ),
135
-                $this->_add_payment_method_help_tabs()
136
-            ),
137
-            'help_tour'     => array('Payment_Methods_Selection_Help_Tour'),
138
-            'require_nonce' => false,
139
-        );
140
-        $this->_page_config = array(
141
-            'default'          => $payment_method_list_config,
142
-            'payment_settings' => array(
143
-                'nav'           => array(
144
-                    'label' => __('Settings', 'event_espresso'),
145
-                    'order' => 20,
146
-                ),
147
-                'help_tabs'     => array(
148
-                    'payment_methods_settings_help_tab' => array(
149
-                        'title'    => __('Payment Method Settings', 'event_espresso'),
150
-                        'filename' => 'payment_methods_settings',
151
-                    ),
152
-                ),
153
-                // 'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ),
154
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
155
-                'require_nonce' => false,
156
-            ),
157
-            'payment_log'      => array(
158
-                'nav'           => array(
159
-                    'label' => __("Logs", 'event_espresso'),
160
-                    'order' => 30,
161
-                ),
162
-                'list_table'    => 'Payment_Log_Admin_List_Table',
163
-                'metaboxes'     => $this->_default_espresso_metaboxes,
164
-                'require_nonce' => false,
165
-            ),
166
-        );
167
-    }
168
-
169
-
170
-    /**
171
-     * @return array
172
-     * @throws DomainException
173
-     * @throws EE_Error
174
-     * @throws InvalidArgumentException
175
-     * @throws InvalidDataTypeException
176
-     * @throws InvalidInterfaceException
177
-     * @throws ReflectionException
178
-     */
179
-    protected function _add_payment_method_help_tabs()
180
-    {
181
-        EE_Registry::instance()->load_lib('Payment_Method_Manager');
182
-        $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types();
183
-        $all_pmt_help_tabs_config = array();
184
-        foreach ($payment_method_types as $payment_method_type) {
185
-            if (! EE_Registry::instance()->CAP->current_user_can(
186
-                $payment_method_type->cap_name(),
187
-                'specific_payment_method_type_access'
188
-            )
189
-            ) {
190
-                continue;
191
-            }
192
-            foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
193
-                $template_args = isset($config['template_args']) ? $config['template_args'] : array();
194
-                $template_args['admin_page_obj'] = $this;
195
-                $all_pmt_help_tabs_config[ $help_tab_name ] = array(
196
-                    'title'   => $config['title'],
197
-                    'content' => EEH_Template::display_template(
198
-                        $payment_method_type->file_folder() . 'help_tabs' . DS . $config['filename'] . '.help_tab.php',
199
-                        $template_args,
200
-                        true
201
-                    ),
202
-                );
203
-            }
204
-        }
205
-        return $all_pmt_help_tabs_config;
206
-    }
207
-
208
-
209
-    // none of the below group are currently used for Gateway Settings
210
-    protected function _add_screen_options()
211
-    {
212
-    }
213
-
214
-
215
-    protected function _add_feature_pointers()
216
-    {
217
-    }
218
-
219
-
220
-    public function admin_init()
221
-    {
222
-    }
223
-
224
-
225
-    public function admin_notices()
226
-    {
227
-    }
228
-
229
-
230
-    public function admin_footer_scripts()
231
-    {
232
-    }
233
-
234
-
235
-    public function load_scripts_styles()
236
-    {
237
-        wp_enqueue_script('ee_admin_js');
238
-        wp_enqueue_script('ee-text-links');
239
-        wp_enqueue_script(
240
-            'espresso_payments',
241
-            EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js',
242
-            array('espresso-ui-theme', 'ee-datepicker'),
243
-            EVENT_ESPRESSO_VERSION,
244
-            true
245
-        );
246
-    }
247
-
248
-
249
-    public function load_scripts_styles_default()
250
-    {
251
-        // styles
252
-        wp_register_style(
253
-            'espresso_payments',
254
-            EE_PAYMENTS_ASSETS_URL . 'ee-payments.css',
255
-            array(),
256
-            EVENT_ESPRESSO_VERSION
257
-        );
258
-        wp_enqueue_style('espresso_payments');
259
-        wp_enqueue_style('ee-text-links');
260
-        // scripts
261
-    }
262
-
263
-
264
-    protected function _payment_methods_list()
265
-    {
266
-        /**
267
-         * first let's ensure payment methods have been setup. We do this here because when people activate a
268
-         * payment method for the first time (as an addon), it may not setup its capabilities or get registered
269
-         * correctly due to the loading process.  However, people MUST setup the details for the payment method so its
270
-         * safe to do a recheck here.
271
-         */
272
-        EE_Registry::instance()->load_lib('Payment_Method_Manager');
273
-        EEM_Payment_Method::instance()->verify_button_urls();
274
-        // setup tabs, one for each payment method type
275
-        $tabs = array();
276
-        $payment_methods = array();
277
-        foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
278
-            // we don't want to show admin-only PMTs for now
279
-            if ($pmt_obj instanceof EE_PMT_Admin_Only) {
280
-                continue;
281
-            }
282
-            // check access
283
-            if (! EE_Registry::instance()->CAP->current_user_can(
284
-                $pmt_obj->cap_name(),
285
-                'specific_payment_method_type_access'
286
-            )
287
-            ) {
288
-                continue;
289
-            }
290
-            // check for any active pms of that type
291
-            $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
292
-            if (! $payment_method instanceof EE_Payment_Method) {
293
-                $payment_method = EE_Payment_Method::new_instance(
294
-                    array(
295
-                        'PMD_slug'       => sanitize_key($pmt_obj->system_name()),
296
-                        'PMD_type'       => $pmt_obj->system_name(),
297
-                        'PMD_name'       => $pmt_obj->pretty_name(),
298
-                        'PMD_admin_name' => $pmt_obj->pretty_name(),
299
-                    )
300
-                );
301
-            }
302
-            $payment_methods[ $payment_method->slug() ] = $payment_method;
303
-        }
304
-        $payment_methods = apply_filters(
305
-            'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
306
-            $payment_methods
307
-        );
308
-        foreach ($payment_methods as $payment_method) {
309
-            if ($payment_method instanceof EE_Payment_Method) {
310
-                add_meta_box(
311
-                    // html id
312
-                    'espresso_' . $payment_method->slug() . '_payment_settings',
313
-                    // title
314
-                    sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
315
-                    // callback
316
-                    array($this, 'payment_method_settings_meta_box'),
317
-                    // post type
318
-                    null,
319
-                    // context
320
-                    'normal',
321
-                    // priority
322
-                    'default',
323
-                    // callback args
324
-                    array('payment_method' => $payment_method)
325
-                );
326
-                // setup for tabbed content
327
-                $tabs[ $payment_method->slug() ] = array(
328
-                    'label' => $payment_method->admin_name(),
329
-                    'class' => $payment_method->active() ? 'gateway-active' : '',
330
-                    'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
331
-                    'title' => __('Modify this Payment Method', 'event_espresso'),
332
-                    'slug'  => $payment_method->slug(),
333
-                );
334
-            }
335
-        }
336
-        $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links(
337
-            $tabs,
338
-            'payment_method_links',
339
-            '|',
340
-            $this->_get_active_payment_method_slug()
341
-        );
342
-        $this->display_admin_page_with_sidebar();
343
-    }
344
-
345
-
346
-    /**
347
-     *   _get_active_payment_method_slug
348
-     *
349
-     * @return string
350
-     */
351
-    protected function _get_active_payment_method_slug()
352
-    {
353
-        $payment_method_slug = false;
354
-        // decide which payment method tab to open first, as dictated by the request's 'payment_method'
355
-        if (isset($this->_req_data['payment_method'])) {
356
-            // if they provided the current payment method, use it
357
-            $payment_method_slug = sanitize_key($this->_req_data['payment_method']);
358
-        }
359
-        $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
360
-        // if that didn't work or wasn't provided, find another way to select the current pm
361
-        if (! $this->_verify_payment_method($payment_method)) {
362
-            // like, looking for an active one
363
-            $payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
364
-            // test that one as well
365
-            if ($this->_verify_payment_method($payment_method)) {
366
-                $payment_method_slug = $payment_method->slug();
367
-            } else {
368
-                $payment_method_slug = 'paypal_standard';
369
-            }
370
-        }
371
-        return $payment_method_slug;
372
-    }
373
-
374
-
375
-    /**
376
-     *    payment_method_settings_meta_box
377
-     *    returns TRUE if the passed payment method is properly constructed and the logged in user has the correct
378
-     *    capabilities to access it
379
-     *
380
-     * @param EE_Payment_Method $payment_method
381
-     * @return boolean
382
-     */
383
-    protected function _verify_payment_method($payment_method)
384
-    {
385
-        if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base
386
-            && EE_Registry::instance()->CAP->current_user_can(
387
-                $payment_method->type_obj()->cap_name(),
388
-                'specific_payment_method_type_access'
389
-            )
390
-        ) {
391
-            return true;
392
-        }
393
-        return false;
394
-    }
395
-
396
-
397
-    /**
398
-     *    payment_method_settings_meta_box
399
-     *
400
-     * @param NULL  $post_obj_which_is_null is an object containing the current post (as a $post object)
401
-     * @param array $metabox                is an array with metabox id, title, callback, and args elements. the value
402
-     *                                      at 'args' has key 'payment_method', as set within _payment_methods_list
403
-     * @return string
404
-     * @throws EE_Error
405
-     */
406
-    public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox)
407
-    {
408
-        $payment_method = isset($metabox['args'], $metabox['args']['payment_method'])
409
-            ? $metabox['args']['payment_method'] : null;
410
-        if (! $payment_method instanceof EE_Payment_Method) {
411
-            throw new EE_Error(
412
-                sprintf(
413
-                    __(
414
-                        'Payment method metabox setup incorrectly. No Payment method object was supplied',
415
-                        'event_espresso'
416
-                    )
417
-                )
418
-            );
419
-        }
420
-        $payment_method_scopes = $payment_method->active();
421
-        // if the payment method really exists show its form, otherwise the activation template
422
-        if ($payment_method->ID() && ! empty($payment_method_scopes)) {
423
-            $form = $this->_generate_payment_method_settings_form($payment_method);
424
-            if ($form->form_data_present_in($this->_req_data)) {
425
-                $form->receive_form_submission($this->_req_data);
426
-            }
427
-            echo $form->form_open() . $form->get_html_and_js() . $form->form_close();
428
-        } else {
429
-            echo $this->_activate_payment_method_button($payment_method)->get_html_and_js();
430
-        }
431
-    }
432
-
433
-
434
-    /**
435
-     * Gets the form for all the settings related to this payment method type
436
-     *
437
-     * @access protected
438
-     * @param EE_Payment_Method $payment_method
439
-     * @return EE_Form_Section_Proper
440
-     */
441
-    protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method)
442
-    {
443
-        if (! $payment_method instanceof EE_Payment_Method) {
444
-            return new EE_Form_Section_Proper();
445
-        }
446
-        return new EE_Form_Section_Proper(
447
-            array(
448
-                'name'            => $payment_method->slug() . '_settings_form',
449
-                'html_id'         => $payment_method->slug() . '_settings_form',
450
-                'action'          => EE_Admin_Page::add_query_args_and_nonce(
451
-                    array(
452
-                        'action'         => 'update_payment_method',
453
-                        'payment_method' => $payment_method->slug(),
454
-                    ),
455
-                    EE_PAYMENTS_ADMIN_URL
456
-                ),
457
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
458
-                'subsections'     => apply_filters(
459
-                    'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
460
-                    array(
461
-                        'pci_dss_compliance'      => $this->_pci_dss_compliance($payment_method),
462
-                        'currency_support'        => $this->_currency_support($payment_method),
463
-                        'payment_method_settings' => $this->_payment_method_settings($payment_method),
464
-                        'update'                  => $this->_update_payment_method_button($payment_method),
465
-                        'deactivate'              => $this->_deactivate_payment_method_button($payment_method),
466
-                        'fine_print'              => $this->_fine_print(),
467
-                    ),
468
-                    $payment_method
469
-                ),
470
-            )
471
-        );
472
-    }
473
-
474
-
475
-    /**
476
-     * _pci_dss_compliance
477
-     *
478
-     * @access protected
479
-     * @param EE_Payment_Method $payment_method
480
-     * @return EE_Form_Section_Proper
481
-     */
482
-    protected function _pci_dss_compliance(EE_Payment_Method $payment_method)
483
-    {
484
-        if ($payment_method->type_obj()->requires_https()) {
485
-            return new EE_Form_Section_HTML(
486
-                EEH_HTML::table(
487
-                    EEH_HTML::tr(
488
-                        EEH_HTML::th(
489
-                            EEH_HTML::label(
490
-                                EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
491
-                            )
492
-                        ) .
493
-                        EEH_HTML::td(
494
-                            EEH_HTML::strong(
495
-                                __(
496
-                                    'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.',
497
-                                    'event_espresso'
498
-                                )
499
-                            )
500
-                            .
501
-                            EEH_HTML::br()
502
-                            .
503
-                            __('Learn more about ', 'event_espresso')
504
-                            . EEH_HTML::link(
505
-                                'https://www.pcisecuritystandards.org/merchants/index.php',
506
-                                __('PCI DSS compliance', 'event_espresso')
507
-                            )
508
-                        )
509
-                    )
510
-                )
511
-            );
512
-        } else {
513
-            return new EE_Form_Section_HTML('');
514
-        }
515
-    }
516
-
517
-
518
-    /**
519
-     * _currency_support
520
-     *
521
-     * @access protected
522
-     * @param EE_Payment_Method $payment_method
523
-     * @return EE_Form_Section_Proper
524
-     */
525
-    protected function _currency_support(EE_Payment_Method $payment_method)
526
-    {
527
-        if (! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
528
-            return new EE_Form_Section_HTML(
529
-                EEH_HTML::table(
530
-                    EEH_HTML::tr(
531
-                        EEH_HTML::th(
532
-                            EEH_HTML::label(
533
-                                EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
534
-                            )
535
-                        ) .
536
-                        EEH_HTML::td(
537
-                            EEH_HTML::strong(
538
-                                sprintf(
539
-                                    __(
540
-                                        'This payment method does not support the currency set on your site (%1$s). Please activate a different payment method or change your site\'s country and associated currency.',
541
-                                        'event_espresso'
542
-                                    ),
543
-                                    EE_Config::instance()->currency->code
544
-                                )
545
-                            )
546
-                        )
547
-                    )
548
-                )
549
-            );
550
-        } else {
551
-            return new EE_Form_Section_HTML('');
552
-        }
553
-    }
554
-
555
-
556
-    /**
557
-     * _update_payment_method_button
558
-     *
559
-     * @access protected
560
-     * @param EE_Payment_Method $payment_method
561
-     * @return EE_Payment_Method_Form
562
-     */
563
-    protected function _payment_method_settings(EE_Payment_Method $payment_method)
564
-    {
565
-        // modify the form so we only have/show fields that will be implemented for this version
566
-        return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
567
-    }
568
-
569
-
570
-    /**
571
-     * Simplifies the form to merely reproduce 4.1's gateway settings functionality
572
-     *
573
-     * @param EE_Form_Section_Proper $form_section
574
-     * @param string                 $payment_method_name
575
-     * @return EE_Payment_Method_Form
576
-     * @throws EE_Error
577
-     */
578
-    protected function _simplify_form($form_section, $payment_method_name = '')
579
-    {
580
-        if ($form_section instanceof EE_Payment_Method_Form) {
581
-            $form_section->exclude(
582
-                array(
583
-                    'PMD_type', // dont want them changing the type
584
-                    'PMD_slug', // or the slug (probably never)
585
-                    'PMD_wp_user', // or the user's ID
586
-                    'Currency' // or the currency, until the rest of EE supports simultaneous currencies
587
-                )
588
-            );
589
-            return $form_section;
590
-        } else {
591
-            throw new EE_Error(
592
-                sprintf(
593
-                    __(
594
-                        'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.',
595
-                        'event_espresso'
596
-                    ),
597
-                    $payment_method_name
598
-                )
599
-            );
600
-        }
601
-    }
602
-
603
-
604
-    /**
605
-     * _update_payment_method_button
606
-     *
607
-     * @access protected
608
-     * @param EE_Payment_Method $payment_method
609
-     * @return EE_Form_Section_HTML
610
-     */
611
-    protected function _update_payment_method_button(EE_Payment_Method $payment_method)
612
-    {
613
-        $update_button = new EE_Submit_Input(
614
-            array(
615
-                'name'       => 'submit',
616
-                'html_id'    => 'save_' . $payment_method->slug() . '_settings',
617
-                'default'    => sprintf(
618
-                    __('Update %s Payment Settings', 'event_espresso'),
619
-                    $payment_method->admin_name()
620
-                ),
621
-                'html_label' => EEH_HTML::nbsp(),
622
-            )
623
-        );
624
-        return new EE_Form_Section_HTML(
625
-            EEH_HTML::table(
626
-                EEH_HTML::no_row(EEH_HTML::br(2)) .
627
-                EEH_HTML::tr(
628
-                    EEH_HTML::th(__('Update Settings', 'event_espresso')) .
629
-                    EEH_HTML::td(
630
-                        $update_button->get_html_for_input()
631
-                    )
632
-                )
633
-            )
634
-        );
635
-    }
636
-
637
-
638
-    /**
639
-     * _deactivate_payment_method_button
640
-     *
641
-     * @access protected
642
-     * @param EE_Payment_Method $payment_method
643
-     * @return EE_Form_Section_Proper
644
-     */
645
-    protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method)
646
-    {
647
-        $link_text_and_title = sprintf(
648
-            __('Deactivate %1$s Payments?', 'event_espresso'),
649
-            $payment_method->admin_name()
650
-        );
651
-        return new EE_Form_Section_HTML(
652
-            EEH_HTML::table(
653
-                EEH_HTML::tr(
654
-                    EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')) .
655
-                    EEH_HTML::td(
656
-                        EEH_HTML::link(
657
-                            EE_Admin_Page::add_query_args_and_nonce(
658
-                                array(
659
-                                    'action'         => 'deactivate_payment_method',
660
-                                    'payment_method' => $payment_method->slug(),
661
-                                ),
662
-                                EE_PAYMENTS_ADMIN_URL
663
-                            ),
664
-                            $link_text_and_title,
665
-                            $link_text_and_title,
666
-                            'deactivate_' . $payment_method->slug(),
667
-                            'espresso-button button-secondary'
668
-                        )
669
-                    )
670
-                )
671
-            )
672
-        );
673
-    }
674
-
675
-
676
-    /**
677
-     * _activate_payment_method_button
678
-     *
679
-     * @access protected
680
-     * @param EE_Payment_Method $payment_method
681
-     * @return EE_Form_Section_Proper
682
-     */
683
-    protected function _activate_payment_method_button(EE_Payment_Method $payment_method)
684
-    {
685
-        $link_text_and_title = sprintf(
686
-            __('Activate %1$s Payment Method?', 'event_espresso'),
687
-            $payment_method->admin_name()
688
-        );
689
-        return new EE_Form_Section_Proper(
690
-            array(
691
-                'name'            => 'activate_' . $payment_method->slug() . '_settings_form',
692
-                'html_id'         => 'activate_' . $payment_method->slug() . '_settings_form',
693
-                'action'          => '#',
694
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
695
-                'subsections'     => apply_filters(
696
-                    'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections',
697
-                    array(
698
-                        new EE_Form_Section_HTML(
699
-                            EEH_HTML::table(
700
-                                EEH_HTML::tr(
701
-                                    EEH_HTML::td(
702
-                                        $payment_method->type_obj()->introductory_html(),
703
-                                        '',
704
-                                        '',
705
-                                        '',
706
-                                        'colspan="2"'
707
-                                    )
708
-                                ) .
709
-                                EEH_HTML::tr(
710
-                                    EEH_HTML::th(
711
-                                        EEH_HTML::label(__('Click to Activate ', 'event_espresso'))
712
-                                    ) .
713
-                                    EEH_HTML::td(
714
-                                        EEH_HTML::link(
715
-                                            EE_Admin_Page::add_query_args_and_nonce(
716
-                                                array(
717
-                                                    'action'              => 'activate_payment_method',
718
-                                                    'payment_method_type' => $payment_method->type(),
719
-                                                ),
720
-                                                EE_PAYMENTS_ADMIN_URL
721
-                                            ),
722
-                                            $link_text_and_title,
723
-                                            $link_text_and_title,
724
-                                            'activate_' . $payment_method->slug(),
725
-                                            'espresso-button-green button-primary'
726
-                                        )
727
-                                    )
728
-                                )
729
-                            )
730
-                        ),
731
-                    ),
732
-                    $payment_method
733
-                ),
734
-            )
735
-        );
736
-    }
737
-
738
-
739
-    /**
740
-     * _fine_print
741
-     *
742
-     * @access protected
743
-     * @return EE_Form_Section_HTML
744
-     */
745
-    protected function _fine_print()
746
-    {
747
-        return new EE_Form_Section_HTML(
748
-            EEH_HTML::table(
749
-                EEH_HTML::tr(
750
-                    EEH_HTML::th() .
751
-                    EEH_HTML::td(
752
-                        EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
753
-                    )
754
-                )
755
-            )
756
-        );
757
-    }
758
-
759
-
760
-    /**
761
-     * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
762
-     *
763
-     * @global WP_User $current_user
764
-     */
765
-    protected function _activate_payment_method()
766
-    {
767
-        if (isset($this->_req_data['payment_method_type'])) {
768
-            $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
769
-            // see if one exists
770
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
771
-            $payment_method = EE_Payment_Method_Manager::instance()
772
-                                                       ->activate_a_payment_method_of_type($payment_method_type);
773
-            $this->_redirect_after_action(
774
-                1,
775
-                'Payment Method',
776
-                'activated',
777
-                array('action' => 'default', 'payment_method' => $payment_method->slug())
778
-            );
779
-        } else {
780
-            $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
781
-        }
782
-    }
783
-
784
-
785
-    /**
786
-     * Deactivates the payment method with the specified slug, and redirects.
787
-     */
788
-    protected function _deactivate_payment_method()
789
-    {
790
-        if (isset($this->_req_data['payment_method'])) {
791
-            $payment_method_slug = sanitize_key($this->_req_data['payment_method']);
792
-            // deactivate it
793
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
794
-            $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
795
-            $this->_redirect_after_action(
796
-                $count_updated,
797
-                'Payment Method',
798
-                'deactivated',
799
-                array('action' => 'default', 'payment_method' => $payment_method_slug)
800
-            );
801
-        } else {
802
-            $this->_redirect_after_action(false, 'Payment Method', 'deactivated', array('action' => 'default'));
803
-        }
804
-    }
805
-
806
-
807
-    /**
808
-     * Processes the payment method form that was submitted. This is slightly trickier than usual form
809
-     * processing because we first need to identify WHICH form was processed and which payment method
810
-     * it corresponds to. Once we have done that, we see if the form is valid. If it is, the
811
-     * form's data is saved and we redirect to the default payment methods page, setting the updated payment method
812
-     * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the
813
-     * subsequently called 'headers_sent_func' which is _payment_methods_list)
814
-     *
815
-     * @return void
816
-     */
817
-    protected function _update_payment_method()
818
-    {
819
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
820
-            // ok let's find which gateway form to use based on the form input
821
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
822
-            /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
823
-            $correct_pmt_form_to_use = null;
824
-            $payment_method = null;
825
-            foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) {
826
-                // get the form and simplify it, like what we do when we display it
827
-                $pmt_form = $this->_generate_payment_method_settings_form($payment_method);
828
-                if ($pmt_form->form_data_present_in($this->_req_data)) {
829
-                    $correct_pmt_form_to_use = $pmt_form;
830
-                    break;
831
-                }
832
-            }
833
-            // if we couldn't find the correct payment method type...
834
-            if (! $correct_pmt_form_to_use) {
835
-                EE_Error::add_error(
836
-                    __(
837
-                        "We could not find which payment method type your form submission related to. Please contact support",
838
-                        'event_espresso'
839
-                    ),
840
-                    __FILE__,
841
-                    __FUNCTION__,
842
-                    __LINE__
843
-                );
844
-                $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
845
-            }
846
-            $correct_pmt_form_to_use->receive_form_submission($this->_req_data);
847
-            if ($correct_pmt_form_to_use->is_valid()) {
848
-                $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings');
849
-                if (! $payment_settings_subform instanceof EE_Payment_Method_Form) {
850
-                    throw new EE_Error(
851
-                        sprintf(
852
-                            __(
853
-                                'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.',
854
-                                'event_espresso'
855
-                            ),
856
-                            'payment_method_settings'
857
-                        )
858
-                    );
859
-                }
860
-                $payment_settings_subform->save();
861
-                /** @var $pm EE_Payment_Method */
862
-                $this->_redirect_after_action(
863
-                    true,
864
-                    'Payment Method',
865
-                    'updated',
866
-                    array('action' => 'default', 'payment_method' => $payment_method->slug())
867
-                );
868
-            } else {
869
-                EE_Error::add_error(
870
-                    sprintf(
871
-                        __(
872
-                            'Payment method of type %s was not saved because there were validation errors. They have been marked in the form',
873
-                            'event_espresso'
874
-                        ),
875
-                        $payment_method instanceof EE_Payment_Method ? $payment_method->type_obj()->pretty_name()
876
-                            : __('"(unknown)"', 'event_espresso')
877
-                    ),
878
-                    __FILE__,
879
-                    __FUNCTION__,
880
-                    __LINE__
881
-                );
882
-            }
883
-        }
884
-        return;
885
-    }
886
-
887
-
888
-    /**
889
-     * Displays payment settings (not payment METHOD settings, that's _payment_method_settings)
890
-     * @throws DomainException
891
-     * @throws EE_Error
892
-     * @throws InvalidArgumentException
893
-     * @throws InvalidDataTypeException
894
-     * @throws InvalidInterfaceException
895
-     */
896
-    protected function _payment_settings()
897
-    {
898
-        $form = $this->getPaymentSettingsForm();
899
-        $this->_set_add_edit_form_tags('update_payment_settings');
900
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
901
-        $this->_template_args['admin_page_content'] =  $form->get_html_and_js();
902
-        $this->display_admin_page_with_sidebar();
903
-    }
904
-
905
-
906
-    /**
907
-     *        _update_payment_settings
908
-     *
909
-     * @access protected
910
-     * @return void
911
-     * @throws EE_Error
912
-     * @throws InvalidArgumentException
913
-     * @throws InvalidDataTypeException
914
-     * @throws InvalidInterfaceException
915
-     */
916
-    protected function _update_payment_settings()
917
-    {
918
-        $form = $this->getPaymentSettingsForm();
919
-        if ($form->was_submitted($this->_req_data)) {
920
-            $form->receive_form_submission($this->_req_data);
921
-            if ($form->is_valid()) {
922
-                /**
923
-                 * @var $reg_config EE_Registration_Config
924
-                 */
925
-                $loader = LoaderFactory::getLoader();
926
-                $reg_config = $loader->getShared('EE_Registration_Config');
927
-                $valid_data = $form->valid_data();
928
-                $reg_config->show_pending_payment_options = $valid_data['show_pending_payment_options'];
929
-                $reg_config->gateway_log_lifespan = $valid_data['gateway_log_lifespan'];
930
-            }
931
-        }
932
-        EE_Registry::instance()->CFG = apply_filters(
933
-            'FHEE__Payments_Admin_Page___update_payment_settings__CFG',
934
-            EE_Registry::instance()->CFG
935
-        );
936
-
937
-        $cfg =  EE_Registry::instance()->CFG ;
938
-
939
-        $what = __('Payment Settings', 'event_espresso');
940
-        $success = $this->_update_espresso_configuration(
941
-            $what,
942
-            EE_Registry::instance()->CFG,
943
-            __FILE__,
944
-            __FUNCTION__,
945
-            __LINE__
946
-        );
947
-        $this->_redirect_after_action(
948
-            $success,
949
-            $what,
950
-            __('updated', 'event_espresso'),
951
-            array('action' => 'payment_settings')
952
-        );
953
-    }
954
-
955
-
956
-    /**
957
-     * Gets the form used for updating payment settings
958
-     *
959
-     * @return EE_Form_Section_Proper
960
-     * @throws EE_Error
961
-     * @throws InvalidArgumentException
962
-     * @throws InvalidDataTypeException
963
-     * @throws InvalidInterfaceException
964
-     */
965
-    protected function getPaymentSettingsForm()
966
-    {
967
-        /**
968
-         * @var $reg_config EE_Registration_Config
969
-         */
970
-        $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
971
-        return new EE_Form_Section_Proper(
972
-            array(
973
-                'name' => 'payment-settings',
974
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
975
-                'subsections' => array(
976
-                    'show_pending_payment_options' => new EE_Yes_No_Input(
977
-                        array(
978
-                            'html_name' => 'show_pending_payment_options',
979
-                            'default' => $reg_config->show_pending_payment_options,
980
-                            'html_help_text' => esc_html__(
981
-                                "If a payment is marked as 'Pending Payment', or if payment is deferred (ie, an offline gateway like Check, Bank, or Invoice is used), then give registrants the option to retry payment. ",
982
-                                'event_espresso'
983
-                            )
984
-                        )
985
-                    ),
986
-                    'gateway_log_lifespan' => new EE_Select_Input(
987
-                        $reg_config->gatewayLogLifespanOptions(),
988
-                        array(
989
-                            'html_label_text' => esc_html__('Gateway Logs Lifespan', 'event_espresso'),
990
-                            'html_help_text' => esc_html__('If issues arise with payments being made through a payment gateway, it\'s helpful to log non-sensitive communications with the payment gateway. But it\'s a security responsibility, so it\'s a good idea to not keep them for any longer than necessary.', 'event_espresso'),
991
-                            'default' => $reg_config->gateway_log_lifespan,
992
-                        )
993
-                    )
994
-                )
995
-            )
996
-        );
997
-    }
998
-
999
-
1000
-    protected function _payment_log_overview_list_table()
1001
-    {
1002
-        $this->display_admin_list_table_page_with_sidebar();
1003
-    }
1004
-
1005
-
1006
-    protected function _set_list_table_views_payment_log()
1007
-    {
1008
-        $this->_views = array(
1009
-            'all' => array(
1010
-                'slug'  => 'all',
1011
-                'label' => __('View All Logs', 'event_espresso'),
1012
-                'count' => 0,
1013
-            ),
1014
-        );
1015
-    }
1016
-
1017
-
1018
-    /**
1019
-     * @param int  $per_page
1020
-     * @param int  $current_page
1021
-     * @param bool $count
1022
-     * @return array
1023
-     */
1024
-    public function get_payment_logs($per_page = 50, $current_page = 0, $count = false)
1025
-    {
1026
-        EE_Registry::instance()->load_model('Change_Log');
1027
-        // we may need to do multiple queries (joining differently), so we actually wan tan array of query params
1028
-        $query_params = array(array('LOG_type' => EEM_Change_Log::type_gateway));
1029
-        // check if they've selected a specific payment method
1030
-        if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
1031
-            $query_params[0]['OR*pm_or_pay_pm'] = array(
1032
-                'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'],
1033
-                'Payment_Method.PMD_ID'         => $this->_req_data['_payment_method'],
1034
-            );
1035
-        }
1036
-        // take into account search
1037
-        if (isset($this->_req_data['s']) && $this->_req_data['s']) {
1038
-            $similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%');
1039
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
1040
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
1041
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
1042
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_name'] = $similarity_string;
1043
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name'] = $similarity_string;
1044
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_type'] = $similarity_string;
1045
-            $query_params[0]['OR*s']['LOG_message'] = $similarity_string;
1046
-            $query_params[0]['OR*s']['Payment_Method.PMD_name'] = $similarity_string;
1047
-            $query_params[0]['OR*s']['Payment_Method.PMD_admin_name'] = $similarity_string;
1048
-            $query_params[0]['OR*s']['Payment_Method.PMD_type'] = $similarity_string;
1049
-            $query_params[0]['OR*s']['LOG_message'] = $similarity_string;
1050
-        }
1051
-        if (isset($this->_req_data['payment-filter-start-date'])
1052
-            && isset($this->_req_data['payment-filter-end-date'])
1053
-        ) {
1054
-            // add date
1055
-            $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
1056
-            $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
1057
-            // make sure our timestamps start and end right at the boundaries for each day
1058
-            $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
1059
-            $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
1060
-            // convert to timestamps
1061
-            $start_date = strtotime($start_date);
1062
-            $end_date = strtotime($end_date);
1063
-            // makes sure start date is the lowest value and vice versa
1064
-            $start_date = min($start_date, $end_date);
1065
-            $end_date = max($start_date, $end_date);
1066
-            // convert for query
1067
-            $start_date = EEM_Change_Log::instance()
1068
-                                        ->convert_datetime_for_query(
1069
-                                            'LOG_time',
1070
-                                            date('Y-m-d H:i:s', $start_date),
1071
-                                            'Y-m-d H:i:s'
1072
-                                        );
1073
-            $end_date = EEM_Change_Log::instance()
1074
-                                      ->convert_datetime_for_query(
1075
-                                          'LOG_time',
1076
-                                          date('Y-m-d H:i:s', $end_date),
1077
-                                          'Y-m-d H:i:s'
1078
-                                      );
1079
-            $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date));
1080
-        }
1081
-        if ($count) {
1082
-            return EEM_Change_Log::instance()->count($query_params);
1083
-        }
1084
-        if (isset($this->_req_data['order'])) {
1085
-            $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
1086
-                : 'DESC';
1087
-            $query_params['order_by'] = array('LOG_time' => $sort);
1088
-        } else {
1089
-            $query_params['order_by'] = array('LOG_time' => 'DESC');
1090
-        }
1091
-        $offset = ($current_page - 1) * $per_page;
1092
-        if (! isset($this->_req_data['download_results'])) {
1093
-            $query_params['limit'] = array($offset, $per_page);
1094
-        }
1095
-        // now they've requested to instead just download the file instead of viewing it.
1096
-        if (isset($this->_req_data['download_results'])) {
1097
-            $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
1098
-            header('Content-Disposition: attachment');
1099
-            header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url()));
1100
-            echo "<h1>Payment Logs for " . site_url() . "</h1>";
1101
-            echo "<h3>Query:</h3>";
1102
-            var_dump($query_params);
1103
-            echo "<h3>Results:</h3>";
1104
-            var_dump($wpdb_results);
1105
-            die;
1106
-        }
1107
-        $results = EEM_Change_Log::instance()->get_all($query_params);
1108
-        return $results;
1109
-    }
1110
-
1111
-
1112
-    /**
1113
-     * Used by usort to RE-sort log query results, because we lose the ordering
1114
-     * because we're possibly combining the results from two queries
1115
-     *
1116
-     * @param EE_Change_Log $logA
1117
-     * @param EE_Change_Log $logB
1118
-     * @return int
1119
-     */
1120
-    protected function _sort_logs_again($logA, $logB)
1121
-    {
1122
-        $timeA = $logA->get_raw('LOG_time');
1123
-        $timeB = $logB->get_raw('LOG_time');
1124
-        if ($timeA == $timeB) {
1125
-            return 0;
1126
-        }
1127
-        $comparison = $timeA < $timeB ? -1 : 1;
1128
-        if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
1129
-            return $comparison * -1;
1130
-        } else {
1131
-            return $comparison;
1132
-        }
1133
-    }
1134
-
1135
-
1136
-    protected function _payment_log_details()
1137
-    {
1138
-        EE_Registry::instance()->load_model('Change_Log');
1139
-        /** @var $payment_log EE_Change_Log */
1140
-        $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
1141
-        $payment_method = null;
1142
-        $transaction = null;
1143
-        if ($payment_log instanceof EE_Change_Log) {
1144
-            if ($payment_log->object() instanceof EE_Payment) {
1145
-                $payment_method = $payment_log->object()->payment_method();
1146
-                $transaction = $payment_log->object()->transaction();
1147
-            } elseif ($payment_log->object() instanceof EE_Payment_Method) {
1148
-                $payment_method = $payment_log->object();
1149
-            } elseif ($payment_log->object() instanceof EE_Transaction) {
1150
-                $transaction = $payment_log->object();
1151
-                $payment_method = $transaction->payment_method();
1152
-            }
1153
-        }
1154
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1155
-            EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
1156
-            array(
1157
-                'payment_log'    => $payment_log,
1158
-                'payment_method' => $payment_method,
1159
-                'transaction'    => $transaction,
1160
-            ),
1161
-            true
1162
-        );
1163
-        $this->display_admin_page_with_sidebar();
1164
-    }
19
+	/**
20
+	 * Variables used for when we're re-sorting the logs results, in case
21
+	 * we needed to do two queries and we need to resort
22
+	 *
23
+	 * @var string
24
+	 */
25
+	private $_sort_logs_again_direction;
26
+
27
+
28
+	/**
29
+	 * @Constructor
30
+	 * @access public
31
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
32
+	 * @throws EE_Error
33
+	 * @throws InvalidArgumentException
34
+	 * @throws InvalidDataTypeException
35
+	 * @throws InvalidInterfaceException
36
+	 * @throws ReflectionException
37
+	 */
38
+	public function __construct($routing = true)
39
+	{
40
+		parent::__construct($routing);
41
+	}
42
+
43
+
44
+	protected function _init_page_props()
45
+	{
46
+		$this->page_slug = EE_PAYMENTS_PG_SLUG;
47
+		$this->page_label = __('Payment Methods', 'event_espresso');
48
+		$this->_admin_base_url = EE_PAYMENTS_ADMIN_URL;
49
+		$this->_admin_base_path = EE_PAYMENTS_ADMIN;
50
+	}
51
+
52
+
53
+	protected function _ajax_hooks()
54
+	{
55
+		// todo: all hooks for ajax goes here.
56
+	}
57
+
58
+
59
+	protected function _define_page_props()
60
+	{
61
+		$this->_admin_page_title = $this->page_label;
62
+		$this->_labels = array(
63
+			'publishbox' => __('Update Settings', 'event_espresso'),
64
+		);
65
+	}
66
+
67
+
68
+	protected function _set_page_routes()
69
+	{
70
+		/**
71
+		 * note that with payment method capabilities, although we've implemented
72
+		 * capability mapping which will be used for accessing payment methods owned by
73
+		 * other users.  This is not fully implemented yet in the payment method ui.
74
+		 * Currently only the "plural" caps are in active use.
75
+		 * When cap mapping is implemented, some routes will need to use the singular form of
76
+		 * capability method and also include the $id of the payment method for the route.
77
+		 **/
78
+		$this->_page_routes = array(
79
+			'default'                   => array(
80
+				'func'       => '_payment_methods_list',
81
+				'capability' => 'ee_edit_payment_methods',
82
+			),
83
+			'payment_settings'          => array(
84
+				'func'       => '_payment_settings',
85
+				'capability' => 'ee_manage_gateways',
86
+			),
87
+			'activate_payment_method'   => array(
88
+				'func'       => '_activate_payment_method',
89
+				'noheader'   => true,
90
+				'capability' => 'ee_edit_payment_methods',
91
+			),
92
+			'deactivate_payment_method' => array(
93
+				'func'       => '_deactivate_payment_method',
94
+				'noheader'   => true,
95
+				'capability' => 'ee_delete_payment_methods',
96
+			),
97
+			'update_payment_method'     => array(
98
+				'func'               => '_update_payment_method',
99
+				'noheader'           => true,
100
+				'headers_sent_route' => 'default',
101
+				'capability'         => 'ee_edit_payment_methods',
102
+			),
103
+			'update_payment_settings'   => array(
104
+				'func'       => '_update_payment_settings',
105
+				'noheader'   => true,
106
+				'capability' => 'ee_manage_gateways',
107
+			),
108
+			'payment_log'               => array(
109
+				'func'       => '_payment_log_overview_list_table',
110
+				'capability' => 'ee_read_payment_methods',
111
+			),
112
+			'payment_log_details'       => array(
113
+				'func'       => '_payment_log_details',
114
+				'capability' => 'ee_read_payment_methods',
115
+			),
116
+		);
117
+	}
118
+
119
+
120
+	protected function _set_page_config()
121
+	{
122
+		$payment_method_list_config = array(
123
+			'nav'           => array(
124
+				'label' => __('Payment Methods', 'event_espresso'),
125
+				'order' => 10,
126
+			),
127
+			'metaboxes'     => $this->_default_espresso_metaboxes,
128
+			'help_tabs'     => array_merge(
129
+				array(
130
+					'payment_methods_overview_help_tab' => array(
131
+						'title'    => __('Payment Methods Overview', 'event_espresso'),
132
+						'filename' => 'payment_methods_overview',
133
+					),
134
+				),
135
+				$this->_add_payment_method_help_tabs()
136
+			),
137
+			'help_tour'     => array('Payment_Methods_Selection_Help_Tour'),
138
+			'require_nonce' => false,
139
+		);
140
+		$this->_page_config = array(
141
+			'default'          => $payment_method_list_config,
142
+			'payment_settings' => array(
143
+				'nav'           => array(
144
+					'label' => __('Settings', 'event_espresso'),
145
+					'order' => 20,
146
+				),
147
+				'help_tabs'     => array(
148
+					'payment_methods_settings_help_tab' => array(
149
+						'title'    => __('Payment Method Settings', 'event_espresso'),
150
+						'filename' => 'payment_methods_settings',
151
+					),
152
+				),
153
+				// 'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ),
154
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
155
+				'require_nonce' => false,
156
+			),
157
+			'payment_log'      => array(
158
+				'nav'           => array(
159
+					'label' => __("Logs", 'event_espresso'),
160
+					'order' => 30,
161
+				),
162
+				'list_table'    => 'Payment_Log_Admin_List_Table',
163
+				'metaboxes'     => $this->_default_espresso_metaboxes,
164
+				'require_nonce' => false,
165
+			),
166
+		);
167
+	}
168
+
169
+
170
+	/**
171
+	 * @return array
172
+	 * @throws DomainException
173
+	 * @throws EE_Error
174
+	 * @throws InvalidArgumentException
175
+	 * @throws InvalidDataTypeException
176
+	 * @throws InvalidInterfaceException
177
+	 * @throws ReflectionException
178
+	 */
179
+	protected function _add_payment_method_help_tabs()
180
+	{
181
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
182
+		$payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types();
183
+		$all_pmt_help_tabs_config = array();
184
+		foreach ($payment_method_types as $payment_method_type) {
185
+			if (! EE_Registry::instance()->CAP->current_user_can(
186
+				$payment_method_type->cap_name(),
187
+				'specific_payment_method_type_access'
188
+			)
189
+			) {
190
+				continue;
191
+			}
192
+			foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
193
+				$template_args = isset($config['template_args']) ? $config['template_args'] : array();
194
+				$template_args['admin_page_obj'] = $this;
195
+				$all_pmt_help_tabs_config[ $help_tab_name ] = array(
196
+					'title'   => $config['title'],
197
+					'content' => EEH_Template::display_template(
198
+						$payment_method_type->file_folder() . 'help_tabs' . DS . $config['filename'] . '.help_tab.php',
199
+						$template_args,
200
+						true
201
+					),
202
+				);
203
+			}
204
+		}
205
+		return $all_pmt_help_tabs_config;
206
+	}
207
+
208
+
209
+	// none of the below group are currently used for Gateway Settings
210
+	protected function _add_screen_options()
211
+	{
212
+	}
213
+
214
+
215
+	protected function _add_feature_pointers()
216
+	{
217
+	}
218
+
219
+
220
+	public function admin_init()
221
+	{
222
+	}
223
+
224
+
225
+	public function admin_notices()
226
+	{
227
+	}
228
+
229
+
230
+	public function admin_footer_scripts()
231
+	{
232
+	}
233
+
234
+
235
+	public function load_scripts_styles()
236
+	{
237
+		wp_enqueue_script('ee_admin_js');
238
+		wp_enqueue_script('ee-text-links');
239
+		wp_enqueue_script(
240
+			'espresso_payments',
241
+			EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js',
242
+			array('espresso-ui-theme', 'ee-datepicker'),
243
+			EVENT_ESPRESSO_VERSION,
244
+			true
245
+		);
246
+	}
247
+
248
+
249
+	public function load_scripts_styles_default()
250
+	{
251
+		// styles
252
+		wp_register_style(
253
+			'espresso_payments',
254
+			EE_PAYMENTS_ASSETS_URL . 'ee-payments.css',
255
+			array(),
256
+			EVENT_ESPRESSO_VERSION
257
+		);
258
+		wp_enqueue_style('espresso_payments');
259
+		wp_enqueue_style('ee-text-links');
260
+		// scripts
261
+	}
262
+
263
+
264
+	protected function _payment_methods_list()
265
+	{
266
+		/**
267
+		 * first let's ensure payment methods have been setup. We do this here because when people activate a
268
+		 * payment method for the first time (as an addon), it may not setup its capabilities or get registered
269
+		 * correctly due to the loading process.  However, people MUST setup the details for the payment method so its
270
+		 * safe to do a recheck here.
271
+		 */
272
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
273
+		EEM_Payment_Method::instance()->verify_button_urls();
274
+		// setup tabs, one for each payment method type
275
+		$tabs = array();
276
+		$payment_methods = array();
277
+		foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
278
+			// we don't want to show admin-only PMTs for now
279
+			if ($pmt_obj instanceof EE_PMT_Admin_Only) {
280
+				continue;
281
+			}
282
+			// check access
283
+			if (! EE_Registry::instance()->CAP->current_user_can(
284
+				$pmt_obj->cap_name(),
285
+				'specific_payment_method_type_access'
286
+			)
287
+			) {
288
+				continue;
289
+			}
290
+			// check for any active pms of that type
291
+			$payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
292
+			if (! $payment_method instanceof EE_Payment_Method) {
293
+				$payment_method = EE_Payment_Method::new_instance(
294
+					array(
295
+						'PMD_slug'       => sanitize_key($pmt_obj->system_name()),
296
+						'PMD_type'       => $pmt_obj->system_name(),
297
+						'PMD_name'       => $pmt_obj->pretty_name(),
298
+						'PMD_admin_name' => $pmt_obj->pretty_name(),
299
+					)
300
+				);
301
+			}
302
+			$payment_methods[ $payment_method->slug() ] = $payment_method;
303
+		}
304
+		$payment_methods = apply_filters(
305
+			'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
306
+			$payment_methods
307
+		);
308
+		foreach ($payment_methods as $payment_method) {
309
+			if ($payment_method instanceof EE_Payment_Method) {
310
+				add_meta_box(
311
+					// html id
312
+					'espresso_' . $payment_method->slug() . '_payment_settings',
313
+					// title
314
+					sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
315
+					// callback
316
+					array($this, 'payment_method_settings_meta_box'),
317
+					// post type
318
+					null,
319
+					// context
320
+					'normal',
321
+					// priority
322
+					'default',
323
+					// callback args
324
+					array('payment_method' => $payment_method)
325
+				);
326
+				// setup for tabbed content
327
+				$tabs[ $payment_method->slug() ] = array(
328
+					'label' => $payment_method->admin_name(),
329
+					'class' => $payment_method->active() ? 'gateway-active' : '',
330
+					'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
331
+					'title' => __('Modify this Payment Method', 'event_espresso'),
332
+					'slug'  => $payment_method->slug(),
333
+				);
334
+			}
335
+		}
336
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links(
337
+			$tabs,
338
+			'payment_method_links',
339
+			'|',
340
+			$this->_get_active_payment_method_slug()
341
+		);
342
+		$this->display_admin_page_with_sidebar();
343
+	}
344
+
345
+
346
+	/**
347
+	 *   _get_active_payment_method_slug
348
+	 *
349
+	 * @return string
350
+	 */
351
+	protected function _get_active_payment_method_slug()
352
+	{
353
+		$payment_method_slug = false;
354
+		// decide which payment method tab to open first, as dictated by the request's 'payment_method'
355
+		if (isset($this->_req_data['payment_method'])) {
356
+			// if they provided the current payment method, use it
357
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
358
+		}
359
+		$payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
360
+		// if that didn't work or wasn't provided, find another way to select the current pm
361
+		if (! $this->_verify_payment_method($payment_method)) {
362
+			// like, looking for an active one
363
+			$payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
364
+			// test that one as well
365
+			if ($this->_verify_payment_method($payment_method)) {
366
+				$payment_method_slug = $payment_method->slug();
367
+			} else {
368
+				$payment_method_slug = 'paypal_standard';
369
+			}
370
+		}
371
+		return $payment_method_slug;
372
+	}
373
+
374
+
375
+	/**
376
+	 *    payment_method_settings_meta_box
377
+	 *    returns TRUE if the passed payment method is properly constructed and the logged in user has the correct
378
+	 *    capabilities to access it
379
+	 *
380
+	 * @param EE_Payment_Method $payment_method
381
+	 * @return boolean
382
+	 */
383
+	protected function _verify_payment_method($payment_method)
384
+	{
385
+		if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base
386
+			&& EE_Registry::instance()->CAP->current_user_can(
387
+				$payment_method->type_obj()->cap_name(),
388
+				'specific_payment_method_type_access'
389
+			)
390
+		) {
391
+			return true;
392
+		}
393
+		return false;
394
+	}
395
+
396
+
397
+	/**
398
+	 *    payment_method_settings_meta_box
399
+	 *
400
+	 * @param NULL  $post_obj_which_is_null is an object containing the current post (as a $post object)
401
+	 * @param array $metabox                is an array with metabox id, title, callback, and args elements. the value
402
+	 *                                      at 'args' has key 'payment_method', as set within _payment_methods_list
403
+	 * @return string
404
+	 * @throws EE_Error
405
+	 */
406
+	public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox)
407
+	{
408
+		$payment_method = isset($metabox['args'], $metabox['args']['payment_method'])
409
+			? $metabox['args']['payment_method'] : null;
410
+		if (! $payment_method instanceof EE_Payment_Method) {
411
+			throw new EE_Error(
412
+				sprintf(
413
+					__(
414
+						'Payment method metabox setup incorrectly. No Payment method object was supplied',
415
+						'event_espresso'
416
+					)
417
+				)
418
+			);
419
+		}
420
+		$payment_method_scopes = $payment_method->active();
421
+		// if the payment method really exists show its form, otherwise the activation template
422
+		if ($payment_method->ID() && ! empty($payment_method_scopes)) {
423
+			$form = $this->_generate_payment_method_settings_form($payment_method);
424
+			if ($form->form_data_present_in($this->_req_data)) {
425
+				$form->receive_form_submission($this->_req_data);
426
+			}
427
+			echo $form->form_open() . $form->get_html_and_js() . $form->form_close();
428
+		} else {
429
+			echo $this->_activate_payment_method_button($payment_method)->get_html_and_js();
430
+		}
431
+	}
432
+
433
+
434
+	/**
435
+	 * Gets the form for all the settings related to this payment method type
436
+	 *
437
+	 * @access protected
438
+	 * @param EE_Payment_Method $payment_method
439
+	 * @return EE_Form_Section_Proper
440
+	 */
441
+	protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method)
442
+	{
443
+		if (! $payment_method instanceof EE_Payment_Method) {
444
+			return new EE_Form_Section_Proper();
445
+		}
446
+		return new EE_Form_Section_Proper(
447
+			array(
448
+				'name'            => $payment_method->slug() . '_settings_form',
449
+				'html_id'         => $payment_method->slug() . '_settings_form',
450
+				'action'          => EE_Admin_Page::add_query_args_and_nonce(
451
+					array(
452
+						'action'         => 'update_payment_method',
453
+						'payment_method' => $payment_method->slug(),
454
+					),
455
+					EE_PAYMENTS_ADMIN_URL
456
+				),
457
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
458
+				'subsections'     => apply_filters(
459
+					'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
460
+					array(
461
+						'pci_dss_compliance'      => $this->_pci_dss_compliance($payment_method),
462
+						'currency_support'        => $this->_currency_support($payment_method),
463
+						'payment_method_settings' => $this->_payment_method_settings($payment_method),
464
+						'update'                  => $this->_update_payment_method_button($payment_method),
465
+						'deactivate'              => $this->_deactivate_payment_method_button($payment_method),
466
+						'fine_print'              => $this->_fine_print(),
467
+					),
468
+					$payment_method
469
+				),
470
+			)
471
+		);
472
+	}
473
+
474
+
475
+	/**
476
+	 * _pci_dss_compliance
477
+	 *
478
+	 * @access protected
479
+	 * @param EE_Payment_Method $payment_method
480
+	 * @return EE_Form_Section_Proper
481
+	 */
482
+	protected function _pci_dss_compliance(EE_Payment_Method $payment_method)
483
+	{
484
+		if ($payment_method->type_obj()->requires_https()) {
485
+			return new EE_Form_Section_HTML(
486
+				EEH_HTML::table(
487
+					EEH_HTML::tr(
488
+						EEH_HTML::th(
489
+							EEH_HTML::label(
490
+								EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
491
+							)
492
+						) .
493
+						EEH_HTML::td(
494
+							EEH_HTML::strong(
495
+								__(
496
+									'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.',
497
+									'event_espresso'
498
+								)
499
+							)
500
+							.
501
+							EEH_HTML::br()
502
+							.
503
+							__('Learn more about ', 'event_espresso')
504
+							. EEH_HTML::link(
505
+								'https://www.pcisecuritystandards.org/merchants/index.php',
506
+								__('PCI DSS compliance', 'event_espresso')
507
+							)
508
+						)
509
+					)
510
+				)
511
+			);
512
+		} else {
513
+			return new EE_Form_Section_HTML('');
514
+		}
515
+	}
516
+
517
+
518
+	/**
519
+	 * _currency_support
520
+	 *
521
+	 * @access protected
522
+	 * @param EE_Payment_Method $payment_method
523
+	 * @return EE_Form_Section_Proper
524
+	 */
525
+	protected function _currency_support(EE_Payment_Method $payment_method)
526
+	{
527
+		if (! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
528
+			return new EE_Form_Section_HTML(
529
+				EEH_HTML::table(
530
+					EEH_HTML::tr(
531
+						EEH_HTML::th(
532
+							EEH_HTML::label(
533
+								EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
534
+							)
535
+						) .
536
+						EEH_HTML::td(
537
+							EEH_HTML::strong(
538
+								sprintf(
539
+									__(
540
+										'This payment method does not support the currency set on your site (%1$s). Please activate a different payment method or change your site\'s country and associated currency.',
541
+										'event_espresso'
542
+									),
543
+									EE_Config::instance()->currency->code
544
+								)
545
+							)
546
+						)
547
+					)
548
+				)
549
+			);
550
+		} else {
551
+			return new EE_Form_Section_HTML('');
552
+		}
553
+	}
554
+
555
+
556
+	/**
557
+	 * _update_payment_method_button
558
+	 *
559
+	 * @access protected
560
+	 * @param EE_Payment_Method $payment_method
561
+	 * @return EE_Payment_Method_Form
562
+	 */
563
+	protected function _payment_method_settings(EE_Payment_Method $payment_method)
564
+	{
565
+		// modify the form so we only have/show fields that will be implemented for this version
566
+		return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
567
+	}
568
+
569
+
570
+	/**
571
+	 * Simplifies the form to merely reproduce 4.1's gateway settings functionality
572
+	 *
573
+	 * @param EE_Form_Section_Proper $form_section
574
+	 * @param string                 $payment_method_name
575
+	 * @return EE_Payment_Method_Form
576
+	 * @throws EE_Error
577
+	 */
578
+	protected function _simplify_form($form_section, $payment_method_name = '')
579
+	{
580
+		if ($form_section instanceof EE_Payment_Method_Form) {
581
+			$form_section->exclude(
582
+				array(
583
+					'PMD_type', // dont want them changing the type
584
+					'PMD_slug', // or the slug (probably never)
585
+					'PMD_wp_user', // or the user's ID
586
+					'Currency' // or the currency, until the rest of EE supports simultaneous currencies
587
+				)
588
+			);
589
+			return $form_section;
590
+		} else {
591
+			throw new EE_Error(
592
+				sprintf(
593
+					__(
594
+						'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.',
595
+						'event_espresso'
596
+					),
597
+					$payment_method_name
598
+				)
599
+			);
600
+		}
601
+	}
602
+
603
+
604
+	/**
605
+	 * _update_payment_method_button
606
+	 *
607
+	 * @access protected
608
+	 * @param EE_Payment_Method $payment_method
609
+	 * @return EE_Form_Section_HTML
610
+	 */
611
+	protected function _update_payment_method_button(EE_Payment_Method $payment_method)
612
+	{
613
+		$update_button = new EE_Submit_Input(
614
+			array(
615
+				'name'       => 'submit',
616
+				'html_id'    => 'save_' . $payment_method->slug() . '_settings',
617
+				'default'    => sprintf(
618
+					__('Update %s Payment Settings', 'event_espresso'),
619
+					$payment_method->admin_name()
620
+				),
621
+				'html_label' => EEH_HTML::nbsp(),
622
+			)
623
+		);
624
+		return new EE_Form_Section_HTML(
625
+			EEH_HTML::table(
626
+				EEH_HTML::no_row(EEH_HTML::br(2)) .
627
+				EEH_HTML::tr(
628
+					EEH_HTML::th(__('Update Settings', 'event_espresso')) .
629
+					EEH_HTML::td(
630
+						$update_button->get_html_for_input()
631
+					)
632
+				)
633
+			)
634
+		);
635
+	}
636
+
637
+
638
+	/**
639
+	 * _deactivate_payment_method_button
640
+	 *
641
+	 * @access protected
642
+	 * @param EE_Payment_Method $payment_method
643
+	 * @return EE_Form_Section_Proper
644
+	 */
645
+	protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method)
646
+	{
647
+		$link_text_and_title = sprintf(
648
+			__('Deactivate %1$s Payments?', 'event_espresso'),
649
+			$payment_method->admin_name()
650
+		);
651
+		return new EE_Form_Section_HTML(
652
+			EEH_HTML::table(
653
+				EEH_HTML::tr(
654
+					EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')) .
655
+					EEH_HTML::td(
656
+						EEH_HTML::link(
657
+							EE_Admin_Page::add_query_args_and_nonce(
658
+								array(
659
+									'action'         => 'deactivate_payment_method',
660
+									'payment_method' => $payment_method->slug(),
661
+								),
662
+								EE_PAYMENTS_ADMIN_URL
663
+							),
664
+							$link_text_and_title,
665
+							$link_text_and_title,
666
+							'deactivate_' . $payment_method->slug(),
667
+							'espresso-button button-secondary'
668
+						)
669
+					)
670
+				)
671
+			)
672
+		);
673
+	}
674
+
675
+
676
+	/**
677
+	 * _activate_payment_method_button
678
+	 *
679
+	 * @access protected
680
+	 * @param EE_Payment_Method $payment_method
681
+	 * @return EE_Form_Section_Proper
682
+	 */
683
+	protected function _activate_payment_method_button(EE_Payment_Method $payment_method)
684
+	{
685
+		$link_text_and_title = sprintf(
686
+			__('Activate %1$s Payment Method?', 'event_espresso'),
687
+			$payment_method->admin_name()
688
+		);
689
+		return new EE_Form_Section_Proper(
690
+			array(
691
+				'name'            => 'activate_' . $payment_method->slug() . '_settings_form',
692
+				'html_id'         => 'activate_' . $payment_method->slug() . '_settings_form',
693
+				'action'          => '#',
694
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
695
+				'subsections'     => apply_filters(
696
+					'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections',
697
+					array(
698
+						new EE_Form_Section_HTML(
699
+							EEH_HTML::table(
700
+								EEH_HTML::tr(
701
+									EEH_HTML::td(
702
+										$payment_method->type_obj()->introductory_html(),
703
+										'',
704
+										'',
705
+										'',
706
+										'colspan="2"'
707
+									)
708
+								) .
709
+								EEH_HTML::tr(
710
+									EEH_HTML::th(
711
+										EEH_HTML::label(__('Click to Activate ', 'event_espresso'))
712
+									) .
713
+									EEH_HTML::td(
714
+										EEH_HTML::link(
715
+											EE_Admin_Page::add_query_args_and_nonce(
716
+												array(
717
+													'action'              => 'activate_payment_method',
718
+													'payment_method_type' => $payment_method->type(),
719
+												),
720
+												EE_PAYMENTS_ADMIN_URL
721
+											),
722
+											$link_text_and_title,
723
+											$link_text_and_title,
724
+											'activate_' . $payment_method->slug(),
725
+											'espresso-button-green button-primary'
726
+										)
727
+									)
728
+								)
729
+							)
730
+						),
731
+					),
732
+					$payment_method
733
+				),
734
+			)
735
+		);
736
+	}
737
+
738
+
739
+	/**
740
+	 * _fine_print
741
+	 *
742
+	 * @access protected
743
+	 * @return EE_Form_Section_HTML
744
+	 */
745
+	protected function _fine_print()
746
+	{
747
+		return new EE_Form_Section_HTML(
748
+			EEH_HTML::table(
749
+				EEH_HTML::tr(
750
+					EEH_HTML::th() .
751
+					EEH_HTML::td(
752
+						EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
753
+					)
754
+				)
755
+			)
756
+		);
757
+	}
758
+
759
+
760
+	/**
761
+	 * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
762
+	 *
763
+	 * @global WP_User $current_user
764
+	 */
765
+	protected function _activate_payment_method()
766
+	{
767
+		if (isset($this->_req_data['payment_method_type'])) {
768
+			$payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
769
+			// see if one exists
770
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
771
+			$payment_method = EE_Payment_Method_Manager::instance()
772
+													   ->activate_a_payment_method_of_type($payment_method_type);
773
+			$this->_redirect_after_action(
774
+				1,
775
+				'Payment Method',
776
+				'activated',
777
+				array('action' => 'default', 'payment_method' => $payment_method->slug())
778
+			);
779
+		} else {
780
+			$this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
781
+		}
782
+	}
783
+
784
+
785
+	/**
786
+	 * Deactivates the payment method with the specified slug, and redirects.
787
+	 */
788
+	protected function _deactivate_payment_method()
789
+	{
790
+		if (isset($this->_req_data['payment_method'])) {
791
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
792
+			// deactivate it
793
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
794
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
795
+			$this->_redirect_after_action(
796
+				$count_updated,
797
+				'Payment Method',
798
+				'deactivated',
799
+				array('action' => 'default', 'payment_method' => $payment_method_slug)
800
+			);
801
+		} else {
802
+			$this->_redirect_after_action(false, 'Payment Method', 'deactivated', array('action' => 'default'));
803
+		}
804
+	}
805
+
806
+
807
+	/**
808
+	 * Processes the payment method form that was submitted. This is slightly trickier than usual form
809
+	 * processing because we first need to identify WHICH form was processed and which payment method
810
+	 * it corresponds to. Once we have done that, we see if the form is valid. If it is, the
811
+	 * form's data is saved and we redirect to the default payment methods page, setting the updated payment method
812
+	 * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the
813
+	 * subsequently called 'headers_sent_func' which is _payment_methods_list)
814
+	 *
815
+	 * @return void
816
+	 */
817
+	protected function _update_payment_method()
818
+	{
819
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
820
+			// ok let's find which gateway form to use based on the form input
821
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
822
+			/** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
823
+			$correct_pmt_form_to_use = null;
824
+			$payment_method = null;
825
+			foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) {
826
+				// get the form and simplify it, like what we do when we display it
827
+				$pmt_form = $this->_generate_payment_method_settings_form($payment_method);
828
+				if ($pmt_form->form_data_present_in($this->_req_data)) {
829
+					$correct_pmt_form_to_use = $pmt_form;
830
+					break;
831
+				}
832
+			}
833
+			// if we couldn't find the correct payment method type...
834
+			if (! $correct_pmt_form_to_use) {
835
+				EE_Error::add_error(
836
+					__(
837
+						"We could not find which payment method type your form submission related to. Please contact support",
838
+						'event_espresso'
839
+					),
840
+					__FILE__,
841
+					__FUNCTION__,
842
+					__LINE__
843
+				);
844
+				$this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
845
+			}
846
+			$correct_pmt_form_to_use->receive_form_submission($this->_req_data);
847
+			if ($correct_pmt_form_to_use->is_valid()) {
848
+				$payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings');
849
+				if (! $payment_settings_subform instanceof EE_Payment_Method_Form) {
850
+					throw new EE_Error(
851
+						sprintf(
852
+							__(
853
+								'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.',
854
+								'event_espresso'
855
+							),
856
+							'payment_method_settings'
857
+						)
858
+					);
859
+				}
860
+				$payment_settings_subform->save();
861
+				/** @var $pm EE_Payment_Method */
862
+				$this->_redirect_after_action(
863
+					true,
864
+					'Payment Method',
865
+					'updated',
866
+					array('action' => 'default', 'payment_method' => $payment_method->slug())
867
+				);
868
+			} else {
869
+				EE_Error::add_error(
870
+					sprintf(
871
+						__(
872
+							'Payment method of type %s was not saved because there were validation errors. They have been marked in the form',
873
+							'event_espresso'
874
+						),
875
+						$payment_method instanceof EE_Payment_Method ? $payment_method->type_obj()->pretty_name()
876
+							: __('"(unknown)"', 'event_espresso')
877
+					),
878
+					__FILE__,
879
+					__FUNCTION__,
880
+					__LINE__
881
+				);
882
+			}
883
+		}
884
+		return;
885
+	}
886
+
887
+
888
+	/**
889
+	 * Displays payment settings (not payment METHOD settings, that's _payment_method_settings)
890
+	 * @throws DomainException
891
+	 * @throws EE_Error
892
+	 * @throws InvalidArgumentException
893
+	 * @throws InvalidDataTypeException
894
+	 * @throws InvalidInterfaceException
895
+	 */
896
+	protected function _payment_settings()
897
+	{
898
+		$form = $this->getPaymentSettingsForm();
899
+		$this->_set_add_edit_form_tags('update_payment_settings');
900
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
901
+		$this->_template_args['admin_page_content'] =  $form->get_html_and_js();
902
+		$this->display_admin_page_with_sidebar();
903
+	}
904
+
905
+
906
+	/**
907
+	 *        _update_payment_settings
908
+	 *
909
+	 * @access protected
910
+	 * @return void
911
+	 * @throws EE_Error
912
+	 * @throws InvalidArgumentException
913
+	 * @throws InvalidDataTypeException
914
+	 * @throws InvalidInterfaceException
915
+	 */
916
+	protected function _update_payment_settings()
917
+	{
918
+		$form = $this->getPaymentSettingsForm();
919
+		if ($form->was_submitted($this->_req_data)) {
920
+			$form->receive_form_submission($this->_req_data);
921
+			if ($form->is_valid()) {
922
+				/**
923
+				 * @var $reg_config EE_Registration_Config
924
+				 */
925
+				$loader = LoaderFactory::getLoader();
926
+				$reg_config = $loader->getShared('EE_Registration_Config');
927
+				$valid_data = $form->valid_data();
928
+				$reg_config->show_pending_payment_options = $valid_data['show_pending_payment_options'];
929
+				$reg_config->gateway_log_lifespan = $valid_data['gateway_log_lifespan'];
930
+			}
931
+		}
932
+		EE_Registry::instance()->CFG = apply_filters(
933
+			'FHEE__Payments_Admin_Page___update_payment_settings__CFG',
934
+			EE_Registry::instance()->CFG
935
+		);
936
+
937
+		$cfg =  EE_Registry::instance()->CFG ;
938
+
939
+		$what = __('Payment Settings', 'event_espresso');
940
+		$success = $this->_update_espresso_configuration(
941
+			$what,
942
+			EE_Registry::instance()->CFG,
943
+			__FILE__,
944
+			__FUNCTION__,
945
+			__LINE__
946
+		);
947
+		$this->_redirect_after_action(
948
+			$success,
949
+			$what,
950
+			__('updated', 'event_espresso'),
951
+			array('action' => 'payment_settings')
952
+		);
953
+	}
954
+
955
+
956
+	/**
957
+	 * Gets the form used for updating payment settings
958
+	 *
959
+	 * @return EE_Form_Section_Proper
960
+	 * @throws EE_Error
961
+	 * @throws InvalidArgumentException
962
+	 * @throws InvalidDataTypeException
963
+	 * @throws InvalidInterfaceException
964
+	 */
965
+	protected function getPaymentSettingsForm()
966
+	{
967
+		/**
968
+		 * @var $reg_config EE_Registration_Config
969
+		 */
970
+		$reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
971
+		return new EE_Form_Section_Proper(
972
+			array(
973
+				'name' => 'payment-settings',
974
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
975
+				'subsections' => array(
976
+					'show_pending_payment_options' => new EE_Yes_No_Input(
977
+						array(
978
+							'html_name' => 'show_pending_payment_options',
979
+							'default' => $reg_config->show_pending_payment_options,
980
+							'html_help_text' => esc_html__(
981
+								"If a payment is marked as 'Pending Payment', or if payment is deferred (ie, an offline gateway like Check, Bank, or Invoice is used), then give registrants the option to retry payment. ",
982
+								'event_espresso'
983
+							)
984
+						)
985
+					),
986
+					'gateway_log_lifespan' => new EE_Select_Input(
987
+						$reg_config->gatewayLogLifespanOptions(),
988
+						array(
989
+							'html_label_text' => esc_html__('Gateway Logs Lifespan', 'event_espresso'),
990
+							'html_help_text' => esc_html__('If issues arise with payments being made through a payment gateway, it\'s helpful to log non-sensitive communications with the payment gateway. But it\'s a security responsibility, so it\'s a good idea to not keep them for any longer than necessary.', 'event_espresso'),
991
+							'default' => $reg_config->gateway_log_lifespan,
992
+						)
993
+					)
994
+				)
995
+			)
996
+		);
997
+	}
998
+
999
+
1000
+	protected function _payment_log_overview_list_table()
1001
+	{
1002
+		$this->display_admin_list_table_page_with_sidebar();
1003
+	}
1004
+
1005
+
1006
+	protected function _set_list_table_views_payment_log()
1007
+	{
1008
+		$this->_views = array(
1009
+			'all' => array(
1010
+				'slug'  => 'all',
1011
+				'label' => __('View All Logs', 'event_espresso'),
1012
+				'count' => 0,
1013
+			),
1014
+		);
1015
+	}
1016
+
1017
+
1018
+	/**
1019
+	 * @param int  $per_page
1020
+	 * @param int  $current_page
1021
+	 * @param bool $count
1022
+	 * @return array
1023
+	 */
1024
+	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false)
1025
+	{
1026
+		EE_Registry::instance()->load_model('Change_Log');
1027
+		// we may need to do multiple queries (joining differently), so we actually wan tan array of query params
1028
+		$query_params = array(array('LOG_type' => EEM_Change_Log::type_gateway));
1029
+		// check if they've selected a specific payment method
1030
+		if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
1031
+			$query_params[0]['OR*pm_or_pay_pm'] = array(
1032
+				'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'],
1033
+				'Payment_Method.PMD_ID'         => $this->_req_data['_payment_method'],
1034
+			);
1035
+		}
1036
+		// take into account search
1037
+		if (isset($this->_req_data['s']) && $this->_req_data['s']) {
1038
+			$similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%');
1039
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
1040
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
1041
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
1042
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_name'] = $similarity_string;
1043
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name'] = $similarity_string;
1044
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_type'] = $similarity_string;
1045
+			$query_params[0]['OR*s']['LOG_message'] = $similarity_string;
1046
+			$query_params[0]['OR*s']['Payment_Method.PMD_name'] = $similarity_string;
1047
+			$query_params[0]['OR*s']['Payment_Method.PMD_admin_name'] = $similarity_string;
1048
+			$query_params[0]['OR*s']['Payment_Method.PMD_type'] = $similarity_string;
1049
+			$query_params[0]['OR*s']['LOG_message'] = $similarity_string;
1050
+		}
1051
+		if (isset($this->_req_data['payment-filter-start-date'])
1052
+			&& isset($this->_req_data['payment-filter-end-date'])
1053
+		) {
1054
+			// add date
1055
+			$start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
1056
+			$end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
1057
+			// make sure our timestamps start and end right at the boundaries for each day
1058
+			$start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
1059
+			$end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
1060
+			// convert to timestamps
1061
+			$start_date = strtotime($start_date);
1062
+			$end_date = strtotime($end_date);
1063
+			// makes sure start date is the lowest value and vice versa
1064
+			$start_date = min($start_date, $end_date);
1065
+			$end_date = max($start_date, $end_date);
1066
+			// convert for query
1067
+			$start_date = EEM_Change_Log::instance()
1068
+										->convert_datetime_for_query(
1069
+											'LOG_time',
1070
+											date('Y-m-d H:i:s', $start_date),
1071
+											'Y-m-d H:i:s'
1072
+										);
1073
+			$end_date = EEM_Change_Log::instance()
1074
+									  ->convert_datetime_for_query(
1075
+										  'LOG_time',
1076
+										  date('Y-m-d H:i:s', $end_date),
1077
+										  'Y-m-d H:i:s'
1078
+									  );
1079
+			$query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date));
1080
+		}
1081
+		if ($count) {
1082
+			return EEM_Change_Log::instance()->count($query_params);
1083
+		}
1084
+		if (isset($this->_req_data['order'])) {
1085
+			$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
1086
+				: 'DESC';
1087
+			$query_params['order_by'] = array('LOG_time' => $sort);
1088
+		} else {
1089
+			$query_params['order_by'] = array('LOG_time' => 'DESC');
1090
+		}
1091
+		$offset = ($current_page - 1) * $per_page;
1092
+		if (! isset($this->_req_data['download_results'])) {
1093
+			$query_params['limit'] = array($offset, $per_page);
1094
+		}
1095
+		// now they've requested to instead just download the file instead of viewing it.
1096
+		if (isset($this->_req_data['download_results'])) {
1097
+			$wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
1098
+			header('Content-Disposition: attachment');
1099
+			header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url()));
1100
+			echo "<h1>Payment Logs for " . site_url() . "</h1>";
1101
+			echo "<h3>Query:</h3>";
1102
+			var_dump($query_params);
1103
+			echo "<h3>Results:</h3>";
1104
+			var_dump($wpdb_results);
1105
+			die;
1106
+		}
1107
+		$results = EEM_Change_Log::instance()->get_all($query_params);
1108
+		return $results;
1109
+	}
1110
+
1111
+
1112
+	/**
1113
+	 * Used by usort to RE-sort log query results, because we lose the ordering
1114
+	 * because we're possibly combining the results from two queries
1115
+	 *
1116
+	 * @param EE_Change_Log $logA
1117
+	 * @param EE_Change_Log $logB
1118
+	 * @return int
1119
+	 */
1120
+	protected function _sort_logs_again($logA, $logB)
1121
+	{
1122
+		$timeA = $logA->get_raw('LOG_time');
1123
+		$timeB = $logB->get_raw('LOG_time');
1124
+		if ($timeA == $timeB) {
1125
+			return 0;
1126
+		}
1127
+		$comparison = $timeA < $timeB ? -1 : 1;
1128
+		if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
1129
+			return $comparison * -1;
1130
+		} else {
1131
+			return $comparison;
1132
+		}
1133
+	}
1134
+
1135
+
1136
+	protected function _payment_log_details()
1137
+	{
1138
+		EE_Registry::instance()->load_model('Change_Log');
1139
+		/** @var $payment_log EE_Change_Log */
1140
+		$payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
1141
+		$payment_method = null;
1142
+		$transaction = null;
1143
+		if ($payment_log instanceof EE_Change_Log) {
1144
+			if ($payment_log->object() instanceof EE_Payment) {
1145
+				$payment_method = $payment_log->object()->payment_method();
1146
+				$transaction = $payment_log->object()->transaction();
1147
+			} elseif ($payment_log->object() instanceof EE_Payment_Method) {
1148
+				$payment_method = $payment_log->object();
1149
+			} elseif ($payment_log->object() instanceof EE_Transaction) {
1150
+				$transaction = $payment_log->object();
1151
+				$payment_method = $transaction->payment_method();
1152
+			}
1153
+		}
1154
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
1155
+			EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
1156
+			array(
1157
+				'payment_log'    => $payment_log,
1158
+				'payment_method' => $payment_method,
1159
+				'transaction'    => $transaction,
1160
+			),
1161
+			true
1162
+		);
1163
+		$this->display_admin_page_with_sidebar();
1164
+	}
1165 1165
 }
Please login to merge, or discard this patch.
libraries/form_sections/strategies/layout/EE_Two_Column_Layout.strategy.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -5,81 +5,81 @@
 block discarded – undo
5 5
 class EE_Two_Column_Layout extends EE_Form_Section_Layout_Base
6 6
 {
7 7
 
8
-    /**
9
-     * Should be used to start teh form section (Eg a table tag, or a div tag, etc.)
10
-     *
11
-     * @param array $additional_args
12
-     * @return string
13
-     */
14
-    public function layout_form_begin($additional_args = array())
15
-    {
16
-        return $this->display_form_wide_errors()
17
-        . EEH_HTML::table(
18
-            '',
19
-            $this->_form_section->html_id(),
20
-            $this->_form_section->html_class(),
21
-            $this->_form_section->html_style()
22
-        ) . EEH_HTML::tbody();
23
-    }
8
+	/**
9
+	 * Should be used to start teh form section (Eg a table tag, or a div tag, etc.)
10
+	 *
11
+	 * @param array $additional_args
12
+	 * @return string
13
+	 */
14
+	public function layout_form_begin($additional_args = array())
15
+	{
16
+		return $this->display_form_wide_errors()
17
+		. EEH_HTML::table(
18
+			'',
19
+			$this->_form_section->html_id(),
20
+			$this->_form_section->html_class(),
21
+			$this->_form_section->html_style()
22
+		) . EEH_HTML::tbody();
23
+	}
24 24
 
25 25
 
26 26
 
27
-    /**
28
-     * Should be used to end the form section (eg a /table tag, or a /div tag, etc)
29
-     *
30
-     * @param array $additional_args
31
-     * @return string
32
-     */
33
-    public function layout_form_end($additional_args = array())
34
-    {
35
-        return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id());
36
-    }
27
+	/**
28
+	 * Should be used to end the form section (eg a /table tag, or a /div tag, etc)
29
+	 *
30
+	 * @param array $additional_args
31
+	 * @return string
32
+	 */
33
+	public function layout_form_end($additional_args = array())
34
+	{
35
+		return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id());
36
+	}
37 37
 
38 38
 
39 39
 
40
-    /**
41
-     * Lays out the row for the input, including label and errors
42
-     *
43
-     * @param EE_Form_Input_Base $input
44
-     * @return string
45
-     */
46
-    public function layout_input($input)
47
-    {
48
-        $html = '';
49
-        if ($input instanceof EE_Hidden_Input) {
50
-            $html .= $input->get_html_for_input();
51
-        } else {
52
-            $html_for_input = $input->get_html_for_input();
53
-            $html_for_input .= $input->get_html_for_errors() != ''
54
-                ? EEH_HTML::nl() . $input->get_html_for_errors()
55
-                : '';
56
-            $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : '';
57
-            $html .= EEH_HTML::tr(
58
-                EEH_HTML::th($input->get_html_for_label()) .
59
-                EEH_HTML::td($html_for_input)
60
-            );
61
-        }
62
-        return $html;
63
-    }
40
+	/**
41
+	 * Lays out the row for the input, including label and errors
42
+	 *
43
+	 * @param EE_Form_Input_Base $input
44
+	 * @return string
45
+	 */
46
+	public function layout_input($input)
47
+	{
48
+		$html = '';
49
+		if ($input instanceof EE_Hidden_Input) {
50
+			$html .= $input->get_html_for_input();
51
+		} else {
52
+			$html_for_input = $input->get_html_for_input();
53
+			$html_for_input .= $input->get_html_for_errors() != ''
54
+				? EEH_HTML::nl() . $input->get_html_for_errors()
55
+				: '';
56
+			$html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : '';
57
+			$html .= EEH_HTML::tr(
58
+				EEH_HTML::th($input->get_html_for_label()) .
59
+				EEH_HTML::td($html_for_input)
60
+			);
61
+		}
62
+		return $html;
63
+	}
64 64
 
65 65
 
66 66
 
67
-    /**
68
-     * Lays out a row for the subsection. Please note that if you have a subsection which you don't want wrapped in
69
-     * a tr and td with a colspan=2, you should use a different layout strategy, like EE_No_Layout, EE_Template_Layout,
70
-     * or EE_Div_Per_Section_Layout, and create subsections using EE_Two_Column_Layout for everywhere you want the
71
-     * two-column layout, and then other sub-sections can be outside the EE_Two_Column_Layout table.
72
-     *
73
-     * @param EE_Form_Section_Proper $form_section
74
-     * @return string
75
-    */
76
-    public function layout_subsection($form_section)
77
-    {
78
-        if ($form_section instanceof EE_Form_Section_Proper
79
-            || $form_section instanceof EE_Form_Section_HTML
80
-        ) {
81
-            return EEH_HTML::no_row($form_section->get_html());
82
-        }
83
-        return '';
84
-    }
67
+	/**
68
+	 * Lays out a row for the subsection. Please note that if you have a subsection which you don't want wrapped in
69
+	 * a tr and td with a colspan=2, you should use a different layout strategy, like EE_No_Layout, EE_Template_Layout,
70
+	 * or EE_Div_Per_Section_Layout, and create subsections using EE_Two_Column_Layout for everywhere you want the
71
+	 * two-column layout, and then other sub-sections can be outside the EE_Two_Column_Layout table.
72
+	 *
73
+	 * @param EE_Form_Section_Proper $form_section
74
+	 * @return string
75
+	 */
76
+	public function layout_subsection($form_section)
77
+	{
78
+		if ($form_section instanceof EE_Form_Section_Proper
79
+			|| $form_section instanceof EE_Form_Section_HTML
80
+		) {
81
+			return EEH_HTML::no_row($form_section->get_html());
82
+		}
83
+		return '';
84
+	}
85 85
 }
Please login to merge, or discard this patch.
form_sections/strategies/layout/EE_Admin_Two_Column_Layout.strategy.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -7,62 +7,62 @@
 block discarded – undo
7 7
 class EE_Admin_Two_Column_Layout extends EE_Two_Column_Layout
8 8
 {
9 9
 
10
-    /**
11
-     * Overriding the parent table layout to include <tbody> tags
12
-     *
13
-     * @param array $additional_args
14
-     * @return string
15
-     */
16
-    public function layout_form_begin($additional_args = array())
17
-    {
18
-        $this->_form_section->set_html_class($this->_form_section->html_class() . ' form-table');
19
-        return parent::layout_form_begin($additional_args);
20
-    }
10
+	/**
11
+	 * Overriding the parent table layout to include <tbody> tags
12
+	 *
13
+	 * @param array $additional_args
14
+	 * @return string
15
+	 */
16
+	public function layout_form_begin($additional_args = array())
17
+	{
18
+		$this->_form_section->set_html_class($this->_form_section->html_class() . ' form-table');
19
+		return parent::layout_form_begin($additional_args);
20
+	}
21 21
 
22 22
 
23 23
 
24
-    /**
25
-     * Lays out the row for the input, including label and errors
26
-     *
27
-     * @param EE_Form_Input_Base $input
28
-     * @return string
29
-     * @throws EE_Error
30
-     */
31
-    public function layout_input($input)
32
-    {
33
-        if ($input->get_display_strategy() instanceof EE_Text_Area_Display_Strategy
34
-            || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy
35
-            || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy
36
-        ) {
37
-            $input->set_html_class($input->html_class() . ' large-text');
38
-        }
39
-        if ($input instanceof EE_Text_Area_Input) {
40
-            $input->set_rows(4);
41
-            $input->set_cols(60);
42
-        }
43
-        $input_html = $input->get_html_for_input();
44
-        // maybe add errors and help text ?
45
-        $input_html .= $input->get_html_for_errors() !== ''
46
-            ? EEH_HTML::nl() . $input->get_html_for_errors()
47
-            : '';
48
-        $input_html .= $input->get_html_for_help() !== ''
49
-            ? EEH_HTML::nl() . $input->get_html_for_help()
50
-            : '';
51
-        // overriding parent to add wp admin specific things.
52
-        $html = '';
53
-        if ($input instanceof EE_Hidden_Input) {
54
-            $html .= EEH_HTML::no_row($input->get_html_for_input());
55
-        } else {
56
-            $html .= EEH_HTML::tr(
57
-                EEH_HTML::th(
58
-                    $input->get_html_for_label(),
59
-                    '',
60
-                    '',
61
-                    '',
62
-                    'scope="row"'
63
-                ) . EEH_HTML::td($input_html)
64
-            );
65
-        }
66
-        return $html;
67
-    }
24
+	/**
25
+	 * Lays out the row for the input, including label and errors
26
+	 *
27
+	 * @param EE_Form_Input_Base $input
28
+	 * @return string
29
+	 * @throws EE_Error
30
+	 */
31
+	public function layout_input($input)
32
+	{
33
+		if ($input->get_display_strategy() instanceof EE_Text_Area_Display_Strategy
34
+			|| $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy
35
+			|| $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy
36
+		) {
37
+			$input->set_html_class($input->html_class() . ' large-text');
38
+		}
39
+		if ($input instanceof EE_Text_Area_Input) {
40
+			$input->set_rows(4);
41
+			$input->set_cols(60);
42
+		}
43
+		$input_html = $input->get_html_for_input();
44
+		// maybe add errors and help text ?
45
+		$input_html .= $input->get_html_for_errors() !== ''
46
+			? EEH_HTML::nl() . $input->get_html_for_errors()
47
+			: '';
48
+		$input_html .= $input->get_html_for_help() !== ''
49
+			? EEH_HTML::nl() . $input->get_html_for_help()
50
+			: '';
51
+		// overriding parent to add wp admin specific things.
52
+		$html = '';
53
+		if ($input instanceof EE_Hidden_Input) {
54
+			$html .= EEH_HTML::no_row($input->get_html_for_input());
55
+		} else {
56
+			$html .= EEH_HTML::tr(
57
+				EEH_HTML::th(
58
+					$input->get_html_for_label(),
59
+					'',
60
+					'',
61
+					'',
62
+					'scope="row"'
63
+				) . EEH_HTML::td($input_html)
64
+			);
65
+		}
66
+		return $html;
67
+	}
68 68
 }
Please login to merge, or discard this patch.
mijireh_slurper/templates/additional_content_on_gateway.template.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <table>
2 2
     <tr>
3 3
         <th><?php _e("Mijireh Checkout Page Design", 'event_espresso'); ?><?php
4
-            echo EEH_Template::get_help_tab_link(
5
-                'ee_mijireh_help_tab'
6
-            ); ?></th>
4
+			echo EEH_Template::get_help_tab_link(
5
+				'ee_mijireh_help_tab'
6
+			); ?></th>
7 7
         <td>
8 8
             <a href="?mijireh_edit_slurp_page=true"><?php _e("Edit Slurp Page", 'event_espresso'); ?></a>
9 9
         </td>
Please login to merge, or discard this patch.
Invoice/templates/invoice_settings_header_display.template.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
         <td>
17 17
             <span class="description">
18 18
                 <?php _e(
19
-                    "The following settings affect the content and/or appearance of the downloadable PDF invoice.",
20
-                    'event_espresso'
21
-                ); ?></span>
19
+					"The following settings affect the content and/or appearance of the downloadable PDF invoice.",
20
+					'event_espresso'
21
+				); ?></span>
22 22
         </td>
23 23
     </tr>
24 24
 </table>
25 25
\ No newline at end of file
Please login to merge, or discard this patch.
Invoice/templates/invoice_settings_header_gateway.template.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
         <td>
17 17
             <span class="description">
18 18
                 <?php _e(
19
-                    "The following settings affect the functioning of the Invoice gateway.",
20
-                    'event_espresso'
21
-                ); ?></span>
19
+					"The following settings affect the functioning of the Invoice gateway.",
20
+					'event_espresso'
21
+				); ?></span>
22 22
         </td>
23 23
     </tr>
24 24
 </table>
25 25
\ No newline at end of file
Please login to merge, or discard this patch.
data_migration_scripts/4_1_0_stages/EE_DMS_4_1_0_org_options.dmsstage.php 2 patches
Indentation   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -103,289 +103,289 @@
 block discarded – undo
103 103
 class EE_DMS_4_1_0_org_options extends EE_Data_Migration_Script_Stage
104 104
 {
105 105
 
106
-    public function _migration_step($num_items = 50)
107
-    {
106
+	public function _migration_step($num_items = 50)
107
+	{
108 108
 
109
-        $items_actually_migrated = 0;
110
-        $old_org_options = get_option('events_organization_settings');
111
-        foreach ($this->_org_options_we_know_how_to_migrate as $option_name) {
112
-            // only bother migrating if there's a setting to migrate. Otherwise we'll just use the default
113
-            if (isset($old_org_options[ $option_name ])) {
114
-                $this->_handle_org_option($option_name, $old_org_options[ $option_name ]);
115
-            }
116
-            if ($option_name=='surcharge') {
117
-                $this->_insert_new_global_surcharge_price($old_org_options);
118
-            }
119
-            $items_actually_migrated++;
120
-        }
109
+		$items_actually_migrated = 0;
110
+		$old_org_options = get_option('events_organization_settings');
111
+		foreach ($this->_org_options_we_know_how_to_migrate as $option_name) {
112
+			// only bother migrating if there's a setting to migrate. Otherwise we'll just use the default
113
+			if (isset($old_org_options[ $option_name ])) {
114
+				$this->_handle_org_option($option_name, $old_org_options[ $option_name ]);
115
+			}
116
+			if ($option_name=='surcharge') {
117
+				$this->_insert_new_global_surcharge_price($old_org_options);
118
+			}
119
+			$items_actually_migrated++;
120
+		}
121 121
 
122
-        $success = EE_Config::instance()->update_espresso_config(false, true);
123
-        if (! $success) {
124
-            $this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(false)));
125
-            EE_Error::overwrite_errors();
126
-        }
127
-        EE_Network_Config::instance()->update_config(false, false);
128
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
129
-            // we may have added new pages and this might be necessary
130
-            flush_rewrite_rules();
131
-            $this->set_completed();
132
-        }
133
-        return $items_actually_migrated;
134
-    }
135
-    public function _count_records_to_migrate()
136
-    {
137
-        $count_of_options_to_migrate = count($this->_org_options_we_know_how_to_migrate);
138
-        return $count_of_options_to_migrate;
139
-    }
140
-    public function __construct()
141
-    {
142
-        $this->_pretty_name = __("Organization Options/Config", "event_espresso");
143
-        $this->_org_options_we_know_how_to_migrate = apply_filters('FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate', $this->_org_options_we_know_how_to_migrate);
144
-        parent::__construct();
145
-    }
122
+		$success = EE_Config::instance()->update_espresso_config(false, true);
123
+		if (! $success) {
124
+			$this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(false)));
125
+			EE_Error::overwrite_errors();
126
+		}
127
+		EE_Network_Config::instance()->update_config(false, false);
128
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
129
+			// we may have added new pages and this might be necessary
130
+			flush_rewrite_rules();
131
+			$this->set_completed();
132
+		}
133
+		return $items_actually_migrated;
134
+	}
135
+	public function _count_records_to_migrate()
136
+	{
137
+		$count_of_options_to_migrate = count($this->_org_options_we_know_how_to_migrate);
138
+		return $count_of_options_to_migrate;
139
+	}
140
+	public function __construct()
141
+	{
142
+		$this->_pretty_name = __("Organization Options/Config", "event_espresso");
143
+		$this->_org_options_we_know_how_to_migrate = apply_filters('FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate', $this->_org_options_we_know_how_to_migrate);
144
+		parent::__construct();
145
+	}
146 146
 
147
-    private function _handle_org_option($option_name, $value)
148
-    {
149
-        $c = EE_Config::instance();
150
-        $cn = EE_Network_Config::instance();
151
-        switch ($option_name) {
152
-            case 'organization':
153
-                $c->organization->name = $value;
154
-                break;
155
-            case 'organization_street1':
156
-                $c->organization->address_1 = $value;
157
-                break;
158
-            case 'organization_street2':
159
-                $c->organization->address_2 = $value;
160
-                break;
161
-            case 'organization_city':
162
-                $c->organization->city = $value;
163
-                break;
164
-            case 'organization_state':
165
-                try {
166
-                    $state = $this->get_migration_script()->get_or_create_state($value);
167
-                    $state_id = $state['STA_ID'];
168
-                    $c->organization->STA_ID = $state_id;
169
-                } catch (EE_Error $e) {
170
-                }
171
-                break;
172
-            case 'organization_zip':
173
-                $c->organization->zip = $value;
174
-                break;
175
-            case 'contact_email':
176
-                $c->organization->email = $value;
177
-                break;
178
-            case 'default_payment_status':
179
-                $c->registration->default_STS_ID =  $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value);
180
-                break;
181
-            case 'organization_country':
182
-                $iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value);
183
-                $c->organization->CNT_ISO = $iso;
184
-                $country_row = $this->get_migration_script()->get_or_create_country($iso);
185
-                if (! $country_row) {
186
-                    $this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso));
187
-                }
188
-                // can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them)
189
-                $c->currency->code = $country_row['CNT_cur_code'];          // currency code: USD, CAD, EUR
190
-                $c->currency->name = $country_row['CNT_cur_single'];    // Dollar
191
-                $c->currency->plural = $country_row['CNT_cur_plural'];  // Dollars
192
-                $c->currency->sign =  $country_row['CNT_cur_sign'];             // currency sign: $
193
-                $c->currency->sign_b4 = filter_var($country_row['CNT_cur_sign_b4'], FILTER_VALIDATE_BOOLEAN);        // currency sign before or after: $TRUE  or  FALSE$
194
-                $c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc'];    // decimal places: 2 = 0.00  3 = 0.000
195
-                $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk'];    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
196
-                $c->currency->thsnds = $country_row['CNT_cur_thsnds'];  // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
147
+	private function _handle_org_option($option_name, $value)
148
+	{
149
+		$c = EE_Config::instance();
150
+		$cn = EE_Network_Config::instance();
151
+		switch ($option_name) {
152
+			case 'organization':
153
+				$c->organization->name = $value;
154
+				break;
155
+			case 'organization_street1':
156
+				$c->organization->address_1 = $value;
157
+				break;
158
+			case 'organization_street2':
159
+				$c->organization->address_2 = $value;
160
+				break;
161
+			case 'organization_city':
162
+				$c->organization->city = $value;
163
+				break;
164
+			case 'organization_state':
165
+				try {
166
+					$state = $this->get_migration_script()->get_or_create_state($value);
167
+					$state_id = $state['STA_ID'];
168
+					$c->organization->STA_ID = $state_id;
169
+				} catch (EE_Error $e) {
170
+				}
171
+				break;
172
+			case 'organization_zip':
173
+				$c->organization->zip = $value;
174
+				break;
175
+			case 'contact_email':
176
+				$c->organization->email = $value;
177
+				break;
178
+			case 'default_payment_status':
179
+				$c->registration->default_STS_ID =  $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value);
180
+				break;
181
+			case 'organization_country':
182
+				$iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value);
183
+				$c->organization->CNT_ISO = $iso;
184
+				$country_row = $this->get_migration_script()->get_or_create_country($iso);
185
+				if (! $country_row) {
186
+					$this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso));
187
+				}
188
+				// can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them)
189
+				$c->currency->code = $country_row['CNT_cur_code'];          // currency code: USD, CAD, EUR
190
+				$c->currency->name = $country_row['CNT_cur_single'];    // Dollar
191
+				$c->currency->plural = $country_row['CNT_cur_plural'];  // Dollars
192
+				$c->currency->sign =  $country_row['CNT_cur_sign'];             // currency sign: $
193
+				$c->currency->sign_b4 = filter_var($country_row['CNT_cur_sign_b4'], FILTER_VALIDATE_BOOLEAN);        // currency sign before or after: $TRUE  or  FALSE$
194
+				$c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc'];    // decimal places: 2 = 0.00  3 = 0.000
195
+				$c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk'];    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
196
+				$c->currency->thsnds = $country_row['CNT_cur_thsnds'];  // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
197 197
   //            $c->currency = new EE_Currency_Config($c->organization->CNT_ISO);break;
198 198
   //        case 'currency_symbol': ignore the currency symbol. we'll just go by their country.
199 199
   //            $c->currency->sign = $value;break;
200
-            case 'show_pending_payment_options':
201
-                $c->registration->show_pending_payment_options = ($value == 'Y');
202
-                break;
203
-            case 'display_address_in_regform':
204
-                $c->template_settings->display_address_in_regform = ($value == 'Y');
205
-                break;
206
-            case 'default_logo_url':
207
-                $c->organization->logo_url = $value;
208
-                break;
209
-            case 'event_page_id':
210
-                // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS
211
-                // to ESPRESSO_THANK_YOU
212
-                $reg_page_post = get_post($value);
213
-                $reg_page_post->post_content = str_replace("[ESPRESSO_EVENTS]", "[ESPRESSO_CHECKOUT]", $reg_page_post->post_content);
214
-                wp_update_post($reg_page_post);
215
-                $c->core->reg_page_id = $value;
216
-                break;
217
-            case 'return_url':
218
-                // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS
219
-                // to ESPRESSO_THANK_YOU
220
-                $thank_you_page_post = get_post($value);
221
-                $thank_you_page_post->post_content = str_replace("[ESPRESSO_PAYMENTS]", "[ESPRESSO_THANK_YOU]", $thank_you_page_post->post_content);
222
-                wp_update_post($thank_you_page_post);
223
-                $c->core->thank_you_page_id = $value;
224
-                break;
225
-            case 'cancel_return':
226
-                $c->core->cancel_page_id = $value;
200
+			case 'show_pending_payment_options':
201
+				$c->registration->show_pending_payment_options = ($value == 'Y');
202
+				break;
203
+			case 'display_address_in_regform':
204
+				$c->template_settings->display_address_in_regform = ($value == 'Y');
205
+				break;
206
+			case 'default_logo_url':
207
+				$c->organization->logo_url = $value;
208
+				break;
209
+			case 'event_page_id':
210
+				// also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS
211
+				// to ESPRESSO_THANK_YOU
212
+				$reg_page_post = get_post($value);
213
+				$reg_page_post->post_content = str_replace("[ESPRESSO_EVENTS]", "[ESPRESSO_CHECKOUT]", $reg_page_post->post_content);
214
+				wp_update_post($reg_page_post);
215
+				$c->core->reg_page_id = $value;
216
+				break;
217
+			case 'return_url':
218
+				// also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS
219
+				// to ESPRESSO_THANK_YOU
220
+				$thank_you_page_post = get_post($value);
221
+				$thank_you_page_post->post_content = str_replace("[ESPRESSO_PAYMENTS]", "[ESPRESSO_THANK_YOU]", $thank_you_page_post->post_content);
222
+				wp_update_post($thank_you_page_post);
223
+				$c->core->thank_you_page_id = $value;
224
+				break;
225
+			case 'cancel_return':
226
+				$c->core->cancel_page_id = $value;
227 227
 
228
-                break;
229
-            case 'notify_url':
230
-                $c->core->txn_page_id = $value;
231
-                break;
232
-            case 'use_captcha':
233
-                $c->registration->use_captcha = ($value == 'Y');
234
-                break;
235
-            case 'recaptcha_publickey':
236
-                $c->registration->recaptcha_publickey = $value;
237
-                break;
238
-            case 'recaptcha_privatekey':
239
-                $c->registration->recaptcha_privatekey = $value;
240
-                break;
241
-            case 'recaptcha_theme':
242
-                $c->registration->recaptcha_theme = $value;
243
-                break;
244
-            case 'recaptcha_width':
245
-                $c->registration->recaptcha_width = $value;
246
-                break;
247
-            case 'recaptcha_language':
248
-                $c->registration->recaptcha_language = $value;
249
-                break;
250
-            case 'espresso_dashboard_widget':
251
-                $c->admin->use_dashboard_widget = ($value == 'Y');
252
-                break;
253
-            case 'use_personnel_manager':
254
-                $c->admin->use_personnel_manager = ($value == 'Y');
255
-                break;
256
-            case 'use_event_timezones':
257
-                $c->admin->use_event_timezones = ($value == 'Y');
258
-                break;
259
-            case 'full_logging':
260
-                $c->admin->use_full_logging = ($value == 'Y');
261
-                break;
262
-            case 'affiliate_id':
263
-                $c->admin->affiliate_id = $value;
264
-                break;
265
-            case 'site_license_key':
266
-                $cn->core->site_license_key = $value;
267
-                break;
268
-            default:
269
-                do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value);
270
-        }
271
-    }
228
+				break;
229
+			case 'notify_url':
230
+				$c->core->txn_page_id = $value;
231
+				break;
232
+			case 'use_captcha':
233
+				$c->registration->use_captcha = ($value == 'Y');
234
+				break;
235
+			case 'recaptcha_publickey':
236
+				$c->registration->recaptcha_publickey = $value;
237
+				break;
238
+			case 'recaptcha_privatekey':
239
+				$c->registration->recaptcha_privatekey = $value;
240
+				break;
241
+			case 'recaptcha_theme':
242
+				$c->registration->recaptcha_theme = $value;
243
+				break;
244
+			case 'recaptcha_width':
245
+				$c->registration->recaptcha_width = $value;
246
+				break;
247
+			case 'recaptcha_language':
248
+				$c->registration->recaptcha_language = $value;
249
+				break;
250
+			case 'espresso_dashboard_widget':
251
+				$c->admin->use_dashboard_widget = ($value == 'Y');
252
+				break;
253
+			case 'use_personnel_manager':
254
+				$c->admin->use_personnel_manager = ($value == 'Y');
255
+				break;
256
+			case 'use_event_timezones':
257
+				$c->admin->use_event_timezones = ($value == 'Y');
258
+				break;
259
+			case 'full_logging':
260
+				$c->admin->use_full_logging = ($value == 'Y');
261
+				break;
262
+			case 'affiliate_id':
263
+				$c->admin->affiliate_id = $value;
264
+				break;
265
+			case 'site_license_key':
266
+				$cn->core->site_license_key = $value;
267
+				break;
268
+			default:
269
+				do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value);
270
+		}
271
+	}
272 272
 
273
-    /**
274
-     * Creates a 4.1 member price discount
275
-     * @global type $wpdb
276
-     * @param type $old_price
277
-     * @return int
278
-     */
279
-    private function _insert_new_global_surcharge_price($org_options)
280
-    {
281
-        $amount = floatval($org_options['surcharge']);
282
-        // dont createa a price if the surcharge is 0
283
-        if ($amount <=.01) {
284
-            return 0;
285
-        }
286
-        if ($org_options['surcharge_type'] == 'flat_rate') {
287
-            $price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge;
288
-        } else {
289
-            $price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge;
290
-        }
291
-        global $wpdb;
292
-        $cols_n_values = array(
293
-            'PRT_ID'=>$price_type,
294
-            'PRC_amount'=>$amount,
295
-            'PRC_name'=>  $org_options['surcharge_text'],
296
-            'PRC_is_default'=>true,
297
-            'PRC_overrides'=>false,
298
-            'PRC_order'=>100,
299
-            'PRC_deleted'=>false,
300
-            'PRC_parent'=>null
273
+	/**
274
+	 * Creates a 4.1 member price discount
275
+	 * @global type $wpdb
276
+	 * @param type $old_price
277
+	 * @return int
278
+	 */
279
+	private function _insert_new_global_surcharge_price($org_options)
280
+	{
281
+		$amount = floatval($org_options['surcharge']);
282
+		// dont createa a price if the surcharge is 0
283
+		if ($amount <=.01) {
284
+			return 0;
285
+		}
286
+		if ($org_options['surcharge_type'] == 'flat_rate') {
287
+			$price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge;
288
+		} else {
289
+			$price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge;
290
+		}
291
+		global $wpdb;
292
+		$cols_n_values = array(
293
+			'PRT_ID'=>$price_type,
294
+			'PRC_amount'=>$amount,
295
+			'PRC_name'=>  $org_options['surcharge_text'],
296
+			'PRC_is_default'=>true,
297
+			'PRC_overrides'=>false,
298
+			'PRC_order'=>100,
299
+			'PRC_deleted'=>false,
300
+			'PRC_parent'=>null
301 301
 
302
-        );
303
-        $datatypes = array(
304
-            '%d',// PRT_ID
305
-            '%f',// PRT_amount
306
-            '%s',// PRC_name
307
-            '%d',// PRC_is_default
308
-            '%d',// PRC_overrides
309
-            '%d',// PRC_order
310
-            '%d',// PRC_deleted
311
-            '%d',// PRC_parent
312
-        );
313
-        $price_table = $wpdb->prefix."esp_price";
314
-        $success = $wpdb->insert($price_table, $cols_n_values, $datatypes);
315
-        if (! $success) {
316
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion(
317
-                'org_options',
318
-                array(
319
-                        'surcharge'=>$org_options['surcharge'],
320
-                        'surcharge_type'=>$org_options['surcharge_type'],
321
-                        'surcharge_text'=>$org_options['surcharge_text']),
322
-                $price_table,
323
-                $cols_n_values,
324
-                $datatypes
325
-            ));
326
-            return 0;
327
-        }
328
-        $new_id = $wpdb->insert_id;
329
-        return $new_id;
330
-    }
302
+		);
303
+		$datatypes = array(
304
+			'%d',// PRT_ID
305
+			'%f',// PRT_amount
306
+			'%s',// PRC_name
307
+			'%d',// PRC_is_default
308
+			'%d',// PRC_overrides
309
+			'%d',// PRC_order
310
+			'%d',// PRC_deleted
311
+			'%d',// PRC_parent
312
+		);
313
+		$price_table = $wpdb->prefix."esp_price";
314
+		$success = $wpdb->insert($price_table, $cols_n_values, $datatypes);
315
+		if (! $success) {
316
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion(
317
+				'org_options',
318
+				array(
319
+						'surcharge'=>$org_options['surcharge'],
320
+						'surcharge_type'=>$org_options['surcharge_type'],
321
+						'surcharge_text'=>$org_options['surcharge_text']),
322
+				$price_table,
323
+				$cols_n_values,
324
+				$datatypes
325
+			));
326
+			return 0;
327
+		}
328
+		$new_id = $wpdb->insert_id;
329
+		return $new_id;
330
+	}
331 331
 
332
-    protected $_org_options_we_know_how_to_migrate = array(
333
-      'organization',
334
-      'organization_street1',
335
-      'organization_street2',
336
-      'organization_city',
337
-      'organization_state',
338
-      'organization_zip',
339
-      'contact_email',
340
-      'default_mail',
341
-      'payment_subject',
342
-      'payment_message',
343
-      'message',
344
-      'default_payment_status',
345
-      'surcharge',// unused?
346
-      'country_id',// unused?
347
-      'organization_country',
332
+	protected $_org_options_we_know_how_to_migrate = array(
333
+	  'organization',
334
+	  'organization_street1',
335
+	  'organization_street2',
336
+	  'organization_city',
337
+	  'organization_state',
338
+	  'organization_zip',
339
+	  'contact_email',
340
+	  'default_mail',
341
+	  'payment_subject',
342
+	  'payment_message',
343
+	  'message',
344
+	  'default_payment_status',
345
+	  'surcharge',// unused?
346
+	  'country_id',// unused?
347
+	  'organization_country',
348 348
 //    'currency_symbol',
349
-      'expire_on_registration_end',
350
-      'email_before_payment',
351
-      'email_fancy_headers',
352
-      'enable_default_style',
353
-      'event_ssl_active',
354
-      'selected_style',
355
-      'show_pending_payment_options',
356
-      'show_reg_footer',
357
-      'skip_confirmation_page',
358
-      'allow_mer_discounts',// no equiv
359
-      'allow_mer_vouchers',// no equiv
360
-      'display_short_description_in_event_list',
361
-      'display_description_on_multi_reg_page',
362
-      'display_address_in_event_list',
363
-      'display_address_in_regform',
364
-      'use_custom_post_types',// no equiv
365
-      'display_ical_download',
366
-      'display_featured_image',
367
-      'themeroller',
368
-      'default_logo_url',
369
-      'event_page_id',
370
-      'return_url',
371
-      'cancel_return',
372
-      'notify_url',
373
-      'events_in_dashboard',
374
-      'use_captcha',
375
-      'recaptcha_publickey',
376
-      'recaptcha_privatekey',
377
-      'recaptcha_theme',
378
-      'recaptcha_width',
379
-      'recaptcha_language',
380
-      'espresso_dashboard_widget',
381
-      'time_reg_limit',
349
+	  'expire_on_registration_end',
350
+	  'email_before_payment',
351
+	  'email_fancy_headers',
352
+	  'enable_default_style',
353
+	  'event_ssl_active',
354
+	  'selected_style',
355
+	  'show_pending_payment_options',
356
+	  'show_reg_footer',
357
+	  'skip_confirmation_page',
358
+	  'allow_mer_discounts',// no equiv
359
+	  'allow_mer_vouchers',// no equiv
360
+	  'display_short_description_in_event_list',
361
+	  'display_description_on_multi_reg_page',
362
+	  'display_address_in_event_list',
363
+	  'display_address_in_regform',
364
+	  'use_custom_post_types',// no equiv
365
+	  'display_ical_download',
366
+	  'display_featured_image',
367
+	  'themeroller',
368
+	  'default_logo_url',
369
+	  'event_page_id',
370
+	  'return_url',
371
+	  'cancel_return',
372
+	  'notify_url',
373
+	  'events_in_dashboard',
374
+	  'use_captcha',
375
+	  'recaptcha_publickey',
376
+	  'recaptcha_privatekey',
377
+	  'recaptcha_theme',
378
+	  'recaptcha_width',
379
+	  'recaptcha_language',
380
+	  'espresso_dashboard_widget',
381
+	  'time_reg_limit',
382 382
 //    'use_attendee_pre_approval', removed in 4.1- instead this is factored into the default reg status
383
-      'use_personnel_manager',// no equiv
384
-      'use_event_timezones',
385
-      'full_logging',
386
-      'surcharge_type',// unused
387
-      'surcharge_text',// unused
388
-      'affiliate_id',
389
-      'site_license_key',
390
-    );
383
+	  'use_personnel_manager',// no equiv
384
+	  'use_event_timezones',
385
+	  'full_logging',
386
+	  'surcharge_type',// unused
387
+	  'surcharge_text',// unused
388
+	  'affiliate_id',
389
+	  'site_license_key',
390
+	);
391 391
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -110,17 +110,17 @@  discard block
 block discarded – undo
110 110
         $old_org_options = get_option('events_organization_settings');
111 111
         foreach ($this->_org_options_we_know_how_to_migrate as $option_name) {
112 112
             // only bother migrating if there's a setting to migrate. Otherwise we'll just use the default
113
-            if (isset($old_org_options[ $option_name ])) {
114
-                $this->_handle_org_option($option_name, $old_org_options[ $option_name ]);
113
+            if (isset($old_org_options[$option_name])) {
114
+                $this->_handle_org_option($option_name, $old_org_options[$option_name]);
115 115
             }
116
-            if ($option_name=='surcharge') {
116
+            if ($option_name == 'surcharge') {
117 117
                 $this->_insert_new_global_surcharge_price($old_org_options);
118 118
             }
119 119
             $items_actually_migrated++;
120 120
         }
121 121
 
122 122
         $success = EE_Config::instance()->update_espresso_config(false, true);
123
-        if (! $success) {
123
+        if ( ! $success) {
124 124
             $this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(false)));
125 125
             EE_Error::overwrite_errors();
126 126
         }
@@ -176,24 +176,24 @@  discard block
 block discarded – undo
176 176
                 $c->organization->email = $value;
177 177
                 break;
178 178
             case 'default_payment_status':
179
-                $c->registration->default_STS_ID =  $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value);
179
+                $c->registration->default_STS_ID = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value);
180 180
                 break;
181 181
             case 'organization_country':
182
-                $iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value);
182
+                $iso = $this->get_migration_script()->get_iso_from_3_1_country_id($value);
183 183
                 $c->organization->CNT_ISO = $iso;
184 184
                 $country_row = $this->get_migration_script()->get_or_create_country($iso);
185
-                if (! $country_row) {
185
+                if ( ! $country_row) {
186 186
                     $this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso));
187 187
                 }
188 188
                 // can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them)
189
-                $c->currency->code = $country_row['CNT_cur_code'];          // currency code: USD, CAD, EUR
190
-                $c->currency->name = $country_row['CNT_cur_single'];    // Dollar
191
-                $c->currency->plural = $country_row['CNT_cur_plural'];  // Dollars
192
-                $c->currency->sign =  $country_row['CNT_cur_sign'];             // currency sign: $
193
-                $c->currency->sign_b4 = filter_var($country_row['CNT_cur_sign_b4'], FILTER_VALIDATE_BOOLEAN);        // currency sign before or after: $TRUE  or  FALSE$
194
-                $c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc'];    // decimal places: 2 = 0.00  3 = 0.000
195
-                $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk'];    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
196
-                $c->currency->thsnds = $country_row['CNT_cur_thsnds'];  // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
189
+                $c->currency->code = $country_row['CNT_cur_code']; // currency code: USD, CAD, EUR
190
+                $c->currency->name = $country_row['CNT_cur_single']; // Dollar
191
+                $c->currency->plural = $country_row['CNT_cur_plural']; // Dollars
192
+                $c->currency->sign = $country_row['CNT_cur_sign']; // currency sign: $
193
+                $c->currency->sign_b4 = filter_var($country_row['CNT_cur_sign_b4'], FILTER_VALIDATE_BOOLEAN); // currency sign before or after: $TRUE  or  FALSE$
194
+                $c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc']; // decimal places: 2 = 0.00  3 = 0.000
195
+                $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk']; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
196
+                $c->currency->thsnds = $country_row['CNT_cur_thsnds']; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
197 197
   //            $c->currency = new EE_Currency_Config($c->organization->CNT_ISO);break;
198 198
   //        case 'currency_symbol': ignore the currency symbol. we'll just go by their country.
199 199
   //            $c->currency->sign = $value;break;
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
     {
281 281
         $amount = floatval($org_options['surcharge']);
282 282
         // dont createa a price if the surcharge is 0
283
-        if ($amount <=.01) {
283
+        if ($amount <= .01) {
284 284
             return 0;
285 285
         }
286 286
         if ($org_options['surcharge_type'] == 'flat_rate') {
@@ -301,18 +301,18 @@  discard block
 block discarded – undo
301 301
 
302 302
         );
303 303
         $datatypes = array(
304
-            '%d',// PRT_ID
305
-            '%f',// PRT_amount
306
-            '%s',// PRC_name
307
-            '%d',// PRC_is_default
308
-            '%d',// PRC_overrides
309
-            '%d',// PRC_order
310
-            '%d',// PRC_deleted
311
-            '%d',// PRC_parent
304
+            '%d', // PRT_ID
305
+            '%f', // PRT_amount
306
+            '%s', // PRC_name
307
+            '%d', // PRC_is_default
308
+            '%d', // PRC_overrides
309
+            '%d', // PRC_order
310
+            '%d', // PRC_deleted
311
+            '%d', // PRC_parent
312 312
         );
313 313
         $price_table = $wpdb->prefix."esp_price";
314 314
         $success = $wpdb->insert($price_table, $cols_n_values, $datatypes);
315
-        if (! $success) {
315
+        if ( ! $success) {
316 316
             $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion(
317 317
                 'org_options',
318 318
                 array(
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
       'payment_message',
343 343
       'message',
344 344
       'default_payment_status',
345
-      'surcharge',// unused?
346
-      'country_id',// unused?
345
+      'surcharge', // unused?
346
+      'country_id', // unused?
347 347
       'organization_country',
348 348
 //    'currency_symbol',
349 349
       'expire_on_registration_end',
@@ -355,13 +355,13 @@  discard block
 block discarded – undo
355 355
       'show_pending_payment_options',
356 356
       'show_reg_footer',
357 357
       'skip_confirmation_page',
358
-      'allow_mer_discounts',// no equiv
359
-      'allow_mer_vouchers',// no equiv
358
+      'allow_mer_discounts', // no equiv
359
+      'allow_mer_vouchers', // no equiv
360 360
       'display_short_description_in_event_list',
361 361
       'display_description_on_multi_reg_page',
362 362
       'display_address_in_event_list',
363 363
       'display_address_in_regform',
364
-      'use_custom_post_types',// no equiv
364
+      'use_custom_post_types', // no equiv
365 365
       'display_ical_download',
366 366
       'display_featured_image',
367 367
       'themeroller',
@@ -380,11 +380,11 @@  discard block
 block discarded – undo
380 380
       'espresso_dashboard_widget',
381 381
       'time_reg_limit',
382 382
 //    'use_attendee_pre_approval', removed in 4.1- instead this is factored into the default reg status
383
-      'use_personnel_manager',// no equiv
383
+      'use_personnel_manager', // no equiv
384 384
       'use_event_timezones',
385 385
       'full_logging',
386
-      'surcharge_type',// unused
387
-      'surcharge_text',// unused
386
+      'surcharge_type', // unused
387
+      'surcharge_text', // unused
388 388
       'affiliate_id',
389 389
       'site_license_key',
390 390
     );
Please login to merge, or discard this patch.
registration_form/help_tabs/registration_form_add_question.help_tab.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@
 block discarded – undo
25 25
 <?php esc_html_e('This shows the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', 'event_espresso'); ?>
26 26
 </li>
27 27
 <li>
28
-<strong><?php esc_html_e('Answer Options (for applicable question types)', 'event_espresso');?></strong><br/>
29
-<?php esc_html_e('Values do not allow any HTML, however, descriptions do allow HTML.', 'event_espresso');?>
28
+<strong><?php esc_html_e('Answer Options (for applicable question types)', 'event_espresso'); ?></strong><br/>
29
+<?php esc_html_e('Values do not allow any HTML, however, descriptions do allow HTML.', 'event_espresso'); ?>
30 30
 </li>
31 31
 <li>
32 32
 <strong><?php esc_html_e('Required Question', 'event_espresso'); ?></strong><br />
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 <p><strong><?php esc_html_e('Add New Question', 'event_espresso'); ?></strong></p>
5 5
 <p>
6 6
 <?php printf(
7
-    esc_html__('This page allows you to add a new question for %s.', 'event_espresso'),
8
-    Domain::brandName()
7
+	esc_html__('This page allows you to add a new question for %s.', 'event_espresso'),
8
+	Domain::brandName()
9 9
 ); ?>
10 10
 </p>
11 11
 <ul>
Please login to merge, or discard this patch.
registration_form/help_tabs/registration_form_edit_question.help_tab.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@
 block discarded – undo
29 29
 <?php esc_html_e('This shows the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, Date Picker, and HTML Textarea (allowed tags: a, abbr, acronym, b, br, blockquote ,cite, code, del ,em, i, li, ol, p, q, s, strike, strong, ul).', 'event_espresso'); ?>
30 30
 </li>
31 31
 <li>
32
-<strong><?php esc_html_e('Answer Options (for applicable question types)', 'event_espresso');?></strong>
33
-<strong><?php esc_html_e('Values do not allow any HTML, however, descriptions do allow HTML.', 'event_espresso');?></strong>
32
+<strong><?php esc_html_e('Answer Options (for applicable question types)', 'event_espresso'); ?></strong>
33
+<strong><?php esc_html_e('Values do not allow any HTML, however, descriptions do allow HTML.', 'event_espresso'); ?></strong>
34 34
 </li>
35 35
 <li>
36 36
 <strong><?php esc_html_e('Required Question', 'event_espresso'); ?></strong><br />
Please login to merge, or discard this patch.