@@ -15,96 +15,96 @@ |
||
15 | 15 | class Pricing_Add_New_Default_Price_Help_Tour extends EE_Help_Tour |
16 | 16 | { |
17 | 17 | |
18 | - protected function _set_tour_properties() |
|
19 | - { |
|
20 | - $this->_label = __('Add New Default Price Tour', 'event_espresso'); |
|
21 | - $this->_slug = 'add-new-default-price-joyride'; |
|
22 | - } |
|
18 | + protected function _set_tour_properties() |
|
19 | + { |
|
20 | + $this->_label = __('Add New Default Price Tour', 'event_espresso'); |
|
21 | + $this->_slug = 'add-new-default-price-joyride'; |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | - protected function _set_tour_stops() |
|
26 | - { |
|
27 | - $this->_stops = array( |
|
28 | - 10 => array( |
|
29 | - 'content' => $this->_start(), |
|
30 | - ), |
|
31 | - 20 => array( |
|
32 | - 'id' => 'PRT_ID', |
|
33 | - 'content' => $this->_price_type_stop(), |
|
34 | - 'options' => array( |
|
35 | - 'tipLocation' => 'top', |
|
36 | - 'tipAdjustmentY' => -50, |
|
37 | - 'tipAdjustmentX' => -15, |
|
38 | - ), |
|
39 | - ), |
|
40 | - 30 => array( |
|
41 | - 'id' => 'PRC_name', |
|
42 | - 'content' => $this->_price_name_stop(), |
|
43 | - 'options' => array( |
|
44 | - 'tipLocation' => 'top', |
|
45 | - 'tipAdjustmentY' => -40, |
|
46 | - ), |
|
47 | - ), |
|
48 | - 40 => array( |
|
49 | - 'id' => 'PRC_desc', |
|
50 | - 'content' => $this->_price_description_stop(), |
|
51 | - 'options' => array( |
|
52 | - 'tipLocation' => 'top', |
|
53 | - 'tipAdjustmentY' => -40, |
|
54 | - ), |
|
55 | - ), |
|
56 | - 50 => array( |
|
57 | - 'id' => 'PRC_amount', |
|
58 | - 'content' => $this->_price_amount_stop(), |
|
59 | - 'options' => array( |
|
60 | - 'tipLocation' => 'top', |
|
61 | - 'tipAdjustmentY' => -40, |
|
62 | - ), |
|
63 | - ), |
|
64 | - ); |
|
65 | - } |
|
25 | + protected function _set_tour_stops() |
|
26 | + { |
|
27 | + $this->_stops = array( |
|
28 | + 10 => array( |
|
29 | + 'content' => $this->_start(), |
|
30 | + ), |
|
31 | + 20 => array( |
|
32 | + 'id' => 'PRT_ID', |
|
33 | + 'content' => $this->_price_type_stop(), |
|
34 | + 'options' => array( |
|
35 | + 'tipLocation' => 'top', |
|
36 | + 'tipAdjustmentY' => -50, |
|
37 | + 'tipAdjustmentX' => -15, |
|
38 | + ), |
|
39 | + ), |
|
40 | + 30 => array( |
|
41 | + 'id' => 'PRC_name', |
|
42 | + 'content' => $this->_price_name_stop(), |
|
43 | + 'options' => array( |
|
44 | + 'tipLocation' => 'top', |
|
45 | + 'tipAdjustmentY' => -40, |
|
46 | + ), |
|
47 | + ), |
|
48 | + 40 => array( |
|
49 | + 'id' => 'PRC_desc', |
|
50 | + 'content' => $this->_price_description_stop(), |
|
51 | + 'options' => array( |
|
52 | + 'tipLocation' => 'top', |
|
53 | + 'tipAdjustmentY' => -40, |
|
54 | + ), |
|
55 | + ), |
|
56 | + 50 => array( |
|
57 | + 'id' => 'PRC_amount', |
|
58 | + 'content' => $this->_price_amount_stop(), |
|
59 | + 'options' => array( |
|
60 | + 'tipLocation' => 'top', |
|
61 | + 'tipAdjustmentY' => -40, |
|
62 | + ), |
|
63 | + ), |
|
64 | + ); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - protected function _start() |
|
69 | - { |
|
70 | - $content = '<h3>' . __('Add New Default Price', 'event_espresso') . '</h3>'; |
|
71 | - $content .= '<p>' |
|
72 | - . __( |
|
73 | - 'This tour of the add new default price page will go over different areas of the screen to help you understand what they are used for.', |
|
74 | - 'event_espresso' |
|
75 | - ) . '</p>'; |
|
76 | - return $content; |
|
77 | - } |
|
68 | + protected function _start() |
|
69 | + { |
|
70 | + $content = '<h3>' . __('Add New Default Price', 'event_espresso') . '</h3>'; |
|
71 | + $content .= '<p>' |
|
72 | + . __( |
|
73 | + 'This tour of the add new default price page will go over different areas of the screen to help you understand what they are used for.', |
|
74 | + 'event_espresso' |
|
75 | + ) . '</p>'; |
|
76 | + return $content; |
|
77 | + } |
|
78 | 78 | |
79 | - protected function _price_type_stop() |
|
80 | - { |
|
81 | - return '<p>' |
|
82 | - . __( |
|
83 | - 'Price Types are a way of categorizing a price, discount, tax, or surcharge and indicating how it gets applied to a running total when a transaction occurs.', |
|
84 | - 'event_espresso' |
|
85 | - ) . '</p>'; |
|
86 | - } |
|
79 | + protected function _price_type_stop() |
|
80 | + { |
|
81 | + return '<p>' |
|
82 | + . __( |
|
83 | + 'Price Types are a way of categorizing a price, discount, tax, or surcharge and indicating how it gets applied to a running total when a transaction occurs.', |
|
84 | + 'event_espresso' |
|
85 | + ) . '</p>'; |
|
86 | + } |
|
87 | 87 | |
88 | - protected function _price_name_stop() |
|
89 | - { |
|
90 | - return '<p>' |
|
91 | - . __( |
|
92 | - 'The name of the price, discount, tax, or surcharge that will be seen by your customers.', |
|
93 | - 'event_espresso' |
|
94 | - ) . '</p>'; |
|
95 | - } |
|
88 | + protected function _price_name_stop() |
|
89 | + { |
|
90 | + return '<p>' |
|
91 | + . __( |
|
92 | + 'The name of the price, discount, tax, or surcharge that will be seen by your customers.', |
|
93 | + 'event_espresso' |
|
94 | + ) . '</p>'; |
|
95 | + } |
|
96 | 96 | |
97 | - protected function _price_description_stop() |
|
98 | - { |
|
99 | - return '<p>' |
|
100 | - . __( |
|
101 | - 'View the price type (price, discount, tax or surcharge) description.', |
|
102 | - 'event_espresso' |
|
103 | - ) . '</p>'; |
|
104 | - } |
|
97 | + protected function _price_description_stop() |
|
98 | + { |
|
99 | + return '<p>' |
|
100 | + . __( |
|
101 | + 'View the price type (price, discount, tax or surcharge) description.', |
|
102 | + 'event_espresso' |
|
103 | + ) . '</p>'; |
|
104 | + } |
|
105 | 105 | |
106 | - protected function _price_amount_stop() |
|
107 | - { |
|
108 | - return '<p>' . __('The ticket amount before any deductions.', 'event_espresso') . '</p>'; |
|
109 | - } |
|
106 | + protected function _price_amount_stop() |
|
107 | + { |
|
108 | + return '<p>' . __('The ticket amount before any deductions.', 'event_espresso') . '</p>'; |
|
109 | + } |
|
110 | 110 | } |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | |
68 | 68 | protected function _start() |
69 | 69 | { |
70 | - $content = '<h3>' . __('Add New Default Price', 'event_espresso') . '</h3>'; |
|
70 | + $content = '<h3>'.__('Add New Default Price', 'event_espresso').'</h3>'; |
|
71 | 71 | $content .= '<p>' |
72 | 72 | . __( |
73 | 73 | 'This tour of the add new default price page will go over different areas of the screen to help you understand what they are used for.', |
74 | 74 | 'event_espresso' |
75 | - ) . '</p>'; |
|
75 | + ).'</p>'; |
|
76 | 76 | return $content; |
77 | 77 | } |
78 | 78 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | . __( |
83 | 83 | 'Price Types are a way of categorizing a price, discount, tax, or surcharge and indicating how it gets applied to a running total when a transaction occurs.', |
84 | 84 | 'event_espresso' |
85 | - ) . '</p>'; |
|
85 | + ).'</p>'; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | protected function _price_name_stop() |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | . __( |
92 | 92 | 'The name of the price, discount, tax, or surcharge that will be seen by your customers.', |
93 | 93 | 'event_espresso' |
94 | - ) . '</p>'; |
|
94 | + ).'</p>'; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | protected function _price_description_stop() |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | . __( |
101 | 101 | 'View the price type (price, discount, tax or surcharge) description.', |
102 | 102 | 'event_espresso' |
103 | - ) . '</p>'; |
|
103 | + ).'</p>'; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | protected function _price_amount_stop() |
107 | 107 | { |
108 | - return '<p>' . __('The ticket amount before any deductions.', 'event_espresso') . '</p>'; |
|
108 | + return '<p>'.__('The ticket amount before any deductions.', 'event_espresso').'</p>'; |
|
109 | 109 | } |
110 | 110 | } |
@@ -15,135 +15,135 @@ |
||
15 | 15 | class Pricing_Default_Prices_Help_Tour extends EE_Help_Tour |
16 | 16 | { |
17 | 17 | |
18 | - protected function _set_tour_properties() |
|
19 | - { |
|
20 | - $this->_label = __('Default Pricing Tour', 'event_espresso'); |
|
21 | - $this->_slug = 'default-prices-joyride'; |
|
22 | - } |
|
18 | + protected function _set_tour_properties() |
|
19 | + { |
|
20 | + $this->_label = __('Default Pricing Tour', 'event_espresso'); |
|
21 | + $this->_slug = 'default-prices-joyride'; |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | - protected function _set_tour_stops() |
|
26 | - { |
|
27 | - $this->_stops = array( |
|
28 | - 10 => array( |
|
29 | - 'content' => $this->_start(), |
|
30 | - ), |
|
31 | - 20 => array( |
|
32 | - 'id' => 'name', |
|
33 | - 'content' => $this->_name_column_stop(), |
|
34 | - 'options' => array( |
|
35 | - 'tipLocation' => 'top', |
|
36 | - 'tipAdjustmentX' => -5, |
|
37 | - 'tipAdjustmentY' => -30, |
|
38 | - ), |
|
39 | - ), |
|
40 | - 30 => array( |
|
41 | - 'id' => 'type', |
|
42 | - 'content' => $this->_type_column_stop(), |
|
43 | - 'options' => array( |
|
44 | - 'tipLocation' => 'top', |
|
45 | - 'tipAdjustmentX' => 5, |
|
46 | - 'tipAdjustmentY' => -30, |
|
47 | - ), |
|
48 | - ), |
|
49 | - 40 => array( |
|
50 | - 'id' => 'description', |
|
51 | - 'content' => $this->_description_column_stop(), |
|
52 | - 'options' => array( |
|
53 | - 'tipLocation' => 'top', |
|
54 | - 'tipAdjustmentX' => 5, |
|
55 | - 'tipAdjustmentY' => -30, |
|
56 | - ), |
|
57 | - ), |
|
58 | - 50 => array( |
|
59 | - 'id' => 'amount', |
|
60 | - 'content' => $this->_amount_column_stop(), |
|
61 | - 'options' => array( |
|
62 | - 'tipLocation' => 'left', |
|
63 | - 'tipAdjustmentY' => -50, |
|
64 | - 'tipAdjustmentX' => 20, |
|
65 | - ), |
|
66 | - ), |
|
67 | - 60 => array( |
|
68 | - 'class' => 'bulkactions', |
|
69 | - 'content' => $this->_bulk_actions_stop(), |
|
70 | - 'options' => array( |
|
71 | - 'tipLocation' => 'left', |
|
72 | - 'tipAdjustmentY' => -50, |
|
73 | - 'tipAdjustmentX' => -75, |
|
74 | - ), |
|
75 | - ), |
|
76 | - 70 => array( |
|
77 | - 'id' => 'event-espresso_page_pricing-search-input', |
|
78 | - 'content' => $this->_search_stop(), |
|
79 | - 'options' => array( |
|
80 | - 'tipLocation' => 'left', |
|
81 | - 'tipAdjustmentY' => -50, |
|
82 | - 'tipAdjustmentX' => -15, |
|
83 | - ), |
|
84 | - ), |
|
85 | - ); |
|
86 | - } |
|
25 | + protected function _set_tour_stops() |
|
26 | + { |
|
27 | + $this->_stops = array( |
|
28 | + 10 => array( |
|
29 | + 'content' => $this->_start(), |
|
30 | + ), |
|
31 | + 20 => array( |
|
32 | + 'id' => 'name', |
|
33 | + 'content' => $this->_name_column_stop(), |
|
34 | + 'options' => array( |
|
35 | + 'tipLocation' => 'top', |
|
36 | + 'tipAdjustmentX' => -5, |
|
37 | + 'tipAdjustmentY' => -30, |
|
38 | + ), |
|
39 | + ), |
|
40 | + 30 => array( |
|
41 | + 'id' => 'type', |
|
42 | + 'content' => $this->_type_column_stop(), |
|
43 | + 'options' => array( |
|
44 | + 'tipLocation' => 'top', |
|
45 | + 'tipAdjustmentX' => 5, |
|
46 | + 'tipAdjustmentY' => -30, |
|
47 | + ), |
|
48 | + ), |
|
49 | + 40 => array( |
|
50 | + 'id' => 'description', |
|
51 | + 'content' => $this->_description_column_stop(), |
|
52 | + 'options' => array( |
|
53 | + 'tipLocation' => 'top', |
|
54 | + 'tipAdjustmentX' => 5, |
|
55 | + 'tipAdjustmentY' => -30, |
|
56 | + ), |
|
57 | + ), |
|
58 | + 50 => array( |
|
59 | + 'id' => 'amount', |
|
60 | + 'content' => $this->_amount_column_stop(), |
|
61 | + 'options' => array( |
|
62 | + 'tipLocation' => 'left', |
|
63 | + 'tipAdjustmentY' => -50, |
|
64 | + 'tipAdjustmentX' => 20, |
|
65 | + ), |
|
66 | + ), |
|
67 | + 60 => array( |
|
68 | + 'class' => 'bulkactions', |
|
69 | + 'content' => $this->_bulk_actions_stop(), |
|
70 | + 'options' => array( |
|
71 | + 'tipLocation' => 'left', |
|
72 | + 'tipAdjustmentY' => -50, |
|
73 | + 'tipAdjustmentX' => -75, |
|
74 | + ), |
|
75 | + ), |
|
76 | + 70 => array( |
|
77 | + 'id' => 'event-espresso_page_pricing-search-input', |
|
78 | + 'content' => $this->_search_stop(), |
|
79 | + 'options' => array( |
|
80 | + 'tipLocation' => 'left', |
|
81 | + 'tipAdjustmentY' => -50, |
|
82 | + 'tipAdjustmentX' => -15, |
|
83 | + ), |
|
84 | + ), |
|
85 | + ); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - protected function _start() |
|
90 | - { |
|
91 | - $content = '<h3>' . __('Default Pricing', 'event_espresso') . '</h3>'; |
|
92 | - $content .= '<p>' |
|
93 | - . __( |
|
94 | - 'This tour of the Default Pricing page will go over different areas of the screen to help you understand what they are used for.', |
|
95 | - 'event_espresso' |
|
96 | - ) . '</p>'; |
|
97 | - return $content; |
|
98 | - } |
|
89 | + protected function _start() |
|
90 | + { |
|
91 | + $content = '<h3>' . __('Default Pricing', 'event_espresso') . '</h3>'; |
|
92 | + $content .= '<p>' |
|
93 | + . __( |
|
94 | + 'This tour of the Default Pricing page will go over different areas of the screen to help you understand what they are used for.', |
|
95 | + 'event_espresso' |
|
96 | + ) . '</p>'; |
|
97 | + return $content; |
|
98 | + } |
|
99 | 99 | |
100 | - protected function _name_column_stop() |
|
101 | - { |
|
102 | - return '<p>' |
|
103 | - . __( |
|
104 | - 'The name of the price, discount, tax, or surcharge that will be seen by your customers. Can be sorted in ascending or descending order.', |
|
105 | - 'event_espresso' |
|
106 | - ) . '</p>'; |
|
107 | - } |
|
100 | + protected function _name_column_stop() |
|
101 | + { |
|
102 | + return '<p>' |
|
103 | + . __( |
|
104 | + 'The name of the price, discount, tax, or surcharge that will be seen by your customers. Can be sorted in ascending or descending order.', |
|
105 | + 'event_espresso' |
|
106 | + ) . '</p>'; |
|
107 | + } |
|
108 | 108 | |
109 | - protected function _type_column_stop() |
|
110 | - { |
|
111 | - return '<p>' |
|
112 | - . __( |
|
113 | - 'Price Types are a way of categorizing a price, discount, tax, or surcharge and indicating how it gets applied to a running total when a transaction occurs. Can be sorted in ascending or descending order.', |
|
114 | - 'event_espresso' |
|
115 | - ) . '</p>'; |
|
116 | - } |
|
109 | + protected function _type_column_stop() |
|
110 | + { |
|
111 | + return '<p>' |
|
112 | + . __( |
|
113 | + 'Price Types are a way of categorizing a price, discount, tax, or surcharge and indicating how it gets applied to a running total when a transaction occurs. Can be sorted in ascending or descending order.', |
|
114 | + 'event_espresso' |
|
115 | + ) . '</p>'; |
|
116 | + } |
|
117 | 117 | |
118 | - protected function _description_column_stop() |
|
119 | - { |
|
120 | - return '<p>' |
|
121 | - . __( |
|
122 | - 'View the price type (price, discount, tax or surcharge) description.', |
|
123 | - 'event_espresso' |
|
124 | - ) . '</p>'; |
|
125 | - } |
|
118 | + protected function _description_column_stop() |
|
119 | + { |
|
120 | + return '<p>' |
|
121 | + . __( |
|
122 | + 'View the price type (price, discount, tax or surcharge) description.', |
|
123 | + 'event_espresso' |
|
124 | + ) . '</p>'; |
|
125 | + } |
|
126 | 126 | |
127 | - protected function _amount_column_stop() |
|
128 | - { |
|
129 | - return '<p>' |
|
130 | - . __( |
|
131 | - 'The ticket amount before any deductions. Can be sorted in ascending or descending order.', |
|
132 | - 'event_espresso' |
|
133 | - ) . '</p>'; |
|
134 | - } |
|
127 | + protected function _amount_column_stop() |
|
128 | + { |
|
129 | + return '<p>' |
|
130 | + . __( |
|
131 | + 'The ticket amount before any deductions. Can be sorted in ascending or descending order.', |
|
132 | + 'event_espresso' |
|
133 | + ) . '</p>'; |
|
134 | + } |
|
135 | 135 | |
136 | - protected function _bulk_actions_stop() |
|
137 | - { |
|
138 | - return '<p>' . __('Perform bulk actions to multiple price types.', 'event_espresso') . '</p>'; |
|
139 | - } |
|
136 | + protected function _bulk_actions_stop() |
|
137 | + { |
|
138 | + return '<p>' . __('Perform bulk actions to multiple price types.', 'event_espresso') . '</p>'; |
|
139 | + } |
|
140 | 140 | |
141 | - protected function _search_stop() |
|
142 | - { |
|
143 | - return '<p>' |
|
144 | - . __( |
|
145 | - 'Search through default pricing. The following sources will be searched: Price Name, Price Type, Price Description, and Price Amount.', |
|
146 | - 'event_espresso' |
|
147 | - ) . '</p>'; |
|
148 | - } |
|
141 | + protected function _search_stop() |
|
142 | + { |
|
143 | + return '<p>' |
|
144 | + . __( |
|
145 | + 'Search through default pricing. The following sources will be searched: Price Name, Price Type, Price Description, and Price Amount.', |
|
146 | + 'event_espresso' |
|
147 | + ) . '</p>'; |
|
148 | + } |
|
149 | 149 | } |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | |
89 | 89 | protected function _start() |
90 | 90 | { |
91 | - $content = '<h3>' . __('Default Pricing', 'event_espresso') . '</h3>'; |
|
91 | + $content = '<h3>'.__('Default Pricing', 'event_espresso').'</h3>'; |
|
92 | 92 | $content .= '<p>' |
93 | 93 | . __( |
94 | 94 | 'This tour of the Default Pricing page will go over different areas of the screen to help you understand what they are used for.', |
95 | 95 | 'event_espresso' |
96 | - ) . '</p>'; |
|
96 | + ).'</p>'; |
|
97 | 97 | return $content; |
98 | 98 | } |
99 | 99 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | . __( |
104 | 104 | 'The name of the price, discount, tax, or surcharge that will be seen by your customers. Can be sorted in ascending or descending order.', |
105 | 105 | 'event_espresso' |
106 | - ) . '</p>'; |
|
106 | + ).'</p>'; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | protected function _type_column_stop() |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | . __( |
113 | 113 | 'Price Types are a way of categorizing a price, discount, tax, or surcharge and indicating how it gets applied to a running total when a transaction occurs. Can be sorted in ascending or descending order.', |
114 | 114 | 'event_espresso' |
115 | - ) . '</p>'; |
|
115 | + ).'</p>'; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | protected function _description_column_stop() |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | . __( |
122 | 122 | 'View the price type (price, discount, tax or surcharge) description.', |
123 | 123 | 'event_espresso' |
124 | - ) . '</p>'; |
|
124 | + ).'</p>'; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | protected function _amount_column_stop() |
@@ -130,12 +130,12 @@ discard block |
||
130 | 130 | . __( |
131 | 131 | 'The ticket amount before any deductions. Can be sorted in ascending or descending order.', |
132 | 132 | 'event_espresso' |
133 | - ) . '</p>'; |
|
133 | + ).'</p>'; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | protected function _bulk_actions_stop() |
137 | 137 | { |
138 | - return '<p>' . __('Perform bulk actions to multiple price types.', 'event_espresso') . '</p>'; |
|
138 | + return '<p>'.__('Perform bulk actions to multiple price types.', 'event_espresso').'</p>'; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | protected function _search_stop() |
@@ -144,6 +144,6 @@ discard block |
||
144 | 144 | . __( |
145 | 145 | 'Search through default pricing. The following sources will be searched: Price Name, Price Type, Price Description, and Price Amount.', |
146 | 146 | 'event_espresso' |
147 | - ) . '</p>'; |
|
147 | + ).'</p>'; |
|
148 | 148 | } |
149 | 149 | } |
@@ -15,84 +15,84 @@ |
||
15 | 15 | class Pricing_Edit_Price_Type_Help_Tour extends EE_Help_Tour |
16 | 16 | { |
17 | 17 | |
18 | - protected function _set_tour_properties() |
|
19 | - { |
|
20 | - $this->_label = __('Edit Price Type Tour', 'event_espresso'); |
|
21 | - $this->_slug = 'edit-price-type-joyride'; |
|
22 | - } |
|
18 | + protected function _set_tour_properties() |
|
19 | + { |
|
20 | + $this->_label = __('Edit Price Type Tour', 'event_espresso'); |
|
21 | + $this->_slug = 'edit-price-type-joyride'; |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | - protected function _set_tour_stops() |
|
26 | - { |
|
27 | - $this->_stops = array( |
|
28 | - 10 => array( |
|
29 | - 'content' => $this->_start(), |
|
30 | - ), |
|
31 | - 20 => array( |
|
32 | - 'id' => 'base_type', |
|
33 | - 'content' => $this->_basic_type_stop(), |
|
34 | - 'options' => array( |
|
35 | - 'tipLocation' => 'top', |
|
36 | - 'tipAdjustmentY' => -50, |
|
37 | - 'tipAdjustmentX' => -15, |
|
38 | - ), |
|
39 | - ), |
|
40 | - 30 => array( |
|
41 | - 'id' => 'PRT_name', |
|
42 | - 'content' => $this->_price_type_name_stop(), |
|
43 | - 'options' => array( |
|
44 | - 'tipLocation' => 'top', |
|
45 | - 'tipAdjustmentY' => -40, |
|
46 | - ), |
|
47 | - ), |
|
48 | - 40 => array( |
|
49 | - 'id' => 'PRT_name', |
|
50 | - 'content' => $this->_percentage_dollar_amount_stop(), |
|
51 | - 'options' => array( |
|
52 | - 'tipLocation' => 'top', |
|
53 | - 'tipAdjustmentY' => 45, |
|
54 | - ), |
|
55 | - ), |
|
56 | - 50 => array( |
|
57 | - 'id' => 'PRT_order', |
|
58 | - 'content' => $this->_order_of_application_stop(), |
|
59 | - 'options' => array( |
|
60 | - 'tipLocation' => 'top', |
|
61 | - 'tipAdjustmentY' => -40, |
|
62 | - ), |
|
63 | - ), |
|
64 | - ); |
|
65 | - } |
|
25 | + protected function _set_tour_stops() |
|
26 | + { |
|
27 | + $this->_stops = array( |
|
28 | + 10 => array( |
|
29 | + 'content' => $this->_start(), |
|
30 | + ), |
|
31 | + 20 => array( |
|
32 | + 'id' => 'base_type', |
|
33 | + 'content' => $this->_basic_type_stop(), |
|
34 | + 'options' => array( |
|
35 | + 'tipLocation' => 'top', |
|
36 | + 'tipAdjustmentY' => -50, |
|
37 | + 'tipAdjustmentX' => -15, |
|
38 | + ), |
|
39 | + ), |
|
40 | + 30 => array( |
|
41 | + 'id' => 'PRT_name', |
|
42 | + 'content' => $this->_price_type_name_stop(), |
|
43 | + 'options' => array( |
|
44 | + 'tipLocation' => 'top', |
|
45 | + 'tipAdjustmentY' => -40, |
|
46 | + ), |
|
47 | + ), |
|
48 | + 40 => array( |
|
49 | + 'id' => 'PRT_name', |
|
50 | + 'content' => $this->_percentage_dollar_amount_stop(), |
|
51 | + 'options' => array( |
|
52 | + 'tipLocation' => 'top', |
|
53 | + 'tipAdjustmentY' => 45, |
|
54 | + ), |
|
55 | + ), |
|
56 | + 50 => array( |
|
57 | + 'id' => 'PRT_order', |
|
58 | + 'content' => $this->_order_of_application_stop(), |
|
59 | + 'options' => array( |
|
60 | + 'tipLocation' => 'top', |
|
61 | + 'tipAdjustmentY' => -40, |
|
62 | + ), |
|
63 | + ), |
|
64 | + ); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - protected function _start() |
|
69 | - { |
|
70 | - $content = '<h3>' . __('Edit Price Type', 'event_espresso') . '</h3>'; |
|
71 | - $content .= '<p>' |
|
72 | - . __( |
|
73 | - 'This tour of the Edit Price Type page will go over different areas of the screen to help you understand what they are used for.', |
|
74 | - 'event_espresso' |
|
75 | - ) . '</p>'; |
|
76 | - return $content; |
|
77 | - } |
|
68 | + protected function _start() |
|
69 | + { |
|
70 | + $content = '<h3>' . __('Edit Price Type', 'event_espresso') . '</h3>'; |
|
71 | + $content .= '<p>' |
|
72 | + . __( |
|
73 | + 'This tour of the Edit Price Type page will go over different areas of the screen to help you understand what they are used for.', |
|
74 | + 'event_espresso' |
|
75 | + ) . '</p>'; |
|
76 | + return $content; |
|
77 | + } |
|
78 | 78 | |
79 | - protected function _basic_type_stop() |
|
80 | - { |
|
81 | - return '<p>' . __('Set a price type to be a discount, surcharge, or tax.', 'event_espresso') . '</p>'; |
|
82 | - } |
|
79 | + protected function _basic_type_stop() |
|
80 | + { |
|
81 | + return '<p>' . __('Set a price type to be a discount, surcharge, or tax.', 'event_espresso') . '</p>'; |
|
82 | + } |
|
83 | 83 | |
84 | - protected function _price_type_name_stop() |
|
85 | - { |
|
86 | - return '<p>' . __('The name of the price type.', 'event_espresso') . '</p>'; |
|
87 | - } |
|
84 | + protected function _price_type_name_stop() |
|
85 | + { |
|
86 | + return '<p>' . __('The name of the price type.', 'event_espresso') . '</p>'; |
|
87 | + } |
|
88 | 88 | |
89 | - protected function _percentage_dollar_amount_stop() |
|
90 | - { |
|
91 | - return '<p>' . __('Set a price type to be percentage-based or a fixed amount.', 'event_espresso') . '</p>'; |
|
92 | - } |
|
89 | + protected function _percentage_dollar_amount_stop() |
|
90 | + { |
|
91 | + return '<p>' . __('Set a price type to be percentage-based or a fixed amount.', 'event_espresso') . '</p>'; |
|
92 | + } |
|
93 | 93 | |
94 | - protected function _order_of_application_stop() |
|
95 | - { |
|
96 | - return '<p>' . __('Set the order of application for a price type.', 'event_espresso') . '</p>'; |
|
97 | - } |
|
94 | + protected function _order_of_application_stop() |
|
95 | + { |
|
96 | + return '<p>' . __('Set the order of application for a price type.', 'event_espresso') . '</p>'; |
|
97 | + } |
|
98 | 98 | } |
@@ -67,32 +67,32 @@ |
||
67 | 67 | |
68 | 68 | protected function _start() |
69 | 69 | { |
70 | - $content = '<h3>' . __('Edit Price Type', 'event_espresso') . '</h3>'; |
|
70 | + $content = '<h3>'.__('Edit Price Type', 'event_espresso').'</h3>'; |
|
71 | 71 | $content .= '<p>' |
72 | 72 | . __( |
73 | 73 | 'This tour of the Edit Price Type page will go over different areas of the screen to help you understand what they are used for.', |
74 | 74 | 'event_espresso' |
75 | - ) . '</p>'; |
|
75 | + ).'</p>'; |
|
76 | 76 | return $content; |
77 | 77 | } |
78 | 78 | |
79 | 79 | protected function _basic_type_stop() |
80 | 80 | { |
81 | - return '<p>' . __('Set a price type to be a discount, surcharge, or tax.', 'event_espresso') . '</p>'; |
|
81 | + return '<p>'.__('Set a price type to be a discount, surcharge, or tax.', 'event_espresso').'</p>'; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | protected function _price_type_name_stop() |
85 | 85 | { |
86 | - return '<p>' . __('The name of the price type.', 'event_espresso') . '</p>'; |
|
86 | + return '<p>'.__('The name of the price type.', 'event_espresso').'</p>'; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | protected function _percentage_dollar_amount_stop() |
90 | 90 | { |
91 | - return '<p>' . __('Set a price type to be percentage-based or a fixed amount.', 'event_espresso') . '</p>'; |
|
91 | + return '<p>'.__('Set a price type to be percentage-based or a fixed amount.', 'event_espresso').'</p>'; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | protected function _order_of_application_stop() |
95 | 95 | { |
96 | - return '<p>' . __('Set the order of application for a price type.', 'event_espresso') . '</p>'; |
|
96 | + return '<p>'.__('Set the order of application for a price type.', 'event_espresso').'</p>'; |
|
97 | 97 | } |
98 | 98 | } |
@@ -15,140 +15,140 @@ |
||
15 | 15 | class Pricing_Price_Types_Default_Help_Tour extends EE_Help_Tour |
16 | 16 | { |
17 | 17 | |
18 | - protected function _set_tour_properties() |
|
19 | - { |
|
20 | - $this->_label = __('Price Types Tour', 'event_espresso'); |
|
21 | - $this->_slug = 'default-price-types-joyride'; |
|
22 | - } |
|
18 | + protected function _set_tour_properties() |
|
19 | + { |
|
20 | + $this->_label = __('Price Types Tour', 'event_espresso'); |
|
21 | + $this->_slug = 'default-price-types-joyride'; |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | - protected function _set_tour_stops() |
|
26 | - { |
|
27 | - $this->_stops = array( |
|
28 | - 10 => array( |
|
29 | - 'content' => $this->_start(), |
|
30 | - ), |
|
31 | - 20 => array( |
|
32 | - 'id' => 'name', |
|
33 | - 'content' => $this->_name_column_stop(), |
|
34 | - 'options' => array( |
|
35 | - 'tipLocation' => 'top', |
|
36 | - 'tipAdjustmentX' => -5, |
|
37 | - 'tipAdjustmentY' => -30, |
|
38 | - ), |
|
39 | - ), |
|
40 | - 30 => array( |
|
41 | - 'id' => 'base_type', |
|
42 | - 'content' => $this->_base_type_stop(), |
|
43 | - 'options' => array( |
|
44 | - 'tipLocation' => 'top', |
|
45 | - 'tipAdjustmentX' => 120, |
|
46 | - 'tipAdjustmentY' => -30, |
|
47 | - ), |
|
48 | - ), |
|
49 | - 40 => array( |
|
50 | - 'id' => 'percent', |
|
51 | - 'content' => $this->_percent_column_stop(), |
|
52 | - 'options' => array( |
|
53 | - 'tipLocation' => 'top', |
|
54 | - 'tipAdjustmentX' => 120, |
|
55 | - 'tipAdjustmentY' => -30, |
|
56 | - ), |
|
57 | - ), |
|
58 | - 50 => array( |
|
59 | - 'id' => 'order', |
|
60 | - 'content' => $this->_order_column_stop(), |
|
61 | - 'options' => array( |
|
62 | - 'tipLocation' => 'left', |
|
63 | - 'tipAdjustmentY' => -30, |
|
64 | - 'tipAdjustmentX' => 100, |
|
65 | - ), |
|
66 | - ), |
|
67 | - 60 => array( |
|
68 | - 'class' => 'bulkactions', |
|
69 | - 'content' => $this->_bulk_actions_stop(), |
|
70 | - 'options' => array( |
|
71 | - 'tipLocation' => 'left', |
|
72 | - 'tipAdjustmentY' => -50, |
|
73 | - 'tipAdjustmentX' => -75, |
|
74 | - ), |
|
75 | - ), |
|
76 | - 70 => array( |
|
77 | - 'id' => 'event-espresso_page_pricing-search-input', |
|
78 | - 'content' => $this->_search_stop(), |
|
79 | - 'options' => array( |
|
80 | - 'tipLocation' => 'left', |
|
81 | - 'tipAdjustmentY' => -50, |
|
82 | - 'tipAdjustmentX' => -15, |
|
83 | - ), |
|
84 | - ), |
|
85 | - ); |
|
86 | - } |
|
25 | + protected function _set_tour_stops() |
|
26 | + { |
|
27 | + $this->_stops = array( |
|
28 | + 10 => array( |
|
29 | + 'content' => $this->_start(), |
|
30 | + ), |
|
31 | + 20 => array( |
|
32 | + 'id' => 'name', |
|
33 | + 'content' => $this->_name_column_stop(), |
|
34 | + 'options' => array( |
|
35 | + 'tipLocation' => 'top', |
|
36 | + 'tipAdjustmentX' => -5, |
|
37 | + 'tipAdjustmentY' => -30, |
|
38 | + ), |
|
39 | + ), |
|
40 | + 30 => array( |
|
41 | + 'id' => 'base_type', |
|
42 | + 'content' => $this->_base_type_stop(), |
|
43 | + 'options' => array( |
|
44 | + 'tipLocation' => 'top', |
|
45 | + 'tipAdjustmentX' => 120, |
|
46 | + 'tipAdjustmentY' => -30, |
|
47 | + ), |
|
48 | + ), |
|
49 | + 40 => array( |
|
50 | + 'id' => 'percent', |
|
51 | + 'content' => $this->_percent_column_stop(), |
|
52 | + 'options' => array( |
|
53 | + 'tipLocation' => 'top', |
|
54 | + 'tipAdjustmentX' => 120, |
|
55 | + 'tipAdjustmentY' => -30, |
|
56 | + ), |
|
57 | + ), |
|
58 | + 50 => array( |
|
59 | + 'id' => 'order', |
|
60 | + 'content' => $this->_order_column_stop(), |
|
61 | + 'options' => array( |
|
62 | + 'tipLocation' => 'left', |
|
63 | + 'tipAdjustmentY' => -30, |
|
64 | + 'tipAdjustmentX' => 100, |
|
65 | + ), |
|
66 | + ), |
|
67 | + 60 => array( |
|
68 | + 'class' => 'bulkactions', |
|
69 | + 'content' => $this->_bulk_actions_stop(), |
|
70 | + 'options' => array( |
|
71 | + 'tipLocation' => 'left', |
|
72 | + 'tipAdjustmentY' => -50, |
|
73 | + 'tipAdjustmentX' => -75, |
|
74 | + ), |
|
75 | + ), |
|
76 | + 70 => array( |
|
77 | + 'id' => 'event-espresso_page_pricing-search-input', |
|
78 | + 'content' => $this->_search_stop(), |
|
79 | + 'options' => array( |
|
80 | + 'tipLocation' => 'left', |
|
81 | + 'tipAdjustmentY' => -50, |
|
82 | + 'tipAdjustmentX' => -15, |
|
83 | + ), |
|
84 | + ), |
|
85 | + ); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - protected function _start() |
|
90 | - { |
|
91 | - $content = '<h3>' . __('Price Types', 'event_espresso') . '</h3>'; |
|
92 | - $content .= '<p>' |
|
93 | - . __( |
|
94 | - 'This tour of the Price Types page will go over different areas of the screen to help you understand what they are used for.', |
|
95 | - 'event_espresso' |
|
96 | - ) . '</p>'; |
|
97 | - return $content; |
|
98 | - } |
|
89 | + protected function _start() |
|
90 | + { |
|
91 | + $content = '<h3>' . __('Price Types', 'event_espresso') . '</h3>'; |
|
92 | + $content .= '<p>' |
|
93 | + . __( |
|
94 | + 'This tour of the Price Types page will go over different areas of the screen to help you understand what they are used for.', |
|
95 | + 'event_espresso' |
|
96 | + ) . '</p>'; |
|
97 | + return $content; |
|
98 | + } |
|
99 | 99 | |
100 | - protected function _name_column_stop() |
|
101 | - { |
|
102 | - return '<p>' |
|
103 | - . __( |
|
104 | - 'The name of the price type. Can be sorted in ascending or descending order.', |
|
105 | - 'event_espresso' |
|
106 | - ) . '</p>'; |
|
107 | - } |
|
100 | + protected function _name_column_stop() |
|
101 | + { |
|
102 | + return '<p>' |
|
103 | + . __( |
|
104 | + 'The name of the price type. Can be sorted in ascending or descending order.', |
|
105 | + 'event_espresso' |
|
106 | + ) . '</p>'; |
|
107 | + } |
|
108 | 108 | |
109 | - protected function _base_type_stop() |
|
110 | - { |
|
111 | - return '<p>' . __('View if a price type is a discount, surcharge, or tax.', 'event_espresso') . '</p>'; |
|
112 | - } |
|
109 | + protected function _base_type_stop() |
|
110 | + { |
|
111 | + return '<p>' . __('View if a price type is a discount, surcharge, or tax.', 'event_espresso') . '</p>'; |
|
112 | + } |
|
113 | 113 | |
114 | - protected function _member_column_stop() |
|
115 | - { |
|
116 | - return '<p>' |
|
117 | - . __( |
|
118 | - 'Here you can see if the discount/surcharge is percentage based or a flat monetary amount.', |
|
119 | - 'event_espresso' |
|
120 | - ) . '</p>'; |
|
121 | - } |
|
114 | + protected function _member_column_stop() |
|
115 | + { |
|
116 | + return '<p>' |
|
117 | + . __( |
|
118 | + 'Here you can see if the discount/surcharge is percentage based or a flat monetary amount.', |
|
119 | + 'event_espresso' |
|
120 | + ) . '</p>'; |
|
121 | + } |
|
122 | 122 | |
123 | - protected function _percent_column_stop() |
|
124 | - { |
|
125 | - return '<p>' |
|
126 | - . __( |
|
127 | - 'View if the discount, surcharge, or tax is percentage-based or a fixed amount.', |
|
128 | - 'event_espresso' |
|
129 | - ) . '</p>'; |
|
130 | - } |
|
123 | + protected function _percent_column_stop() |
|
124 | + { |
|
125 | + return '<p>' |
|
126 | + . __( |
|
127 | + 'View if the discount, surcharge, or tax is percentage-based or a fixed amount.', |
|
128 | + 'event_espresso' |
|
129 | + ) . '</p>'; |
|
130 | + } |
|
131 | 131 | |
132 | - protected function _order_column_stop() |
|
133 | - { |
|
134 | - return '<p>' |
|
135 | - . __( |
|
136 | - 'View the order in which each discount, surcharge, or tax will be applied to the base ticket cost. Zero (0) means it will be applied first.', |
|
137 | - 'event_espresso' |
|
138 | - ) . '</p>'; |
|
139 | - } |
|
132 | + protected function _order_column_stop() |
|
133 | + { |
|
134 | + return '<p>' |
|
135 | + . __( |
|
136 | + 'View the order in which each discount, surcharge, or tax will be applied to the base ticket cost. Zero (0) means it will be applied first.', |
|
137 | + 'event_espresso' |
|
138 | + ) . '</p>'; |
|
139 | + } |
|
140 | 140 | |
141 | - protected function _bulk_actions_stop() |
|
142 | - { |
|
143 | - return '<p>' . __('Perform bulk actions to multiple price types.', 'event_espresso') . '</p>'; |
|
144 | - } |
|
141 | + protected function _bulk_actions_stop() |
|
142 | + { |
|
143 | + return '<p>' . __('Perform bulk actions to multiple price types.', 'event_espresso') . '</p>'; |
|
144 | + } |
|
145 | 145 | |
146 | - protected function _search_stop() |
|
147 | - { |
|
148 | - return '<p>' |
|
149 | - . __( |
|
150 | - 'Search through price types. The following source will be searched: Price Type Name.', |
|
151 | - 'event_espresso' |
|
152 | - ) . '</p>'; |
|
153 | - } |
|
146 | + protected function _search_stop() |
|
147 | + { |
|
148 | + return '<p>' |
|
149 | + . __( |
|
150 | + 'Search through price types. The following source will be searched: Price Type Name.', |
|
151 | + 'event_espresso' |
|
152 | + ) . '</p>'; |
|
153 | + } |
|
154 | 154 | } |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | |
89 | 89 | protected function _start() |
90 | 90 | { |
91 | - $content = '<h3>' . __('Price Types', 'event_espresso') . '</h3>'; |
|
91 | + $content = '<h3>'.__('Price Types', 'event_espresso').'</h3>'; |
|
92 | 92 | $content .= '<p>' |
93 | 93 | . __( |
94 | 94 | 'This tour of the Price Types page will go over different areas of the screen to help you understand what they are used for.', |
95 | 95 | 'event_espresso' |
96 | - ) . '</p>'; |
|
96 | + ).'</p>'; |
|
97 | 97 | return $content; |
98 | 98 | } |
99 | 99 | |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | . __( |
104 | 104 | 'The name of the price type. Can be sorted in ascending or descending order.', |
105 | 105 | 'event_espresso' |
106 | - ) . '</p>'; |
|
106 | + ).'</p>'; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | protected function _base_type_stop() |
110 | 110 | { |
111 | - return '<p>' . __('View if a price type is a discount, surcharge, or tax.', 'event_espresso') . '</p>'; |
|
111 | + return '<p>'.__('View if a price type is a discount, surcharge, or tax.', 'event_espresso').'</p>'; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | protected function _member_column_stop() |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | . __( |
118 | 118 | 'Here you can see if the discount/surcharge is percentage based or a flat monetary amount.', |
119 | 119 | 'event_espresso' |
120 | - ) . '</p>'; |
|
120 | + ).'</p>'; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | protected function _percent_column_stop() |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | . __( |
127 | 127 | 'View if the discount, surcharge, or tax is percentage-based or a fixed amount.', |
128 | 128 | 'event_espresso' |
129 | - ) . '</p>'; |
|
129 | + ).'</p>'; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | protected function _order_column_stop() |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | . __( |
136 | 136 | 'View the order in which each discount, surcharge, or tax will be applied to the base ticket cost. Zero (0) means it will be applied first.', |
137 | 137 | 'event_espresso' |
138 | - ) . '</p>'; |
|
138 | + ).'</p>'; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | protected function _bulk_actions_stop() |
142 | 142 | { |
143 | - return '<p>' . __('Perform bulk actions to multiple price types.', 'event_espresso') . '</p>'; |
|
143 | + return '<p>'.__('Perform bulk actions to multiple price types.', 'event_espresso').'</p>'; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | protected function _search_stop() |
@@ -149,6 +149,6 @@ discard block |
||
149 | 149 | . __( |
150 | 150 | 'Search through price types. The following source will be searched: Price Type Name.', |
151 | 151 | 'event_espresso' |
152 | - ) . '</p>'; |
|
152 | + ).'</p>'; |
|
153 | 153 | } |
154 | 154 | } |
@@ -15,42 +15,42 @@ |
||
15 | 15 | class Global_EE_Caf_Hooks |
16 | 16 | { |
17 | 17 | |
18 | - public function __construct() |
|
19 | - { |
|
20 | - $this->_do_hooks(); |
|
21 | - } |
|
22 | - |
|
23 | - |
|
24 | - private function _do_hooks() |
|
25 | - { |
|
26 | - add_filter('FHEE_show_sponsors_meta_box', '__return_false', 10); |
|
27 | - add_filter('FHEE_show_ratings_request_meta_box', '__return_false', 10); |
|
28 | - add_filter( |
|
29 | - 'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', |
|
30 | - array($this, 'forums_lazy_loading'), |
|
31 | - 10 |
|
32 | - ); |
|
33 | - add_action( |
|
34 | - 'AHEE__EE_Admin_Page__espresso_news_post_box__after_content', |
|
35 | - array($this, 'extra_news_box_content'), |
|
36 | - 10 |
|
37 | - ); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - public function extra_news_box_content($content) |
|
42 | - { |
|
43 | - echo '<h3 style="margin:0">' . __('From the Forums', 'event_espresso') . '</h3>'; |
|
44 | - echo '<div id="ee_forum_posts_content">'; |
|
45 | - $url = 'http://eventespresso.com/forum/event-espresso-support/feed/'; |
|
46 | - EE_Admin_Page::cached_rss_display('ee_forum_posts_content', $url); |
|
47 | - echo '</div>'; |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - public function forums_lazy_loading($ids) |
|
52 | - { |
|
53 | - $ids[] = 'ee_forum_posts_content'; |
|
54 | - return $ids; |
|
55 | - } |
|
18 | + public function __construct() |
|
19 | + { |
|
20 | + $this->_do_hooks(); |
|
21 | + } |
|
22 | + |
|
23 | + |
|
24 | + private function _do_hooks() |
|
25 | + { |
|
26 | + add_filter('FHEE_show_sponsors_meta_box', '__return_false', 10); |
|
27 | + add_filter('FHEE_show_ratings_request_meta_box', '__return_false', 10); |
|
28 | + add_filter( |
|
29 | + 'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', |
|
30 | + array($this, 'forums_lazy_loading'), |
|
31 | + 10 |
|
32 | + ); |
|
33 | + add_action( |
|
34 | + 'AHEE__EE_Admin_Page__espresso_news_post_box__after_content', |
|
35 | + array($this, 'extra_news_box_content'), |
|
36 | + 10 |
|
37 | + ); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + public function extra_news_box_content($content) |
|
42 | + { |
|
43 | + echo '<h3 style="margin:0">' . __('From the Forums', 'event_espresso') . '</h3>'; |
|
44 | + echo '<div id="ee_forum_posts_content">'; |
|
45 | + $url = 'http://eventespresso.com/forum/event-espresso-support/feed/'; |
|
46 | + EE_Admin_Page::cached_rss_display('ee_forum_posts_content', $url); |
|
47 | + echo '</div>'; |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + public function forums_lazy_loading($ids) |
|
52 | + { |
|
53 | + $ids[] = 'ee_forum_posts_content'; |
|
54 | + return $ids; |
|
55 | + } |
|
56 | 56 | } |
@@ -40,7 +40,7 @@ |
||
40 | 40 | |
41 | 41 | public function extra_news_box_content($content) |
42 | 42 | { |
43 | - echo '<h3 style="margin:0">' . __('From the Forums', 'event_espresso') . '</h3>'; |
|
43 | + echo '<h3 style="margin:0">'.__('From the Forums', 'event_espresso').'</h3>'; |
|
44 | 44 | echo '<div id="ee_forum_posts_content">'; |
45 | 45 | $url = 'http://eventespresso.com/forum/event-espresso-support/feed/'; |
46 | 46 | EE_Admin_Page::cached_rss_display('ee_forum_posts_content', $url); |
@@ -52,7 +52,7 @@ |
||
52 | 52 | /** |
53 | 53 | * Callback for FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks hook |
54 | 54 | * |
55 | - * @param $callbacks |
|
55 | + * @param callable[] $callbacks |
|
56 | 56 | * @return array |
57 | 57 | */ |
58 | 58 | public function modify_callbacks($callbacks) |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | : array(); |
136 | 136 | $EQGids = array_keys($EQGs); |
137 | 137 | |
138 | - if (! empty($QSGs)) { |
|
138 | + if ( ! empty($QSGs)) { |
|
139 | 139 | $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : ''; |
140 | 140 | foreach ($QSGs as $QSG) { |
141 | 141 | $checked = in_array($QSG->ID(), $EQGids, true) |
@@ -155,16 +155,16 @@ discard block |
||
155 | 155 | ); |
156 | 156 | |
157 | 157 | $html .= ' |
158 | - <p id="event-question-group-' . $QSG->ID() . '"> |
|
159 | - <input value="' . $QSG->ID() . '" type="checkbox"' |
|
158 | + <p id="event-question-group-' . $QSG->ID().'"> |
|
159 | + <input value="' . $QSG->ID().'" type="checkbox"' |
|
160 | 160 | . $visibility |
161 | - . ' name="question_groups[' . $QSG->ID() . ']"' . $checked . ' /> |
|
162 | - <a href="' . $edit_link . '" title="' |
|
161 | + . ' name="question_groups['.$QSG->ID().']"'.$checked.' /> |
|
162 | + <a href="' . $edit_link.'" title="' |
|
163 | 163 | . sprintf( |
164 | 164 | esc_attr__('Edit %s Group', 'event_espresso'), |
165 | 165 | $QSG->get('QSG_name') |
166 | 166 | ) |
167 | - . '" target="_blank">' . $QSG->get('QSG_name') . '</a> |
|
167 | + . '" target="_blank">'.$QSG->get('QSG_name').'</a> |
|
168 | 168 | </p>'; |
169 | 169 | } |
170 | 170 | $html .= count($QSGs) > 10 ? '</div>' : ''; |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $current_qgs = array_keys($current_qgs); // we just want the ids |
204 | 204 | |
205 | 205 | // now let's get the groups selected in the editor and update (IF we have data) |
206 | - if (! empty($question_groups)) { |
|
206 | + if ( ! empty($question_groups)) { |
|
207 | 207 | foreach ($question_groups as $id => $val) { |
208 | 208 | // add to event |
209 | 209 | if ($val) { |
@@ -16,210 +16,210 @@ |
||
16 | 16 | class espresso_events_Registration_Form_Hooks extends EE_Admin_Hooks |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var EE_Event|null |
|
21 | - */ |
|
22 | - protected $_event; |
|
23 | - |
|
24 | - |
|
25 | - protected function _set_hooks_properties() |
|
26 | - { |
|
27 | - |
|
28 | - $this->_name = 'registration_form'; |
|
29 | - $this->_metaboxes = array( |
|
30 | - 0 => array( |
|
31 | - 'page_route' => array('edit', 'create_new'), |
|
32 | - 'func' => 'primary_questions', |
|
33 | - 'label' => esc_html__('Questions for Primary Registrant', 'event_espresso'), |
|
34 | - 'priority' => 'default', |
|
35 | - 'context' => 'side', |
|
36 | - ), |
|
37 | - ); |
|
38 | - |
|
39 | - // hook into the handler for saving question groups |
|
40 | - add_filter( |
|
41 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
42 | - array($this, 'modify_callbacks'), |
|
43 | - 10 |
|
44 | - ); |
|
45 | - |
|
46 | - // hook into revision restores (we're hooking into the global action because EE_Admin_Hooks classes are already |
|
47 | - // restricted by page) |
|
48 | - add_action('AHEE_EE_Admin_Page_CPT__restore_revision', array($this, 'restore_revision'), 10, 2); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * Callback for FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks hook |
|
54 | - * |
|
55 | - * @param $callbacks |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - public function modify_callbacks($callbacks) |
|
59 | - { |
|
60 | - // now let's add the question group callback |
|
61 | - $callbacks[] = array($this, 'primary_question_group_update'); |
|
62 | - return $callbacks; |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * Hooked into revision restores. |
|
68 | - * |
|
69 | - * @param $post_id |
|
70 | - * @param $revision_id |
|
71 | - * @return EE_Base_Class |
|
72 | - * @throws EE_Error |
|
73 | - * @throws InvalidArgumentException |
|
74 | - * @throws ReflectionException |
|
75 | - * @throws InvalidDataTypeException |
|
76 | - * @throws InvalidInterfaceException |
|
77 | - */ |
|
78 | - public function restore_revision($post_id, $revision_id) |
|
79 | - { |
|
80 | - $EVT_MDL = EE_Registry::instance()->load_model('Event'); |
|
81 | - $post_evt = $EVT_MDL->get_one_by_ID($post_id); |
|
82 | - // restore revision for primary questions |
|
83 | - $post_evt->restore_revision( |
|
84 | - $revision_id, |
|
85 | - ['Question_Group'], |
|
86 | - ['Question_Group' => ['Event_Question_Group.EQG_primary' => true]] |
|
87 | - ); |
|
88 | - return $post_evt; |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * Content of metabox. |
|
94 | - * |
|
95 | - * @param $post_id |
|
96 | - * @param $post |
|
97 | - * @throws EE_Error |
|
98 | - * @throws InvalidArgumentException |
|
99 | - * @throws InvalidDataTypeException |
|
100 | - * @throws InvalidInterfaceException |
|
101 | - */ |
|
102 | - public function primary_questions($post_id, $post) |
|
103 | - { |
|
104 | - $this->_event = $this->_adminpage_obj->get_event_object(); |
|
105 | - $event_id = $this->_event->ID(); |
|
106 | - ?> |
|
19 | + /** |
|
20 | + * @var EE_Event|null |
|
21 | + */ |
|
22 | + protected $_event; |
|
23 | + |
|
24 | + |
|
25 | + protected function _set_hooks_properties() |
|
26 | + { |
|
27 | + |
|
28 | + $this->_name = 'registration_form'; |
|
29 | + $this->_metaboxes = array( |
|
30 | + 0 => array( |
|
31 | + 'page_route' => array('edit', 'create_new'), |
|
32 | + 'func' => 'primary_questions', |
|
33 | + 'label' => esc_html__('Questions for Primary Registrant', 'event_espresso'), |
|
34 | + 'priority' => 'default', |
|
35 | + 'context' => 'side', |
|
36 | + ), |
|
37 | + ); |
|
38 | + |
|
39 | + // hook into the handler for saving question groups |
|
40 | + add_filter( |
|
41 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
42 | + array($this, 'modify_callbacks'), |
|
43 | + 10 |
|
44 | + ); |
|
45 | + |
|
46 | + // hook into revision restores (we're hooking into the global action because EE_Admin_Hooks classes are already |
|
47 | + // restricted by page) |
|
48 | + add_action('AHEE_EE_Admin_Page_CPT__restore_revision', array($this, 'restore_revision'), 10, 2); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * Callback for FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks hook |
|
54 | + * |
|
55 | + * @param $callbacks |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + public function modify_callbacks($callbacks) |
|
59 | + { |
|
60 | + // now let's add the question group callback |
|
61 | + $callbacks[] = array($this, 'primary_question_group_update'); |
|
62 | + return $callbacks; |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * Hooked into revision restores. |
|
68 | + * |
|
69 | + * @param $post_id |
|
70 | + * @param $revision_id |
|
71 | + * @return EE_Base_Class |
|
72 | + * @throws EE_Error |
|
73 | + * @throws InvalidArgumentException |
|
74 | + * @throws ReflectionException |
|
75 | + * @throws InvalidDataTypeException |
|
76 | + * @throws InvalidInterfaceException |
|
77 | + */ |
|
78 | + public function restore_revision($post_id, $revision_id) |
|
79 | + { |
|
80 | + $EVT_MDL = EE_Registry::instance()->load_model('Event'); |
|
81 | + $post_evt = $EVT_MDL->get_one_by_ID($post_id); |
|
82 | + // restore revision for primary questions |
|
83 | + $post_evt->restore_revision( |
|
84 | + $revision_id, |
|
85 | + ['Question_Group'], |
|
86 | + ['Question_Group' => ['Event_Question_Group.EQG_primary' => true]] |
|
87 | + ); |
|
88 | + return $post_evt; |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * Content of metabox. |
|
94 | + * |
|
95 | + * @param $post_id |
|
96 | + * @param $post |
|
97 | + * @throws EE_Error |
|
98 | + * @throws InvalidArgumentException |
|
99 | + * @throws InvalidDataTypeException |
|
100 | + * @throws InvalidInterfaceException |
|
101 | + */ |
|
102 | + public function primary_questions($post_id, $post) |
|
103 | + { |
|
104 | + $this->_event = $this->_adminpage_obj->get_event_object(); |
|
105 | + $event_id = $this->_event->ID(); |
|
106 | + ?> |
|
107 | 107 | <div class="inside"> |
108 | 108 | <p><strong> |
109 | 109 | <?php _e('Question Groups', 'event_espresso'); ?> |
110 | 110 | </strong><br/> |
111 | 111 | <?php |
112 | - printf( |
|
113 | - esc_html__( |
|
114 | - 'Add a pre-populated %1$sgroup of questions%2$s to your event. The personal information group is required for all events', |
|
115 | - 'event_espresso' |
|
116 | - ), |
|
117 | - '<a href="admin.php?page=espresso_registration_form" target="_blank">', |
|
118 | - '</a>' |
|
119 | - ) |
|
120 | - ?> |
|
112 | + printf( |
|
113 | + esc_html__( |
|
114 | + 'Add a pre-populated %1$sgroup of questions%2$s to your event. The personal information group is required for all events', |
|
115 | + 'event_espresso' |
|
116 | + ), |
|
117 | + '<a href="admin.php?page=espresso_registration_form" target="_blank">', |
|
118 | + '</a>' |
|
119 | + ) |
|
120 | + ?> |
|
121 | 121 | </p> |
122 | 122 | <?php |
123 | 123 | |
124 | - $qsg_where['QSG_deleted'] = false; |
|
125 | - $query_params = apply_filters( |
|
126 | - 'FHEE__espresso_events_Registration_Form_Hooks__primary_questions__question_group_query_parameters', |
|
127 | - array($qsg_where, 'order_by' => array('QSG_order' => 'ASC')) |
|
128 | - ); |
|
129 | - $QSGs = EEM_Question_Group::instance()->get_all($query_params); |
|
130 | - $EQGs = ! empty($event_id) |
|
131 | - ? $this->_event->get_many_related( |
|
132 | - 'Question_Group', |
|
133 | - [['Event_Question_Group.EQG_primary' => true]] |
|
134 | - ) |
|
135 | - : array(); |
|
136 | - $EQGids = array_keys($EQGs); |
|
137 | - |
|
138 | - if (! empty($QSGs)) { |
|
139 | - $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : ''; |
|
140 | - foreach ($QSGs as $QSG) { |
|
141 | - $checked = in_array($QSG->ID(), $EQGids, true) |
|
142 | - || $QSG->get('QSG_system') === 1 |
|
143 | - ? ' checked="checked"' |
|
144 | - : ''; |
|
145 | - $visibility = $QSG->get('QSG_system') === 1 |
|
146 | - ? ' style="visibility:hidden"' |
|
147 | - : ''; |
|
148 | - $edit_query_args = $this->_adminpage_obj->is_caf() ? array( |
|
149 | - 'action' => 'edit_question_group', |
|
150 | - 'QSG_ID' => $QSG->ID(), |
|
151 | - ) : array('action' => 'question_groups'); |
|
152 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( |
|
153 | - $edit_query_args, |
|
154 | - EE_FORMS_ADMIN_URL |
|
155 | - ); |
|
156 | - |
|
157 | - $html .= ' |
|
124 | + $qsg_where['QSG_deleted'] = false; |
|
125 | + $query_params = apply_filters( |
|
126 | + 'FHEE__espresso_events_Registration_Form_Hooks__primary_questions__question_group_query_parameters', |
|
127 | + array($qsg_where, 'order_by' => array('QSG_order' => 'ASC')) |
|
128 | + ); |
|
129 | + $QSGs = EEM_Question_Group::instance()->get_all($query_params); |
|
130 | + $EQGs = ! empty($event_id) |
|
131 | + ? $this->_event->get_many_related( |
|
132 | + 'Question_Group', |
|
133 | + [['Event_Question_Group.EQG_primary' => true]] |
|
134 | + ) |
|
135 | + : array(); |
|
136 | + $EQGids = array_keys($EQGs); |
|
137 | + |
|
138 | + if (! empty($QSGs)) { |
|
139 | + $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : ''; |
|
140 | + foreach ($QSGs as $QSG) { |
|
141 | + $checked = in_array($QSG->ID(), $EQGids, true) |
|
142 | + || $QSG->get('QSG_system') === 1 |
|
143 | + ? ' checked="checked"' |
|
144 | + : ''; |
|
145 | + $visibility = $QSG->get('QSG_system') === 1 |
|
146 | + ? ' style="visibility:hidden"' |
|
147 | + : ''; |
|
148 | + $edit_query_args = $this->_adminpage_obj->is_caf() ? array( |
|
149 | + 'action' => 'edit_question_group', |
|
150 | + 'QSG_ID' => $QSG->ID(), |
|
151 | + ) : array('action' => 'question_groups'); |
|
152 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce( |
|
153 | + $edit_query_args, |
|
154 | + EE_FORMS_ADMIN_URL |
|
155 | + ); |
|
156 | + |
|
157 | + $html .= ' |
|
158 | 158 | <p id="event-question-group-' . $QSG->ID() . '"> |
159 | 159 | <input value="' . $QSG->ID() . '" type="checkbox"' |
160 | - . $visibility |
|
161 | - . ' name="question_groups[' . $QSG->ID() . ']"' . $checked . ' /> |
|
160 | + . $visibility |
|
161 | + . ' name="question_groups[' . $QSG->ID() . ']"' . $checked . ' /> |
|
162 | 162 | <a href="' . $edit_link . '" title="' |
163 | - . sprintf( |
|
164 | - esc_attr__('Edit %s Group', 'event_espresso'), |
|
165 | - $QSG->get('QSG_name') |
|
166 | - ) |
|
167 | - . '" target="_blank">' . $QSG->get('QSG_name') . '</a> |
|
163 | + . sprintf( |
|
164 | + esc_attr__('Edit %s Group', 'event_espresso'), |
|
165 | + $QSG->get('QSG_name') |
|
166 | + ) |
|
167 | + . '" target="_blank">' . $QSG->get('QSG_name') . '</a> |
|
168 | 168 | </p>'; |
169 | - } |
|
170 | - $html .= count($QSGs) > 10 ? '</div>' : ''; |
|
171 | - |
|
172 | - echo $html; |
|
173 | - } else { |
|
174 | - esc_html_e( |
|
175 | - 'There seems to be a problem with your questions. Please contact [email protected]', |
|
176 | - 'event_espresso' |
|
177 | - ); |
|
178 | - } |
|
179 | - do_action('AHEE_event_editor_questions_notice'); |
|
180 | - ?> |
|
169 | + } |
|
170 | + $html .= count($QSGs) > 10 ? '</div>' : ''; |
|
171 | + |
|
172 | + echo $html; |
|
173 | + } else { |
|
174 | + esc_html_e( |
|
175 | + 'There seems to be a problem with your questions. Please contact [email protected]', |
|
176 | + 'event_espresso' |
|
177 | + ); |
|
178 | + } |
|
179 | + do_action('AHEE_event_editor_questions_notice'); |
|
180 | + ?> |
|
181 | 181 | </div> |
182 | 182 | <?php |
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * @param EE_Event $evtobj |
|
188 | - * @param array $data |
|
189 | - * @return bool |
|
190 | - * @throws EE_Error |
|
191 | - */ |
|
192 | - public function primary_question_group_update($evtobj, $data) |
|
193 | - { |
|
194 | - $question_groups = ! empty($data['question_groups']) ? (array) $data['question_groups'] : array(); |
|
195 | - $added_qgs = array_keys($question_groups); |
|
196 | - $success = array(); |
|
197 | - |
|
198 | - // let's get all current question groups associated with this event. |
|
199 | - $current_qgs = $evtobj->get_many_related( |
|
200 | - 'Question_Group', |
|
201 | - [['Event_Question_Group.EQG_primary' => true]] |
|
202 | - ); |
|
203 | - $current_qgs = array_keys($current_qgs); // we just want the ids |
|
204 | - |
|
205 | - // now let's get the groups selected in the editor and update (IF we have data) |
|
206 | - if (! empty($question_groups)) { |
|
207 | - foreach ($question_groups as $id => $val) { |
|
208 | - // add to event |
|
209 | - if ($val) { |
|
210 | - $qg = $evtobj->_add_relation_to($id, 'Question_Group', ['EQG_primary' => true]); |
|
211 | - } |
|
212 | - $success[] = ! empty($qg) ? 1 : 0; |
|
213 | - } |
|
214 | - } |
|
215 | - |
|
216 | - // wait a minute... are there question groups missing in the saved groups that ARE with the current event? |
|
217 | - $removed_qgs = array_diff($current_qgs, $added_qgs); |
|
218 | - |
|
219 | - foreach ($removed_qgs as $qgid) { |
|
220 | - $qg = $evtobj->_remove_relation_to($qgid, 'Question_Group', ['EQG_primary' => true]); |
|
221 | - $success[] = ! empty($qg) ? 1 : 0; |
|
222 | - } |
|
223 | - return in_array(0, $success, true) ? false : true; |
|
224 | - } |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * @param EE_Event $evtobj |
|
188 | + * @param array $data |
|
189 | + * @return bool |
|
190 | + * @throws EE_Error |
|
191 | + */ |
|
192 | + public function primary_question_group_update($evtobj, $data) |
|
193 | + { |
|
194 | + $question_groups = ! empty($data['question_groups']) ? (array) $data['question_groups'] : array(); |
|
195 | + $added_qgs = array_keys($question_groups); |
|
196 | + $success = array(); |
|
197 | + |
|
198 | + // let's get all current question groups associated with this event. |
|
199 | + $current_qgs = $evtobj->get_many_related( |
|
200 | + 'Question_Group', |
|
201 | + [['Event_Question_Group.EQG_primary' => true]] |
|
202 | + ); |
|
203 | + $current_qgs = array_keys($current_qgs); // we just want the ids |
|
204 | + |
|
205 | + // now let's get the groups selected in the editor and update (IF we have data) |
|
206 | + if (! empty($question_groups)) { |
|
207 | + foreach ($question_groups as $id => $val) { |
|
208 | + // add to event |
|
209 | + if ($val) { |
|
210 | + $qg = $evtobj->_add_relation_to($id, 'Question_Group', ['EQG_primary' => true]); |
|
211 | + } |
|
212 | + $success[] = ! empty($qg) ? 1 : 0; |
|
213 | + } |
|
214 | + } |
|
215 | + |
|
216 | + // wait a minute... are there question groups missing in the saved groups that ARE with the current event? |
|
217 | + $removed_qgs = array_diff($current_qgs, $added_qgs); |
|
218 | + |
|
219 | + foreach ($removed_qgs as $qgid) { |
|
220 | + $qg = $evtobj->_remove_relation_to($qgid, 'Question_Group', ['EQG_primary' => true]); |
|
221 | + $success[] = ! empty($qg) ? 1 : 0; |
|
222 | + } |
|
223 | + return in_array(0, $success, true) ? false : true; |
|
224 | + } |
|
225 | 225 | } |
@@ -137,7 +137,7 @@ |
||
137 | 137 | * @param EE_Transaction $transaction |
138 | 138 | * @param string $payment_status One of EEM_Payment's statuses, like 'PAP' (Approved). |
139 | 139 | * By default, searches for approved payments |
140 | - * @return float|false float on success, false on fail |
|
140 | + * @return double float on success, false on fail |
|
141 | 141 | * @throws \EE_Error |
142 | 142 | */ |
143 | 143 | public function recalculate_total_payments_for_transaction( |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | public static function instance() |
44 | 44 | { |
45 | 45 | // check if class object is instantiated |
46 | - if (! self::$_instance instanceof EE_Transaction_Payments) { |
|
46 | + if ( ! self::$_instance instanceof EE_Transaction_Payments) { |
|
47 | 47 | self::$_instance = new self(); |
48 | 48 | } |
49 | 49 | return self::$_instance; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | public function recalculate_transaction_total(EE_Transaction $transaction, $update_txn = true) |
63 | 63 | { |
64 | 64 | $total_line_item = $transaction->total_line_item(); |
65 | - if (! $total_line_item instanceof EE_Line_Item) { |
|
65 | + if ( ! $total_line_item instanceof EE_Line_Item) { |
|
66 | 66 | EE_Error::add_error( |
67 | 67 | sprintf( |
68 | 68 | __('The Total Line Item for Transaction %1$d\'s was not found or is invalid.', 'event_espresso'), |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | public function calculate_total_payments_and_update_status(EE_Transaction $transaction, $update_txn = true) |
102 | 102 | { |
103 | 103 | // verify transaction |
104 | - if (! $transaction instanceof EE_Transaction) { |
|
104 | + if ( ! $transaction instanceof EE_Transaction) { |
|
105 | 105 | EE_Error::add_error( |
106 | 106 | __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
107 | 107 | __FILE__, |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | if ($total_paid !== false && (float) $total_paid !== $transaction->paid()) { |
117 | 117 | $transaction->set_paid($total_paid); |
118 | 118 | // maybe update status, and make sure to save transaction if not done already |
119 | - if (! $transaction->update_status_based_on_total_paid($update_txn)) { |
|
119 | + if ( ! $transaction->update_status_based_on_total_paid($update_txn)) { |
|
120 | 120 | if ($update_txn) { |
121 | 121 | return $transaction->save() ? true : false; |
122 | 122 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $payment_status = EEM_Payment::status_id_approved |
146 | 146 | ) { |
147 | 147 | // verify transaction |
148 | - if (! $transaction instanceof EE_Transaction) { |
|
148 | + if ( ! $transaction instanceof EE_Transaction) { |
|
149 | 149 | EE_Error::add_error( |
150 | 150 | __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
151 | 151 | __FILE__, |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | public function delete_payment_and_update_transaction(EE_Payment $payment) |
179 | 179 | { |
180 | 180 | // verify payment |
181 | - if (! $payment instanceof EE_Payment) { |
|
181 | + if ( ! $payment instanceof EE_Payment) { |
|
182 | 182 | EE_Error::add_error( |
183 | 183 | __('A valid Payment object was not received.', 'event_espresso'), |
184 | 184 | __FILE__, |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | ); |
188 | 188 | return false; |
189 | 189 | } |
190 | - if (! $this->delete_registration_payments_and_update_registrations($payment)) { |
|
190 | + if ( ! $this->delete_registration_payments_and_update_registrations($payment)) { |
|
191 | 191 | return false; |
192 | 192 | } |
193 | - if (! $payment->delete()) { |
|
193 | + if ( ! $payment->delete()) { |
|
194 | 194 | EE_Error::add_error( |
195 | 195 | __('The payment could not be deleted.', 'event_espresso'), |
196 | 196 | __FILE__, |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | // if this fails, that just means that the transaction didn't get its status changed and/or updated. |
215 | 215 | // however the payment was still deleted. |
216 | - if (! $this->calculate_total_payments_and_update_status($transaction)) { |
|
216 | + if ( ! $this->calculate_total_payments_and_update_status($transaction)) { |
|
217 | 217 | EE_Error::add_attention( |
218 | 218 | __( |
219 | 219 | 'It appears that the Payment was deleted but no change was recorded for the Transaction for an unknown reason. Please verify that all data for this Transaction looks correct..', |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | $reg_payment_query_params = ! empty($reg_payment_query_params) ? $reg_payment_query_params |
256 | 256 | : array(array('PAY_ID' => $payment->ID())); |
257 | 257 | $registration_payments = EEM_Registration_Payment::instance()->get_all($reg_payment_query_params); |
258 | - if (! empty($registration_payments)) { |
|
258 | + if ( ! empty($registration_payments)) { |
|
259 | 259 | foreach ($registration_payments as $registration_payment) { |
260 | 260 | if ($registration_payment instanceof EE_Registration_Payment) { |
261 | 261 | $amount_paid = $registration_payment->amount(); |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | public function update_transaction_status_based_on_total_paid(EE_Transaction $transaction, $update_txn = true) |
322 | 322 | { |
323 | 323 | EE_Error::doing_it_wrong( |
324 | - __CLASS__ . '::' . __FUNCTION__, |
|
324 | + __CLASS__.'::'.__FUNCTION__, |
|
325 | 325 | sprintf( |
326 | 326 | __('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
327 | 327 | 'EE_Transaction::update_status_based_on_total_paid()' |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | '5.0.0' |
331 | 331 | ); |
332 | 332 | // verify transaction |
333 | - if (! $transaction instanceof EE_Transaction) { |
|
333 | + if ( ! $transaction instanceof EE_Transaction) { |
|
334 | 334 | EE_Error::add_error( |
335 | 335 | __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
336 | 336 | __FILE__, |
@@ -15,424 +15,424 @@ |
||
15 | 15 | class EE_Transaction_Payments |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var EE_Transaction_Payments $_instance |
|
20 | - * @access private |
|
21 | - */ |
|
22 | - private static $_instance; |
|
23 | - |
|
24 | - /** |
|
25 | - * @deprecated |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - protected $_old_txn_status; |
|
29 | - |
|
30 | - /** |
|
31 | - * @deprecated |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - protected $_new_txn_status; |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * @singleton method used to instantiate class object |
|
39 | - * @access public |
|
40 | - * @return EE_Transaction_Payments instance |
|
41 | - */ |
|
42 | - public static function instance() |
|
43 | - { |
|
44 | - // check if class object is instantiated |
|
45 | - if (! self::$_instance instanceof EE_Transaction_Payments) { |
|
46 | - self::$_instance = new self(); |
|
47 | - } |
|
48 | - return self::$_instance; |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * recalculate_transaction_total |
|
54 | - * |
|
55 | - * @access private |
|
56 | - * @param EE_Transaction $transaction |
|
57 | - * @param bool $update_txn |
|
58 | - * @return bool true if TXN total was updated, false if not |
|
59 | - * @throws \EE_Error |
|
60 | - */ |
|
61 | - public function recalculate_transaction_total(EE_Transaction $transaction, $update_txn = true) |
|
62 | - { |
|
63 | - $total_line_item = $transaction->total_line_item(); |
|
64 | - if (! $total_line_item instanceof EE_Line_Item) { |
|
65 | - EE_Error::add_error( |
|
66 | - sprintf( |
|
67 | - __('The Total Line Item for Transaction %1$d\'s was not found or is invalid.', 'event_espresso'), |
|
68 | - $transaction->ID() |
|
69 | - ), |
|
70 | - __FILE__, |
|
71 | - __FUNCTION__, |
|
72 | - __LINE__ |
|
73 | - ); |
|
74 | - return false; |
|
75 | - } |
|
76 | - $new_total = $total_line_item->recalculate_total_including_taxes(); |
|
77 | - $transaction->set_total($new_total); |
|
78 | - if ($update_txn) { |
|
79 | - return $transaction->save() ? true : false; |
|
80 | - } |
|
81 | - return false; |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * Updates the provided EE_Transaction with all the applicable payments |
|
87 | - * returns a boolean for whether the TXN was saved to the db |
|
88 | - * (meaning a status change occurred) |
|
89 | - * or not saved (which could **still** mean that |
|
90 | - * the TXN status changed, but just was not yet saved). |
|
91 | - * So if passing a value of false for the $update_txn param, |
|
92 | - * then client code needs to take responsibility for saving the TXN |
|
93 | - * regardless of what happens within EE_Transaction_Payments; |
|
94 | - * |
|
95 | - * @param EE_Transaction /int $transaction_obj_or_id EE_Transaction or its ID |
|
96 | - * @param boolean $update_txn whether to save the TXN |
|
97 | - * @return boolean whether the TXN was saved |
|
98 | - * @throws \EE_Error |
|
99 | - */ |
|
100 | - public function calculate_total_payments_and_update_status(EE_Transaction $transaction, $update_txn = true) |
|
101 | - { |
|
102 | - // verify transaction |
|
103 | - if (! $transaction instanceof EE_Transaction) { |
|
104 | - EE_Error::add_error( |
|
105 | - __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
|
106 | - __FILE__, |
|
107 | - __FUNCTION__, |
|
108 | - __LINE__ |
|
109 | - ); |
|
110 | - return false; |
|
111 | - } |
|
112 | - // calculate total paid |
|
113 | - $total_paid = $this->recalculate_total_payments_for_transaction($transaction); |
|
114 | - // if total paid has changed |
|
115 | - if ($total_paid !== false && (float) $total_paid !== $transaction->paid()) { |
|
116 | - $transaction->set_paid($total_paid); |
|
117 | - // maybe update status, and make sure to save transaction if not done already |
|
118 | - if (! $transaction->update_status_based_on_total_paid($update_txn)) { |
|
119 | - if ($update_txn) { |
|
120 | - return $transaction->save() ? true : false; |
|
121 | - } |
|
122 | - } else { |
|
123 | - // the status got updated and was saved by |
|
124 | - // update_transaction_status_based_on_total_paid() |
|
125 | - return true; |
|
126 | - } |
|
127 | - } |
|
128 | - return false; |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * recalculate_total_payments_for_transaction |
|
134 | - * |
|
135 | - * @access public |
|
136 | - * @param EE_Transaction $transaction |
|
137 | - * @param string $payment_status One of EEM_Payment's statuses, like 'PAP' (Approved). |
|
138 | - * By default, searches for approved payments |
|
139 | - * @return float|false float on success, false on fail |
|
140 | - * @throws \EE_Error |
|
141 | - */ |
|
142 | - public function recalculate_total_payments_for_transaction( |
|
143 | - EE_Transaction $transaction, |
|
144 | - $payment_status = EEM_Payment::status_id_approved |
|
145 | - ) { |
|
146 | - // verify transaction |
|
147 | - if (! $transaction instanceof EE_Transaction) { |
|
148 | - EE_Error::add_error( |
|
149 | - __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
|
150 | - __FILE__, |
|
151 | - __FUNCTION__, |
|
152 | - __LINE__ |
|
153 | - ); |
|
154 | - return false; |
|
155 | - } |
|
156 | - // ensure Payment model is loaded |
|
157 | - EE_Registry::instance()->load_model('Payment'); |
|
158 | - // calls EEM_Base::sum() |
|
159 | - return EEM_Payment::instance()->sum( |
|
160 | - // query params |
|
161 | - array(array('TXN_ID' => $transaction->ID(), 'STS_ID' => $payment_status)), |
|
162 | - // field to sum |
|
163 | - 'PAY_amount' |
|
164 | - ); |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - /** |
|
169 | - * delete_payment_and_update_transaction |
|
170 | - * Before deleting the selected payment, we fetch it's transaction, |
|
171 | - * then delete the payment, and update the transactions' amount paid. |
|
172 | - * |
|
173 | - * @param EE_Payment $payment |
|
174 | - * @return boolean |
|
175 | - * @throws \EE_Error |
|
176 | - */ |
|
177 | - public function delete_payment_and_update_transaction(EE_Payment $payment) |
|
178 | - { |
|
179 | - // verify payment |
|
180 | - if (! $payment instanceof EE_Payment) { |
|
181 | - EE_Error::add_error( |
|
182 | - __('A valid Payment object was not received.', 'event_espresso'), |
|
183 | - __FILE__, |
|
184 | - __FUNCTION__, |
|
185 | - __LINE__ |
|
186 | - ); |
|
187 | - return false; |
|
188 | - } |
|
189 | - if (! $this->delete_registration_payments_and_update_registrations($payment)) { |
|
190 | - return false; |
|
191 | - } |
|
192 | - if (! $payment->delete()) { |
|
193 | - EE_Error::add_error( |
|
194 | - __('The payment could not be deleted.', 'event_espresso'), |
|
195 | - __FILE__, |
|
196 | - __FUNCTION__, |
|
197 | - __LINE__ |
|
198 | - ); |
|
199 | - return false; |
|
200 | - } |
|
201 | - |
|
202 | - $transaction = $payment->transaction(); |
|
203 | - $TXN_status = $transaction->status_ID(); |
|
204 | - if ( |
|
205 | - $TXN_status === EEM_Transaction::abandoned_status_code |
|
206 | - || $TXN_status === EEM_Transaction::failed_status_code |
|
207 | - || $payment->amount() === 0 |
|
208 | - ) { |
|
209 | - EE_Error::add_success(__('The Payment was successfully deleted.', 'event_espresso')); |
|
210 | - return true; |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - // if this fails, that just means that the transaction didn't get its status changed and/or updated. |
|
215 | - // however the payment was still deleted. |
|
216 | - if (! $this->calculate_total_payments_and_update_status($transaction)) { |
|
217 | - EE_Error::add_attention( |
|
218 | - __( |
|
219 | - 'It appears that the Payment was deleted but no change was recorded for the Transaction for an unknown reason. Please verify that all data for this Transaction looks correct..', |
|
220 | - 'event_espresso' |
|
221 | - ), |
|
222 | - __FILE__, |
|
223 | - __FUNCTION__, |
|
224 | - __LINE__ |
|
225 | - ); |
|
226 | - return true; |
|
227 | - } |
|
228 | - |
|
229 | - EE_Error::add_success( |
|
230 | - __( |
|
231 | - 'The Payment was successfully deleted, and the Transaction has been updated accordingly.', |
|
232 | - 'event_espresso' |
|
233 | - ) |
|
234 | - ); |
|
235 | - return true; |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * delete_registration_payments_and_update_registrations |
|
241 | - * |
|
242 | - * removes all registration payment records associated with a payment |
|
243 | - * and subtracts their amounts from the corresponding registrations REG_paid field |
|
244 | - * |
|
245 | - * @param EE_Payment $payment |
|
246 | - * @param array $reg_payment_query_params |
|
247 | - * @return bool |
|
248 | - * @throws \EE_Error |
|
249 | - */ |
|
250 | - public function delete_registration_payments_and_update_registrations( |
|
251 | - EE_Payment $payment, |
|
252 | - $reg_payment_query_params = array() |
|
253 | - ) { |
|
254 | - $save_payment = false; |
|
255 | - $reg_payment_query_params = ! empty($reg_payment_query_params) ? $reg_payment_query_params |
|
256 | - : array(array('PAY_ID' => $payment->ID())); |
|
257 | - $registration_payments = EEM_Registration_Payment::instance()->get_all($reg_payment_query_params); |
|
258 | - if (! empty($registration_payments)) { |
|
259 | - foreach ($registration_payments as $registration_payment) { |
|
260 | - if ($registration_payment instanceof EE_Registration_Payment) { |
|
261 | - $amount_paid = $registration_payment->amount(); |
|
262 | - $registration = $registration_payment->registration(); |
|
263 | - if ($registration instanceof EE_Registration) { |
|
264 | - $registration->set_paid($registration->paid() - $amount_paid); |
|
265 | - if ($registration->save() !== false) { |
|
266 | - $registration_payment->delete_permanently(); |
|
267 | - $save_payment = true; |
|
268 | - } |
|
269 | - } else { |
|
270 | - EE_Error::add_error( |
|
271 | - sprintf( |
|
272 | - __( |
|
273 | - 'An invalid Registration object was associated with Registration Payment ID# %1$d.', |
|
274 | - 'event_espresso' |
|
275 | - ), |
|
276 | - $registration_payment->ID() |
|
277 | - ), |
|
278 | - __FILE__, |
|
279 | - __FUNCTION__, |
|
280 | - __LINE__ |
|
281 | - ); |
|
282 | - return false; |
|
283 | - } |
|
284 | - } else { |
|
285 | - EE_Error::add_error( |
|
286 | - sprintf( |
|
287 | - __( |
|
288 | - 'An invalid Registration Payment object was associated with payment ID# %1$d.', |
|
289 | - 'event_espresso' |
|
290 | - ), |
|
291 | - $payment->ID() |
|
292 | - ), |
|
293 | - __FILE__, |
|
294 | - __FUNCTION__, |
|
295 | - __LINE__ |
|
296 | - ); |
|
297 | - return false; |
|
298 | - } |
|
299 | - } |
|
300 | - } |
|
301 | - if ($save_payment) { |
|
302 | - $payment->save(); |
|
303 | - } |
|
304 | - return true; |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - |
|
309 | - /********************************** DEPRECATED METHODS **********************************/ |
|
310 | - |
|
311 | - |
|
312 | - /** |
|
313 | - * possibly toggles TXN status |
|
314 | - * |
|
315 | - * @deprecated 4.9.1 |
|
316 | - * @param EE_Transaction $transaction |
|
317 | - * @param boolean $update_txn whether to save the TXN |
|
318 | - * @return boolean whether the TXN was saved |
|
319 | - * @throws \EE_Error |
|
320 | - */ |
|
321 | - public function update_transaction_status_based_on_total_paid(EE_Transaction $transaction, $update_txn = true) |
|
322 | - { |
|
323 | - EE_Error::doing_it_wrong( |
|
324 | - __CLASS__ . '::' . __FUNCTION__, |
|
325 | - sprintf( |
|
326 | - __('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
|
327 | - 'EE_Transaction::update_status_based_on_total_paid()' |
|
328 | - ), |
|
329 | - '4.9.1', |
|
330 | - '5.0.0' |
|
331 | - ); |
|
332 | - // verify transaction |
|
333 | - if (! $transaction instanceof EE_Transaction) { |
|
334 | - EE_Error::add_error( |
|
335 | - __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
|
336 | - __FILE__, |
|
337 | - __FUNCTION__, |
|
338 | - __LINE__ |
|
339 | - ); |
|
340 | - return false; |
|
341 | - } |
|
342 | - // set transaction status based on comparison of TXN_paid vs TXN_total |
|
343 | - return $transaction->update_status_based_on_total_paid($update_txn); |
|
344 | - } |
|
345 | - |
|
346 | - |
|
347 | - /** |
|
348 | - * @deprecated 4.9.12 |
|
349 | - * @return string |
|
350 | - */ |
|
351 | - public function old_txn_status() |
|
352 | - { |
|
353 | - EE_Error::doing_it_wrong( |
|
354 | - __METHOD__, |
|
355 | - esc_html__( |
|
356 | - 'This logic has been moved into \EE_Transaction::old_txn_status(), please use that method instead.', |
|
357 | - 'event_espresso' |
|
358 | - ), |
|
359 | - '4.9.12' |
|
360 | - ); |
|
361 | - return $this->_old_txn_status; |
|
362 | - } |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * @deprecated 4.9.12 |
|
367 | - * @param string $old_txn_status |
|
368 | - */ |
|
369 | - public function set_old_txn_status($old_txn_status) |
|
370 | - { |
|
371 | - EE_Error::doing_it_wrong( |
|
372 | - __METHOD__, |
|
373 | - esc_html__( |
|
374 | - 'This logic has been moved into \EE_Transaction::set_old_txn_status(), please use that method instead.', |
|
375 | - 'event_espresso' |
|
376 | - ), |
|
377 | - '4.9.12' |
|
378 | - ); |
|
379 | - // only set the first time |
|
380 | - if ($this->_old_txn_status === null) { |
|
381 | - $this->_old_txn_status = $old_txn_status; |
|
382 | - } |
|
383 | - } |
|
384 | - |
|
385 | - |
|
386 | - /** |
|
387 | - * @deprecated 4.9.12 |
|
388 | - * @return string |
|
389 | - */ |
|
390 | - public function new_txn_status() |
|
391 | - { |
|
392 | - EE_Error::doing_it_wrong( |
|
393 | - __METHOD__, |
|
394 | - esc_html__( |
|
395 | - 'This logic has been removed. Please just use \EE_Transaction::status_ID() instead.', |
|
396 | - 'event_espresso' |
|
397 | - ), |
|
398 | - '4.9.12' |
|
399 | - ); |
|
400 | - return $this->_new_txn_status; |
|
401 | - } |
|
402 | - |
|
403 | - |
|
404 | - /** |
|
405 | - * @deprecated 4.9.12 |
|
406 | - * @param string $new_txn_status |
|
407 | - */ |
|
408 | - public function set_new_txn_status($new_txn_status) |
|
409 | - { |
|
410 | - EE_Error::doing_it_wrong( |
|
411 | - __METHOD__, |
|
412 | - esc_html__( |
|
413 | - 'This logic has been removed. Please just use \EE_Transaction::set_status() instead.', |
|
414 | - 'event_espresso' |
|
415 | - ), |
|
416 | - '4.9.12' |
|
417 | - ); |
|
418 | - $this->_new_txn_status = $new_txn_status; |
|
419 | - } |
|
420 | - |
|
421 | - |
|
422 | - /** |
|
423 | - * @deprecated 4.9.12 |
|
424 | - * @return bool |
|
425 | - */ |
|
426 | - public function txn_status_updated() |
|
427 | - { |
|
428 | - EE_Error::doing_it_wrong( |
|
429 | - __METHOD__, |
|
430 | - esc_html__( |
|
431 | - 'This logic has been moved into \EE_Transaction::txn_status_updated(), please use that method instead.', |
|
432 | - 'event_espresso' |
|
433 | - ), |
|
434 | - '4.9.12' |
|
435 | - ); |
|
436 | - return $this->_new_txn_status !== $this->_old_txn_status && $this->_old_txn_status !== null ? true : false; |
|
437 | - } |
|
18 | + /** |
|
19 | + * @var EE_Transaction_Payments $_instance |
|
20 | + * @access private |
|
21 | + */ |
|
22 | + private static $_instance; |
|
23 | + |
|
24 | + /** |
|
25 | + * @deprecated |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + protected $_old_txn_status; |
|
29 | + |
|
30 | + /** |
|
31 | + * @deprecated |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + protected $_new_txn_status; |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * @singleton method used to instantiate class object |
|
39 | + * @access public |
|
40 | + * @return EE_Transaction_Payments instance |
|
41 | + */ |
|
42 | + public static function instance() |
|
43 | + { |
|
44 | + // check if class object is instantiated |
|
45 | + if (! self::$_instance instanceof EE_Transaction_Payments) { |
|
46 | + self::$_instance = new self(); |
|
47 | + } |
|
48 | + return self::$_instance; |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * recalculate_transaction_total |
|
54 | + * |
|
55 | + * @access private |
|
56 | + * @param EE_Transaction $transaction |
|
57 | + * @param bool $update_txn |
|
58 | + * @return bool true if TXN total was updated, false if not |
|
59 | + * @throws \EE_Error |
|
60 | + */ |
|
61 | + public function recalculate_transaction_total(EE_Transaction $transaction, $update_txn = true) |
|
62 | + { |
|
63 | + $total_line_item = $transaction->total_line_item(); |
|
64 | + if (! $total_line_item instanceof EE_Line_Item) { |
|
65 | + EE_Error::add_error( |
|
66 | + sprintf( |
|
67 | + __('The Total Line Item for Transaction %1$d\'s was not found or is invalid.', 'event_espresso'), |
|
68 | + $transaction->ID() |
|
69 | + ), |
|
70 | + __FILE__, |
|
71 | + __FUNCTION__, |
|
72 | + __LINE__ |
|
73 | + ); |
|
74 | + return false; |
|
75 | + } |
|
76 | + $new_total = $total_line_item->recalculate_total_including_taxes(); |
|
77 | + $transaction->set_total($new_total); |
|
78 | + if ($update_txn) { |
|
79 | + return $transaction->save() ? true : false; |
|
80 | + } |
|
81 | + return false; |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * Updates the provided EE_Transaction with all the applicable payments |
|
87 | + * returns a boolean for whether the TXN was saved to the db |
|
88 | + * (meaning a status change occurred) |
|
89 | + * or not saved (which could **still** mean that |
|
90 | + * the TXN status changed, but just was not yet saved). |
|
91 | + * So if passing a value of false for the $update_txn param, |
|
92 | + * then client code needs to take responsibility for saving the TXN |
|
93 | + * regardless of what happens within EE_Transaction_Payments; |
|
94 | + * |
|
95 | + * @param EE_Transaction /int $transaction_obj_or_id EE_Transaction or its ID |
|
96 | + * @param boolean $update_txn whether to save the TXN |
|
97 | + * @return boolean whether the TXN was saved |
|
98 | + * @throws \EE_Error |
|
99 | + */ |
|
100 | + public function calculate_total_payments_and_update_status(EE_Transaction $transaction, $update_txn = true) |
|
101 | + { |
|
102 | + // verify transaction |
|
103 | + if (! $transaction instanceof EE_Transaction) { |
|
104 | + EE_Error::add_error( |
|
105 | + __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
|
106 | + __FILE__, |
|
107 | + __FUNCTION__, |
|
108 | + __LINE__ |
|
109 | + ); |
|
110 | + return false; |
|
111 | + } |
|
112 | + // calculate total paid |
|
113 | + $total_paid = $this->recalculate_total_payments_for_transaction($transaction); |
|
114 | + // if total paid has changed |
|
115 | + if ($total_paid !== false && (float) $total_paid !== $transaction->paid()) { |
|
116 | + $transaction->set_paid($total_paid); |
|
117 | + // maybe update status, and make sure to save transaction if not done already |
|
118 | + if (! $transaction->update_status_based_on_total_paid($update_txn)) { |
|
119 | + if ($update_txn) { |
|
120 | + return $transaction->save() ? true : false; |
|
121 | + } |
|
122 | + } else { |
|
123 | + // the status got updated and was saved by |
|
124 | + // update_transaction_status_based_on_total_paid() |
|
125 | + return true; |
|
126 | + } |
|
127 | + } |
|
128 | + return false; |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * recalculate_total_payments_for_transaction |
|
134 | + * |
|
135 | + * @access public |
|
136 | + * @param EE_Transaction $transaction |
|
137 | + * @param string $payment_status One of EEM_Payment's statuses, like 'PAP' (Approved). |
|
138 | + * By default, searches for approved payments |
|
139 | + * @return float|false float on success, false on fail |
|
140 | + * @throws \EE_Error |
|
141 | + */ |
|
142 | + public function recalculate_total_payments_for_transaction( |
|
143 | + EE_Transaction $transaction, |
|
144 | + $payment_status = EEM_Payment::status_id_approved |
|
145 | + ) { |
|
146 | + // verify transaction |
|
147 | + if (! $transaction instanceof EE_Transaction) { |
|
148 | + EE_Error::add_error( |
|
149 | + __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
|
150 | + __FILE__, |
|
151 | + __FUNCTION__, |
|
152 | + __LINE__ |
|
153 | + ); |
|
154 | + return false; |
|
155 | + } |
|
156 | + // ensure Payment model is loaded |
|
157 | + EE_Registry::instance()->load_model('Payment'); |
|
158 | + // calls EEM_Base::sum() |
|
159 | + return EEM_Payment::instance()->sum( |
|
160 | + // query params |
|
161 | + array(array('TXN_ID' => $transaction->ID(), 'STS_ID' => $payment_status)), |
|
162 | + // field to sum |
|
163 | + 'PAY_amount' |
|
164 | + ); |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + /** |
|
169 | + * delete_payment_and_update_transaction |
|
170 | + * Before deleting the selected payment, we fetch it's transaction, |
|
171 | + * then delete the payment, and update the transactions' amount paid. |
|
172 | + * |
|
173 | + * @param EE_Payment $payment |
|
174 | + * @return boolean |
|
175 | + * @throws \EE_Error |
|
176 | + */ |
|
177 | + public function delete_payment_and_update_transaction(EE_Payment $payment) |
|
178 | + { |
|
179 | + // verify payment |
|
180 | + if (! $payment instanceof EE_Payment) { |
|
181 | + EE_Error::add_error( |
|
182 | + __('A valid Payment object was not received.', 'event_espresso'), |
|
183 | + __FILE__, |
|
184 | + __FUNCTION__, |
|
185 | + __LINE__ |
|
186 | + ); |
|
187 | + return false; |
|
188 | + } |
|
189 | + if (! $this->delete_registration_payments_and_update_registrations($payment)) { |
|
190 | + return false; |
|
191 | + } |
|
192 | + if (! $payment->delete()) { |
|
193 | + EE_Error::add_error( |
|
194 | + __('The payment could not be deleted.', 'event_espresso'), |
|
195 | + __FILE__, |
|
196 | + __FUNCTION__, |
|
197 | + __LINE__ |
|
198 | + ); |
|
199 | + return false; |
|
200 | + } |
|
201 | + |
|
202 | + $transaction = $payment->transaction(); |
|
203 | + $TXN_status = $transaction->status_ID(); |
|
204 | + if ( |
|
205 | + $TXN_status === EEM_Transaction::abandoned_status_code |
|
206 | + || $TXN_status === EEM_Transaction::failed_status_code |
|
207 | + || $payment->amount() === 0 |
|
208 | + ) { |
|
209 | + EE_Error::add_success(__('The Payment was successfully deleted.', 'event_espresso')); |
|
210 | + return true; |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + // if this fails, that just means that the transaction didn't get its status changed and/or updated. |
|
215 | + // however the payment was still deleted. |
|
216 | + if (! $this->calculate_total_payments_and_update_status($transaction)) { |
|
217 | + EE_Error::add_attention( |
|
218 | + __( |
|
219 | + 'It appears that the Payment was deleted but no change was recorded for the Transaction for an unknown reason. Please verify that all data for this Transaction looks correct..', |
|
220 | + 'event_espresso' |
|
221 | + ), |
|
222 | + __FILE__, |
|
223 | + __FUNCTION__, |
|
224 | + __LINE__ |
|
225 | + ); |
|
226 | + return true; |
|
227 | + } |
|
228 | + |
|
229 | + EE_Error::add_success( |
|
230 | + __( |
|
231 | + 'The Payment was successfully deleted, and the Transaction has been updated accordingly.', |
|
232 | + 'event_espresso' |
|
233 | + ) |
|
234 | + ); |
|
235 | + return true; |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * delete_registration_payments_and_update_registrations |
|
241 | + * |
|
242 | + * removes all registration payment records associated with a payment |
|
243 | + * and subtracts their amounts from the corresponding registrations REG_paid field |
|
244 | + * |
|
245 | + * @param EE_Payment $payment |
|
246 | + * @param array $reg_payment_query_params |
|
247 | + * @return bool |
|
248 | + * @throws \EE_Error |
|
249 | + */ |
|
250 | + public function delete_registration_payments_and_update_registrations( |
|
251 | + EE_Payment $payment, |
|
252 | + $reg_payment_query_params = array() |
|
253 | + ) { |
|
254 | + $save_payment = false; |
|
255 | + $reg_payment_query_params = ! empty($reg_payment_query_params) ? $reg_payment_query_params |
|
256 | + : array(array('PAY_ID' => $payment->ID())); |
|
257 | + $registration_payments = EEM_Registration_Payment::instance()->get_all($reg_payment_query_params); |
|
258 | + if (! empty($registration_payments)) { |
|
259 | + foreach ($registration_payments as $registration_payment) { |
|
260 | + if ($registration_payment instanceof EE_Registration_Payment) { |
|
261 | + $amount_paid = $registration_payment->amount(); |
|
262 | + $registration = $registration_payment->registration(); |
|
263 | + if ($registration instanceof EE_Registration) { |
|
264 | + $registration->set_paid($registration->paid() - $amount_paid); |
|
265 | + if ($registration->save() !== false) { |
|
266 | + $registration_payment->delete_permanently(); |
|
267 | + $save_payment = true; |
|
268 | + } |
|
269 | + } else { |
|
270 | + EE_Error::add_error( |
|
271 | + sprintf( |
|
272 | + __( |
|
273 | + 'An invalid Registration object was associated with Registration Payment ID# %1$d.', |
|
274 | + 'event_espresso' |
|
275 | + ), |
|
276 | + $registration_payment->ID() |
|
277 | + ), |
|
278 | + __FILE__, |
|
279 | + __FUNCTION__, |
|
280 | + __LINE__ |
|
281 | + ); |
|
282 | + return false; |
|
283 | + } |
|
284 | + } else { |
|
285 | + EE_Error::add_error( |
|
286 | + sprintf( |
|
287 | + __( |
|
288 | + 'An invalid Registration Payment object was associated with payment ID# %1$d.', |
|
289 | + 'event_espresso' |
|
290 | + ), |
|
291 | + $payment->ID() |
|
292 | + ), |
|
293 | + __FILE__, |
|
294 | + __FUNCTION__, |
|
295 | + __LINE__ |
|
296 | + ); |
|
297 | + return false; |
|
298 | + } |
|
299 | + } |
|
300 | + } |
|
301 | + if ($save_payment) { |
|
302 | + $payment->save(); |
|
303 | + } |
|
304 | + return true; |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + |
|
309 | + /********************************** DEPRECATED METHODS **********************************/ |
|
310 | + |
|
311 | + |
|
312 | + /** |
|
313 | + * possibly toggles TXN status |
|
314 | + * |
|
315 | + * @deprecated 4.9.1 |
|
316 | + * @param EE_Transaction $transaction |
|
317 | + * @param boolean $update_txn whether to save the TXN |
|
318 | + * @return boolean whether the TXN was saved |
|
319 | + * @throws \EE_Error |
|
320 | + */ |
|
321 | + public function update_transaction_status_based_on_total_paid(EE_Transaction $transaction, $update_txn = true) |
|
322 | + { |
|
323 | + EE_Error::doing_it_wrong( |
|
324 | + __CLASS__ . '::' . __FUNCTION__, |
|
325 | + sprintf( |
|
326 | + __('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
|
327 | + 'EE_Transaction::update_status_based_on_total_paid()' |
|
328 | + ), |
|
329 | + '4.9.1', |
|
330 | + '5.0.0' |
|
331 | + ); |
|
332 | + // verify transaction |
|
333 | + if (! $transaction instanceof EE_Transaction) { |
|
334 | + EE_Error::add_error( |
|
335 | + __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
|
336 | + __FILE__, |
|
337 | + __FUNCTION__, |
|
338 | + __LINE__ |
|
339 | + ); |
|
340 | + return false; |
|
341 | + } |
|
342 | + // set transaction status based on comparison of TXN_paid vs TXN_total |
|
343 | + return $transaction->update_status_based_on_total_paid($update_txn); |
|
344 | + } |
|
345 | + |
|
346 | + |
|
347 | + /** |
|
348 | + * @deprecated 4.9.12 |
|
349 | + * @return string |
|
350 | + */ |
|
351 | + public function old_txn_status() |
|
352 | + { |
|
353 | + EE_Error::doing_it_wrong( |
|
354 | + __METHOD__, |
|
355 | + esc_html__( |
|
356 | + 'This logic has been moved into \EE_Transaction::old_txn_status(), please use that method instead.', |
|
357 | + 'event_espresso' |
|
358 | + ), |
|
359 | + '4.9.12' |
|
360 | + ); |
|
361 | + return $this->_old_txn_status; |
|
362 | + } |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * @deprecated 4.9.12 |
|
367 | + * @param string $old_txn_status |
|
368 | + */ |
|
369 | + public function set_old_txn_status($old_txn_status) |
|
370 | + { |
|
371 | + EE_Error::doing_it_wrong( |
|
372 | + __METHOD__, |
|
373 | + esc_html__( |
|
374 | + 'This logic has been moved into \EE_Transaction::set_old_txn_status(), please use that method instead.', |
|
375 | + 'event_espresso' |
|
376 | + ), |
|
377 | + '4.9.12' |
|
378 | + ); |
|
379 | + // only set the first time |
|
380 | + if ($this->_old_txn_status === null) { |
|
381 | + $this->_old_txn_status = $old_txn_status; |
|
382 | + } |
|
383 | + } |
|
384 | + |
|
385 | + |
|
386 | + /** |
|
387 | + * @deprecated 4.9.12 |
|
388 | + * @return string |
|
389 | + */ |
|
390 | + public function new_txn_status() |
|
391 | + { |
|
392 | + EE_Error::doing_it_wrong( |
|
393 | + __METHOD__, |
|
394 | + esc_html__( |
|
395 | + 'This logic has been removed. Please just use \EE_Transaction::status_ID() instead.', |
|
396 | + 'event_espresso' |
|
397 | + ), |
|
398 | + '4.9.12' |
|
399 | + ); |
|
400 | + return $this->_new_txn_status; |
|
401 | + } |
|
402 | + |
|
403 | + |
|
404 | + /** |
|
405 | + * @deprecated 4.9.12 |
|
406 | + * @param string $new_txn_status |
|
407 | + */ |
|
408 | + public function set_new_txn_status($new_txn_status) |
|
409 | + { |
|
410 | + EE_Error::doing_it_wrong( |
|
411 | + __METHOD__, |
|
412 | + esc_html__( |
|
413 | + 'This logic has been removed. Please just use \EE_Transaction::set_status() instead.', |
|
414 | + 'event_espresso' |
|
415 | + ), |
|
416 | + '4.9.12' |
|
417 | + ); |
|
418 | + $this->_new_txn_status = $new_txn_status; |
|
419 | + } |
|
420 | + |
|
421 | + |
|
422 | + /** |
|
423 | + * @deprecated 4.9.12 |
|
424 | + * @return bool |
|
425 | + */ |
|
426 | + public function txn_status_updated() |
|
427 | + { |
|
428 | + EE_Error::doing_it_wrong( |
|
429 | + __METHOD__, |
|
430 | + esc_html__( |
|
431 | + 'This logic has been moved into \EE_Transaction::txn_status_updated(), please use that method instead.', |
|
432 | + 'event_espresso' |
|
433 | + ), |
|
434 | + '4.9.12' |
|
435 | + ); |
|
436 | + return $this->_new_txn_status !== $this->_old_txn_status && $this->_old_txn_status !== null ? true : false; |
|
437 | + } |
|
438 | 438 | } |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | /** |
839 | 839 | * calculate spaces remaining based on "saleable" tickets |
840 | 840 | * |
841 | - * @param array $tickets |
|
841 | + * @param EE_Base_Class[] $tickets |
|
842 | 842 | * @param bool $filtered |
843 | 843 | * @return int|float |
844 | 844 | * @throws EE_Error |
@@ -1078,7 +1078,7 @@ discard block |
||
1078 | 1078 | * |
1079 | 1079 | * @access public |
1080 | 1080 | * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
1081 | - * @return mixed void|string |
|
1081 | + * @return string void|string |
|
1082 | 1082 | * @throws EE_Error |
1083 | 1083 | */ |
1084 | 1084 | public function pretty_active_status($echo = true) |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function getAvailableSpacesCalculator() |
73 | 73 | { |
74 | - if (! $this->available_spaces_calculator instanceof EventSpacesCalculator) { |
|
74 | + if ( ! $this->available_spaces_calculator instanceof EventSpacesCalculator) { |
|
75 | 75 | $this->available_spaces_calculator = new EventSpacesCalculator($this); |
76 | 76 | } |
77 | 77 | return $this->available_spaces_calculator; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function primary_datetime($try_to_exclude_expired = true, $try_to_exclude_deleted = true) |
215 | 215 | { |
216 | - if (! empty($this->_Primary_Datetime)) { |
|
216 | + if ( ! empty($this->_Primary_Datetime)) { |
|
217 | 217 | return $this->_Primary_Datetime; |
218 | 218 | } |
219 | 219 | $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event( |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | { |
237 | 237 | // first get all datetimes |
238 | 238 | $datetimes = $this->datetimes_ordered(); |
239 | - if (! $datetimes) { |
|
239 | + if ( ! $datetimes) { |
|
240 | 240 | return array(); |
241 | 241 | } |
242 | 242 | $datetime_ids = array(); |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | public function short_description($num_words = 55, $more = null, $not_full_desc = false) |
430 | 430 | { |
431 | 431 | $short_desc = $this->get('EVT_short_desc'); |
432 | - if (! empty($short_desc) || $not_full_desc) { |
|
432 | + if ( ! empty($short_desc) || $not_full_desc) { |
|
433 | 433 | return $short_desc; |
434 | 434 | } |
435 | 435 | $full_desc = $this->get('EVT_desc'); |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | ); |
884 | 884 | $all_expired = true; |
885 | 885 | foreach ($tickets as $ticket) { |
886 | - if (! $ticket->is_expired()) { |
|
886 | + if ( ! $ticket->is_expired()) { |
|
887 | 887 | $all_expired = false; |
888 | 888 | break; |
889 | 889 | } |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | */ |
973 | 973 | public function is_sold_out($actual = false) |
974 | 974 | { |
975 | - if (! $actual) { |
|
975 | + if ( ! $actual) { |
|
976 | 976 | return $this->status() === EEM_Event::sold_out; |
977 | 977 | } |
978 | 978 | return $this->perform_sold_out_status_check(); |
@@ -1017,11 +1017,11 @@ discard block |
||
1017 | 1017 | public function get_active_status($reset = false) |
1018 | 1018 | { |
1019 | 1019 | // if the active status has already been set, then just use that value (unless we are resetting it) |
1020 | - if (! empty($this->_active_status) && ! $reset) { |
|
1020 | + if ( ! empty($this->_active_status) && ! $reset) { |
|
1021 | 1021 | return $this->_active_status; |
1022 | 1022 | } |
1023 | 1023 | // first check if event id is present on this object |
1024 | - if (! $this->ID()) { |
|
1024 | + if ( ! $this->ID()) { |
|
1025 | 1025 | return false; |
1026 | 1026 | } |
1027 | 1027 | $where_params_for_event = array(array('EVT_ID' => $this->ID())); |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | public function get_number_of_tickets_sold() |
1107 | 1107 | { |
1108 | 1108 | $tkt_sold = 0; |
1109 | - if (! $this->ID()) { |
|
1109 | + if ( ! $this->ID()) { |
|
1110 | 1110 | return 0; |
1111 | 1111 | } |
1112 | 1112 | $datetimes = $this->datetimes(); |
@@ -1290,7 +1290,7 @@ discard block |
||
1290 | 1290 | ] |
1291 | 1291 | ); |
1292 | 1292 | $field_to_update = EEM_Event_Question_Group::instance()->fieldNameForContext($for_primary); |
1293 | - $other_field = EEM_Event_Question_Group::instance()->fieldNameForContext(! $for_primary); |
|
1293 | + $other_field = EEM_Event_Question_Group::instance()->fieldNameForContext( ! $for_primary); |
|
1294 | 1294 | if ($existing_relation->get($other_field) === false) { |
1295 | 1295 | // Delete it. It's now no longer for primary or additional question groups. |
1296 | 1296 | return $this->_remove_relation_to($question_group_id_or_obj, 'Question_Group'); |
@@ -15,1393 +15,1393 @@ |
||
15 | 15 | class EE_Event extends EE_CPT_Base implements EEI_Line_Item_Object, EEI_Admin_Links, EEI_Has_Icon, EEI_Event |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * cached value for the the logical active status for the event |
|
20 | - * |
|
21 | - * @see get_active_status() |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $_active_status = ''; |
|
25 | - |
|
26 | - /** |
|
27 | - * This is just used for caching the Primary Datetime for the Event on initial retrieval |
|
28 | - * |
|
29 | - * @var EE_Datetime |
|
30 | - */ |
|
31 | - protected $_Primary_Datetime; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var EventSpacesCalculator $available_spaces_calculator |
|
35 | - */ |
|
36 | - protected $available_spaces_calculator; |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * @param array $props_n_values incoming values |
|
41 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
42 | - * used.) |
|
43 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
44 | - * date_format and the second value is the time format |
|
45 | - * @return EE_Event |
|
46 | - * @throws EE_Error |
|
47 | - */ |
|
48 | - public static function new_instance($props_n_values = array(), $timezone = '', $date_formats = array()) |
|
49 | - { |
|
50 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
51 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * @param array $props_n_values incoming values from the database |
|
57 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
58 | - * the website will be used. |
|
59 | - * @return EE_Event |
|
60 | - * @throws EE_Error |
|
61 | - */ |
|
62 | - public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
63 | - { |
|
64 | - return new self($props_n_values, true, $timezone); |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * @return EventSpacesCalculator |
|
70 | - * @throws \EE_Error |
|
71 | - */ |
|
72 | - public function getAvailableSpacesCalculator() |
|
73 | - { |
|
74 | - if (! $this->available_spaces_calculator instanceof EventSpacesCalculator) { |
|
75 | - $this->available_spaces_calculator = new EventSpacesCalculator($this); |
|
76 | - } |
|
77 | - return $this->available_spaces_calculator; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * Overrides parent set() method so that all calls to set( 'status', $status ) can be routed to internal methods |
|
83 | - * |
|
84 | - * @param string $field_name |
|
85 | - * @param mixed $field_value |
|
86 | - * @param bool $use_default |
|
87 | - * @throws EE_Error |
|
88 | - */ |
|
89 | - public function set($field_name, $field_value, $use_default = false) |
|
90 | - { |
|
91 | - switch ($field_name) { |
|
92 | - case 'status': |
|
93 | - $this->set_status($field_value, $use_default); |
|
94 | - break; |
|
95 | - default: |
|
96 | - parent::set($field_name, $field_value, $use_default); |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * set_status |
|
103 | - * Checks if event status is being changed to SOLD OUT |
|
104 | - * and updates event meta data with previous event status |
|
105 | - * so that we can revert things if/when the event is no longer sold out |
|
106 | - * |
|
107 | - * @access public |
|
108 | - * @param string $new_status |
|
109 | - * @param bool $use_default |
|
110 | - * @return void |
|
111 | - * @throws EE_Error |
|
112 | - */ |
|
113 | - public function set_status($new_status = null, $use_default = false) |
|
114 | - { |
|
115 | - // if nothing is set, and we aren't explicitly wanting to reset the status, then just leave |
|
116 | - if (empty($new_status) && ! $use_default) { |
|
117 | - return; |
|
118 | - } |
|
119 | - // get current Event status |
|
120 | - $old_status = $this->status(); |
|
121 | - // if status has changed |
|
122 | - if ($old_status !== $new_status) { |
|
123 | - // TO sold_out |
|
124 | - if ($new_status === EEM_Event::sold_out) { |
|
125 | - // save the previous event status so that we can revert if the event is no longer sold out |
|
126 | - $this->add_post_meta('_previous_event_status', $old_status); |
|
127 | - do_action('AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status); |
|
128 | - // OR FROM sold_out |
|
129 | - } elseif ($old_status === EEM_Event::sold_out) { |
|
130 | - $this->delete_post_meta('_previous_event_status'); |
|
131 | - do_action('AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status); |
|
132 | - } |
|
133 | - // clear out the active status so that it gets reset the next time it is requested |
|
134 | - $this->_active_status = null; |
|
135 | - // update status |
|
136 | - parent::set('status', $new_status, $use_default); |
|
137 | - do_action('AHEE__EE_Event__set_status__after_update', $this); |
|
138 | - return; |
|
139 | - } |
|
140 | - // even though the old value matches the new value, it's still good to |
|
141 | - // allow the parent set method to have a say |
|
142 | - parent::set('status', $new_status, $use_default); |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * Gets all the datetimes for this event |
|
148 | - * |
|
149 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
150 | - * @return EE_Base_Class[]|EE_Datetime[] |
|
151 | - * @throws EE_Error |
|
152 | - */ |
|
153 | - public function datetimes($query_params = array()) |
|
154 | - { |
|
155 | - return $this->get_many_related('Datetime', $query_params); |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * Gets all the datetimes for this event, ordered by DTT_EVT_start in ascending order |
|
161 | - * |
|
162 | - * @return EE_Base_Class[]|EE_Datetime[] |
|
163 | - * @throws EE_Error |
|
164 | - */ |
|
165 | - public function datetimes_in_chronological_order() |
|
166 | - { |
|
167 | - return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC'))); |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * Gets all the datetimes for this event, ordered by the DTT_order on the datetime. |
|
173 | - * @darren, we should probably UNSET timezone on the EEM_Datetime model |
|
174 | - * after running our query, so that this timezone isn't set for EVERY query |
|
175 | - * on EEM_Datetime for the rest of the request, no? |
|
176 | - * |
|
177 | - * @param boolean $show_expired whether or not to include expired events |
|
178 | - * @param boolean $show_deleted whether or not to include deleted events |
|
179 | - * @param null $limit |
|
180 | - * @return EE_Datetime[] |
|
181 | - * @throws EE_Error |
|
182 | - */ |
|
183 | - public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null) |
|
184 | - { |
|
185 | - return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order( |
|
186 | - $this->ID(), |
|
187 | - $show_expired, |
|
188 | - $show_deleted, |
|
189 | - $limit |
|
190 | - ); |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - /** |
|
195 | - * Returns one related datetime. Mostly only used by some legacy code. |
|
196 | - * |
|
197 | - * @return EE_Base_Class|EE_Datetime |
|
198 | - * @throws EE_Error |
|
199 | - */ |
|
200 | - public function first_datetime() |
|
201 | - { |
|
202 | - return $this->get_first_related('Datetime'); |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - /** |
|
207 | - * Returns the 'primary' datetime for the event |
|
208 | - * |
|
209 | - * @param bool $try_to_exclude_expired |
|
210 | - * @param bool $try_to_exclude_deleted |
|
211 | - * @return EE_Datetime |
|
212 | - * @throws EE_Error |
|
213 | - */ |
|
214 | - public function primary_datetime($try_to_exclude_expired = true, $try_to_exclude_deleted = true) |
|
215 | - { |
|
216 | - if (! empty($this->_Primary_Datetime)) { |
|
217 | - return $this->_Primary_Datetime; |
|
218 | - } |
|
219 | - $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event( |
|
220 | - $this->ID(), |
|
221 | - $try_to_exclude_expired, |
|
222 | - $try_to_exclude_deleted |
|
223 | - ); |
|
224 | - return $this->_Primary_Datetime; |
|
225 | - } |
|
226 | - |
|
227 | - |
|
228 | - /** |
|
229 | - * Gets all the tickets available for purchase of this event |
|
230 | - * |
|
231 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
232 | - * @return EE_Base_Class[]|EE_Ticket[] |
|
233 | - * @throws EE_Error |
|
234 | - */ |
|
235 | - public function tickets($query_params = array()) |
|
236 | - { |
|
237 | - // first get all datetimes |
|
238 | - $datetimes = $this->datetimes_ordered(); |
|
239 | - if (! $datetimes) { |
|
240 | - return array(); |
|
241 | - } |
|
242 | - $datetime_ids = array(); |
|
243 | - foreach ($datetimes as $datetime) { |
|
244 | - $datetime_ids[] = $datetime->ID(); |
|
245 | - } |
|
246 | - $where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids)); |
|
247 | - // if incoming $query_params has where conditions let's merge but not override existing. |
|
248 | - if (is_array($query_params) && isset($query_params[0])) { |
|
249 | - $where_params = array_merge($query_params[0], $where_params); |
|
250 | - unset($query_params[0]); |
|
251 | - } |
|
252 | - // now add $where_params to $query_params |
|
253 | - $query_params[0] = $where_params; |
|
254 | - return EEM_Ticket::instance()->get_all($query_params); |
|
255 | - } |
|
256 | - |
|
257 | - |
|
258 | - /** |
|
259 | - * get all unexpired untrashed tickets |
|
260 | - * |
|
261 | - * @return EE_Ticket[] |
|
262 | - * @throws EE_Error |
|
263 | - */ |
|
264 | - public function active_tickets() |
|
265 | - { |
|
266 | - return $this->tickets( |
|
267 | - array( |
|
268 | - array( |
|
269 | - 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
270 | - 'TKT_deleted' => false, |
|
271 | - ), |
|
272 | - ) |
|
273 | - ); |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - /** |
|
278 | - * @return bool |
|
279 | - * @throws EE_Error |
|
280 | - */ |
|
281 | - public function additional_limit() |
|
282 | - { |
|
283 | - return $this->get('EVT_additional_limit'); |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * @return bool |
|
289 | - * @throws EE_Error |
|
290 | - */ |
|
291 | - public function allow_overflow() |
|
292 | - { |
|
293 | - return $this->get('EVT_allow_overflow'); |
|
294 | - } |
|
295 | - |
|
296 | - |
|
297 | - /** |
|
298 | - * @return bool |
|
299 | - * @throws EE_Error |
|
300 | - */ |
|
301 | - public function created() |
|
302 | - { |
|
303 | - return $this->get('EVT_created'); |
|
304 | - } |
|
305 | - |
|
306 | - |
|
307 | - /** |
|
308 | - * @return bool |
|
309 | - * @throws EE_Error |
|
310 | - */ |
|
311 | - public function description() |
|
312 | - { |
|
313 | - return $this->get('EVT_desc'); |
|
314 | - } |
|
315 | - |
|
316 | - |
|
317 | - /** |
|
318 | - * Runs do_shortcode and wpautop on the description |
|
319 | - * |
|
320 | - * @return string of html |
|
321 | - * @throws EE_Error |
|
322 | - */ |
|
323 | - public function description_filtered() |
|
324 | - { |
|
325 | - return $this->get_pretty('EVT_desc'); |
|
326 | - } |
|
327 | - |
|
328 | - |
|
329 | - /** |
|
330 | - * @return bool |
|
331 | - * @throws EE_Error |
|
332 | - */ |
|
333 | - public function display_description() |
|
334 | - { |
|
335 | - return $this->get('EVT_display_desc'); |
|
336 | - } |
|
337 | - |
|
338 | - |
|
339 | - /** |
|
340 | - * @return bool |
|
341 | - * @throws EE_Error |
|
342 | - */ |
|
343 | - public function display_ticket_selector() |
|
344 | - { |
|
345 | - return (bool) $this->get('EVT_display_ticket_selector'); |
|
346 | - } |
|
347 | - |
|
348 | - |
|
349 | - /** |
|
350 | - * @return bool |
|
351 | - * @throws EE_Error |
|
352 | - */ |
|
353 | - public function external_url() |
|
354 | - { |
|
355 | - return $this->get('EVT_external_URL'); |
|
356 | - } |
|
357 | - |
|
358 | - |
|
359 | - /** |
|
360 | - * @return bool |
|
361 | - * @throws EE_Error |
|
362 | - */ |
|
363 | - public function member_only() |
|
364 | - { |
|
365 | - return $this->get('EVT_member_only'); |
|
366 | - } |
|
367 | - |
|
368 | - |
|
369 | - /** |
|
370 | - * @return bool |
|
371 | - * @throws EE_Error |
|
372 | - */ |
|
373 | - public function phone() |
|
374 | - { |
|
375 | - return $this->get('EVT_phone'); |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - /** |
|
380 | - * @return bool |
|
381 | - * @throws EE_Error |
|
382 | - */ |
|
383 | - public function modified() |
|
384 | - { |
|
385 | - return $this->get('EVT_modified'); |
|
386 | - } |
|
387 | - |
|
388 | - |
|
389 | - /** |
|
390 | - * @return bool |
|
391 | - * @throws EE_Error |
|
392 | - */ |
|
393 | - public function name() |
|
394 | - { |
|
395 | - return $this->get('EVT_name'); |
|
396 | - } |
|
397 | - |
|
398 | - |
|
399 | - /** |
|
400 | - * @return bool |
|
401 | - * @throws EE_Error |
|
402 | - */ |
|
403 | - public function order() |
|
404 | - { |
|
405 | - return $this->get('EVT_order'); |
|
406 | - } |
|
407 | - |
|
408 | - |
|
409 | - /** |
|
410 | - * @return bool|string |
|
411 | - * @throws EE_Error |
|
412 | - */ |
|
413 | - public function default_registration_status() |
|
414 | - { |
|
415 | - $event_default_registration_status = $this->get('EVT_default_registration_status'); |
|
416 | - return ! empty($event_default_registration_status) |
|
417 | - ? $event_default_registration_status |
|
418 | - : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
419 | - } |
|
420 | - |
|
421 | - |
|
422 | - /** |
|
423 | - * @param int $num_words |
|
424 | - * @param null $more |
|
425 | - * @param bool $not_full_desc |
|
426 | - * @return bool|string |
|
427 | - * @throws EE_Error |
|
428 | - */ |
|
429 | - public function short_description($num_words = 55, $more = null, $not_full_desc = false) |
|
430 | - { |
|
431 | - $short_desc = $this->get('EVT_short_desc'); |
|
432 | - if (! empty($short_desc) || $not_full_desc) { |
|
433 | - return $short_desc; |
|
434 | - } |
|
435 | - $full_desc = $this->get('EVT_desc'); |
|
436 | - return wp_trim_words($full_desc, $num_words, $more); |
|
437 | - } |
|
438 | - |
|
439 | - |
|
440 | - /** |
|
441 | - * @return bool |
|
442 | - * @throws EE_Error |
|
443 | - */ |
|
444 | - public function slug() |
|
445 | - { |
|
446 | - return $this->get('EVT_slug'); |
|
447 | - } |
|
448 | - |
|
449 | - |
|
450 | - /** |
|
451 | - * @return bool |
|
452 | - * @throws EE_Error |
|
453 | - */ |
|
454 | - public function timezone_string() |
|
455 | - { |
|
456 | - return $this->get('EVT_timezone_string'); |
|
457 | - } |
|
458 | - |
|
459 | - |
|
460 | - /** |
|
461 | - * @return bool |
|
462 | - * @throws EE_Error |
|
463 | - */ |
|
464 | - public function visible_on() |
|
465 | - { |
|
466 | - return $this->get('EVT_visible_on'); |
|
467 | - } |
|
468 | - |
|
469 | - |
|
470 | - /** |
|
471 | - * @return int |
|
472 | - * @throws EE_Error |
|
473 | - */ |
|
474 | - public function wp_user() |
|
475 | - { |
|
476 | - return $this->get('EVT_wp_user'); |
|
477 | - } |
|
478 | - |
|
479 | - |
|
480 | - /** |
|
481 | - * @return bool |
|
482 | - * @throws EE_Error |
|
483 | - */ |
|
484 | - public function donations() |
|
485 | - { |
|
486 | - return $this->get('EVT_donations'); |
|
487 | - } |
|
488 | - |
|
489 | - |
|
490 | - /** |
|
491 | - * @param $limit |
|
492 | - * @throws EE_Error |
|
493 | - */ |
|
494 | - public function set_additional_limit($limit) |
|
495 | - { |
|
496 | - $this->set('EVT_additional_limit', $limit); |
|
497 | - } |
|
498 | - |
|
499 | - |
|
500 | - /** |
|
501 | - * @param $created |
|
502 | - * @throws EE_Error |
|
503 | - */ |
|
504 | - public function set_created($created) |
|
505 | - { |
|
506 | - $this->set('EVT_created', $created); |
|
507 | - } |
|
508 | - |
|
509 | - |
|
510 | - /** |
|
511 | - * @param $desc |
|
512 | - * @throws EE_Error |
|
513 | - */ |
|
514 | - public function set_description($desc) |
|
515 | - { |
|
516 | - $this->set('EVT_desc', $desc); |
|
517 | - } |
|
518 | - |
|
519 | - |
|
520 | - /** |
|
521 | - * @param $display_desc |
|
522 | - * @throws EE_Error |
|
523 | - */ |
|
524 | - public function set_display_description($display_desc) |
|
525 | - { |
|
526 | - $this->set('EVT_display_desc', $display_desc); |
|
527 | - } |
|
528 | - |
|
529 | - |
|
530 | - /** |
|
531 | - * @param $display_ticket_selector |
|
532 | - * @throws EE_Error |
|
533 | - */ |
|
534 | - public function set_display_ticket_selector($display_ticket_selector) |
|
535 | - { |
|
536 | - $this->set('EVT_display_ticket_selector', $display_ticket_selector); |
|
537 | - } |
|
538 | - |
|
539 | - |
|
540 | - /** |
|
541 | - * @param $external_url |
|
542 | - * @throws EE_Error |
|
543 | - */ |
|
544 | - public function set_external_url($external_url) |
|
545 | - { |
|
546 | - $this->set('EVT_external_URL', $external_url); |
|
547 | - } |
|
548 | - |
|
549 | - |
|
550 | - /** |
|
551 | - * @param $member_only |
|
552 | - * @throws EE_Error |
|
553 | - */ |
|
554 | - public function set_member_only($member_only) |
|
555 | - { |
|
556 | - $this->set('EVT_member_only', $member_only); |
|
557 | - } |
|
558 | - |
|
559 | - |
|
560 | - /** |
|
561 | - * @param $event_phone |
|
562 | - * @throws EE_Error |
|
563 | - */ |
|
564 | - public function set_event_phone($event_phone) |
|
565 | - { |
|
566 | - $this->set('EVT_phone', $event_phone); |
|
567 | - } |
|
568 | - |
|
569 | - |
|
570 | - /** |
|
571 | - * @param $modified |
|
572 | - * @throws EE_Error |
|
573 | - */ |
|
574 | - public function set_modified($modified) |
|
575 | - { |
|
576 | - $this->set('EVT_modified', $modified); |
|
577 | - } |
|
578 | - |
|
579 | - |
|
580 | - /** |
|
581 | - * @param $name |
|
582 | - * @throws EE_Error |
|
583 | - */ |
|
584 | - public function set_name($name) |
|
585 | - { |
|
586 | - $this->set('EVT_name', $name); |
|
587 | - } |
|
588 | - |
|
589 | - |
|
590 | - /** |
|
591 | - * @param $order |
|
592 | - * @throws EE_Error |
|
593 | - */ |
|
594 | - public function set_order($order) |
|
595 | - { |
|
596 | - $this->set('EVT_order', $order); |
|
597 | - } |
|
598 | - |
|
599 | - |
|
600 | - /** |
|
601 | - * @param $short_desc |
|
602 | - * @throws EE_Error |
|
603 | - */ |
|
604 | - public function set_short_description($short_desc) |
|
605 | - { |
|
606 | - $this->set('EVT_short_desc', $short_desc); |
|
607 | - } |
|
608 | - |
|
609 | - |
|
610 | - /** |
|
611 | - * @param $slug |
|
612 | - * @throws EE_Error |
|
613 | - */ |
|
614 | - public function set_slug($slug) |
|
615 | - { |
|
616 | - $this->set('EVT_slug', $slug); |
|
617 | - } |
|
618 | - |
|
619 | - |
|
620 | - /** |
|
621 | - * @param $timezone_string |
|
622 | - * @throws EE_Error |
|
623 | - */ |
|
624 | - public function set_timezone_string($timezone_string) |
|
625 | - { |
|
626 | - $this->set('EVT_timezone_string', $timezone_string); |
|
627 | - } |
|
628 | - |
|
629 | - |
|
630 | - /** |
|
631 | - * @param $visible_on |
|
632 | - * @throws EE_Error |
|
633 | - */ |
|
634 | - public function set_visible_on($visible_on) |
|
635 | - { |
|
636 | - $this->set('EVT_visible_on', $visible_on); |
|
637 | - } |
|
638 | - |
|
639 | - |
|
640 | - /** |
|
641 | - * @param $wp_user |
|
642 | - * @throws EE_Error |
|
643 | - */ |
|
644 | - public function set_wp_user($wp_user) |
|
645 | - { |
|
646 | - $this->set('EVT_wp_user', $wp_user); |
|
647 | - } |
|
648 | - |
|
649 | - |
|
650 | - /** |
|
651 | - * @param $default_registration_status |
|
652 | - * @throws EE_Error |
|
653 | - */ |
|
654 | - public function set_default_registration_status($default_registration_status) |
|
655 | - { |
|
656 | - $this->set('EVT_default_registration_status', $default_registration_status); |
|
657 | - } |
|
658 | - |
|
659 | - |
|
660 | - /** |
|
661 | - * @param $donations |
|
662 | - * @throws EE_Error |
|
663 | - */ |
|
664 | - public function set_donations($donations) |
|
665 | - { |
|
666 | - $this->set('EVT_donations', $donations); |
|
667 | - } |
|
668 | - |
|
669 | - |
|
670 | - /** |
|
671 | - * Adds a venue to this event |
|
672 | - * |
|
673 | - * @param EE_Venue /int $venue_id_or_obj |
|
674 | - * @return EE_Base_Class|EE_Venue |
|
675 | - * @throws EE_Error |
|
676 | - */ |
|
677 | - public function add_venue($venue_id_or_obj) |
|
678 | - { |
|
679 | - return $this->_add_relation_to($venue_id_or_obj, 'Venue'); |
|
680 | - } |
|
681 | - |
|
682 | - |
|
683 | - /** |
|
684 | - * Removes a venue from the event |
|
685 | - * |
|
686 | - * @param EE_Venue /int $venue_id_or_obj |
|
687 | - * @return EE_Base_Class|EE_Venue |
|
688 | - * @throws EE_Error |
|
689 | - */ |
|
690 | - public function remove_venue($venue_id_or_obj) |
|
691 | - { |
|
692 | - return $this->_remove_relation_to($venue_id_or_obj, 'Venue'); |
|
693 | - } |
|
694 | - |
|
695 | - |
|
696 | - /** |
|
697 | - * Gets all the venues related ot the event. May provide additional $query_params if desired |
|
698 | - * |
|
699 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
700 | - * @return EE_Base_Class[]|EE_Venue[] |
|
701 | - * @throws EE_Error |
|
702 | - */ |
|
703 | - public function venues($query_params = array()) |
|
704 | - { |
|
705 | - return $this->get_many_related('Venue', $query_params); |
|
706 | - } |
|
707 | - |
|
708 | - |
|
709 | - /** |
|
710 | - * check if event id is present and if event is published |
|
711 | - * |
|
712 | - * @access public |
|
713 | - * @return boolean true yes, false no |
|
714 | - * @throws EE_Error |
|
715 | - */ |
|
716 | - private function _has_ID_and_is_published() |
|
717 | - { |
|
718 | - // first check if event id is present and not NULL, |
|
719 | - // then check if this event is published (or any of the equivalent "published" statuses) |
|
720 | - return |
|
721 | - $this->ID() && $this->ID() !== null |
|
722 | - && ( |
|
723 | - $this->status() === 'publish' |
|
724 | - || $this->status() === EEM_Event::sold_out |
|
725 | - || $this->status() === EEM_Event::postponed |
|
726 | - || $this->status() === EEM_Event::cancelled |
|
727 | - ); |
|
728 | - } |
|
729 | - |
|
730 | - |
|
731 | - /** |
|
732 | - * This simply compares the internal dates with NOW and determines if the event is upcoming or not. |
|
733 | - * |
|
734 | - * @access public |
|
735 | - * @return boolean true yes, false no |
|
736 | - * @throws EE_Error |
|
737 | - */ |
|
738 | - public function is_upcoming() |
|
739 | - { |
|
740 | - // check if event id is present and if this event is published |
|
741 | - if ($this->is_inactive()) { |
|
742 | - return false; |
|
743 | - } |
|
744 | - // set initial value |
|
745 | - $upcoming = false; |
|
746 | - // next let's get all datetimes and loop through them |
|
747 | - $datetimes = $this->datetimes_in_chronological_order(); |
|
748 | - foreach ($datetimes as $datetime) { |
|
749 | - if ($datetime instanceof EE_Datetime) { |
|
750 | - // if this dtt is expired then we continue cause one of the other datetimes might be upcoming. |
|
751 | - if ($datetime->is_expired()) { |
|
752 | - continue; |
|
753 | - } |
|
754 | - // if this dtt is active then we return false. |
|
755 | - if ($datetime->is_active()) { |
|
756 | - return false; |
|
757 | - } |
|
758 | - // otherwise let's check upcoming status |
|
759 | - $upcoming = $datetime->is_upcoming(); |
|
760 | - } |
|
761 | - } |
|
762 | - return $upcoming; |
|
763 | - } |
|
764 | - |
|
765 | - |
|
766 | - /** |
|
767 | - * @return bool |
|
768 | - * @throws EE_Error |
|
769 | - */ |
|
770 | - public function is_active() |
|
771 | - { |
|
772 | - // check if event id is present and if this event is published |
|
773 | - if ($this->is_inactive()) { |
|
774 | - return false; |
|
775 | - } |
|
776 | - // set initial value |
|
777 | - $active = false; |
|
778 | - // next let's get all datetimes and loop through them |
|
779 | - $datetimes = $this->datetimes_in_chronological_order(); |
|
780 | - foreach ($datetimes as $datetime) { |
|
781 | - if ($datetime instanceof EE_Datetime) { |
|
782 | - // if this dtt is expired then we continue cause one of the other datetimes might be active. |
|
783 | - if ($datetime->is_expired()) { |
|
784 | - continue; |
|
785 | - } |
|
786 | - // if this dtt is upcoming then we return false. |
|
787 | - if ($datetime->is_upcoming()) { |
|
788 | - return false; |
|
789 | - } |
|
790 | - // otherwise let's check active status |
|
791 | - $active = $datetime->is_active(); |
|
792 | - } |
|
793 | - } |
|
794 | - return $active; |
|
795 | - } |
|
796 | - |
|
797 | - |
|
798 | - /** |
|
799 | - * @return bool |
|
800 | - * @throws EE_Error |
|
801 | - */ |
|
802 | - public function is_expired() |
|
803 | - { |
|
804 | - // check if event id is present and if this event is published |
|
805 | - if ($this->is_inactive()) { |
|
806 | - return false; |
|
807 | - } |
|
808 | - // set initial value |
|
809 | - $expired = false; |
|
810 | - // first let's get all datetimes and loop through them |
|
811 | - $datetimes = $this->datetimes_in_chronological_order(); |
|
812 | - foreach ($datetimes as $datetime) { |
|
813 | - if ($datetime instanceof EE_Datetime) { |
|
814 | - // if this dtt is upcoming or active then we return false. |
|
815 | - if ($datetime->is_upcoming() || $datetime->is_active()) { |
|
816 | - return false; |
|
817 | - } |
|
818 | - // otherwise let's check active status |
|
819 | - $expired = $datetime->is_expired(); |
|
820 | - } |
|
821 | - } |
|
822 | - return $expired; |
|
823 | - } |
|
824 | - |
|
825 | - |
|
826 | - /** |
|
827 | - * @return bool |
|
828 | - * @throws EE_Error |
|
829 | - */ |
|
830 | - public function is_inactive() |
|
831 | - { |
|
832 | - // check if event id is present and if this event is published |
|
833 | - if ($this->_has_ID_and_is_published()) { |
|
834 | - return false; |
|
835 | - } |
|
836 | - return true; |
|
837 | - } |
|
838 | - |
|
839 | - |
|
840 | - /** |
|
841 | - * calculate spaces remaining based on "saleable" tickets |
|
842 | - * |
|
843 | - * @param array $tickets |
|
844 | - * @param bool $filtered |
|
845 | - * @return int|float |
|
846 | - * @throws EE_Error |
|
847 | - * @throws DomainException |
|
848 | - * @throws UnexpectedEntityException |
|
849 | - */ |
|
850 | - public function spaces_remaining($tickets = array(), $filtered = true) |
|
851 | - { |
|
852 | - $this->getAvailableSpacesCalculator()->setActiveTickets($tickets); |
|
853 | - $spaces_remaining = $this->getAvailableSpacesCalculator()->spacesRemaining(); |
|
854 | - return $filtered |
|
855 | - ? apply_filters( |
|
856 | - 'FHEE_EE_Event__spaces_remaining', |
|
857 | - $spaces_remaining, |
|
858 | - $this, |
|
859 | - $tickets |
|
860 | - ) |
|
861 | - : $spaces_remaining; |
|
862 | - } |
|
863 | - |
|
864 | - |
|
865 | - /** |
|
866 | - * perform_sold_out_status_check |
|
867 | - * checks all of this events's datetime reg_limit - sold values to determine if ANY datetimes have spaces |
|
868 | - * available... if NOT, then the event status will get toggled to 'sold_out' |
|
869 | - * |
|
870 | - * @return bool return the ACTUAL sold out state. |
|
871 | - * @throws EE_Error |
|
872 | - * @throws DomainException |
|
873 | - * @throws UnexpectedEntityException |
|
874 | - */ |
|
875 | - public function perform_sold_out_status_check() |
|
876 | - { |
|
877 | - // get all tickets |
|
878 | - $tickets = $this->tickets( |
|
879 | - array( |
|
880 | - 'default_where_conditions' => 'none', |
|
881 | - 'order_by' => array('TKT_qty' => 'ASC'), |
|
882 | - ) |
|
883 | - ); |
|
884 | - $all_expired = true; |
|
885 | - foreach ($tickets as $ticket) { |
|
886 | - if (! $ticket->is_expired()) { |
|
887 | - $all_expired = false; |
|
888 | - break; |
|
889 | - } |
|
890 | - } |
|
891 | - // if all the tickets are just expired, then don't update the event status to sold out |
|
892 | - if ($all_expired) { |
|
893 | - return true; |
|
894 | - } |
|
895 | - $spaces_remaining = $this->spaces_remaining($tickets); |
|
896 | - if ($spaces_remaining < 1) { |
|
897 | - if ($this->status() !== EEM_Event::post_status_private) { |
|
898 | - $this->set_status(EEM_Event::sold_out); |
|
899 | - $this->save(); |
|
900 | - } |
|
901 | - $sold_out = true; |
|
902 | - } else { |
|
903 | - $sold_out = false; |
|
904 | - // was event previously marked as sold out ? |
|
905 | - if ($this->status() === EEM_Event::sold_out) { |
|
906 | - // revert status to previous value, if it was set |
|
907 | - $previous_event_status = $this->get_post_meta('_previous_event_status', true); |
|
908 | - if ($previous_event_status) { |
|
909 | - $this->set_status($previous_event_status); |
|
910 | - $this->save(); |
|
911 | - } |
|
912 | - } |
|
913 | - } |
|
914 | - do_action('AHEE__EE_Event__perform_sold_out_status_check__end', $this, $sold_out, $spaces_remaining, $tickets); |
|
915 | - return $sold_out; |
|
916 | - } |
|
917 | - |
|
918 | - |
|
919 | - /** |
|
920 | - * This returns the total remaining spaces for sale on this event. |
|
921 | - * |
|
922 | - * @uses EE_Event::total_available_spaces() |
|
923 | - * @return float|int |
|
924 | - * @throws EE_Error |
|
925 | - * @throws DomainException |
|
926 | - * @throws UnexpectedEntityException |
|
927 | - */ |
|
928 | - public function spaces_remaining_for_sale() |
|
929 | - { |
|
930 | - return $this->total_available_spaces(true); |
|
931 | - } |
|
932 | - |
|
933 | - |
|
934 | - /** |
|
935 | - * This returns the total spaces available for an event |
|
936 | - * while considering all the qtys on the tickets and the reg limits |
|
937 | - * on the datetimes attached to this event. |
|
938 | - * |
|
939 | - * @param bool $consider_sold Whether to consider any tickets that have already sold in our calculation. |
|
940 | - * If this is false, then we return the most tickets that could ever be sold |
|
941 | - * for this event with the datetime and tickets setup on the event under optimal |
|
942 | - * selling conditions. Otherwise we return a live calculation of spaces available |
|
943 | - * based on tickets sold. Depending on setup and stage of sales, this |
|
944 | - * may appear to equal remaining tickets. However, the more tickets are |
|
945 | - * sold out, the more accurate the "live" total is. |
|
946 | - * @return float|int |
|
947 | - * @throws EE_Error |
|
948 | - * @throws DomainException |
|
949 | - * @throws UnexpectedEntityException |
|
950 | - */ |
|
951 | - public function total_available_spaces($consider_sold = false) |
|
952 | - { |
|
953 | - $spaces_available = $consider_sold |
|
954 | - ? $this->getAvailableSpacesCalculator()->spacesRemaining() |
|
955 | - : $this->getAvailableSpacesCalculator()->totalSpacesAvailable(); |
|
956 | - return apply_filters( |
|
957 | - 'FHEE_EE_Event__total_available_spaces__spaces_available', |
|
958 | - $spaces_available, |
|
959 | - $this, |
|
960 | - $this->getAvailableSpacesCalculator()->getDatetimes(), |
|
961 | - $this->getAvailableSpacesCalculator()->getActiveTickets() |
|
962 | - ); |
|
963 | - } |
|
964 | - |
|
965 | - |
|
966 | - /** |
|
967 | - * Checks if the event is set to sold out |
|
968 | - * |
|
969 | - * @param bool $actual whether or not to perform calculations to not only figure the |
|
970 | - * actual status but also to flip the status if necessary to sold |
|
971 | - * out If false, we just check the existing status of the event |
|
972 | - * @return boolean |
|
973 | - * @throws EE_Error |
|
974 | - */ |
|
975 | - public function is_sold_out($actual = false) |
|
976 | - { |
|
977 | - if (! $actual) { |
|
978 | - return $this->status() === EEM_Event::sold_out; |
|
979 | - } |
|
980 | - return $this->perform_sold_out_status_check(); |
|
981 | - } |
|
982 | - |
|
983 | - |
|
984 | - /** |
|
985 | - * Checks if the event is marked as postponed |
|
986 | - * |
|
987 | - * @return boolean |
|
988 | - */ |
|
989 | - public function is_postponed() |
|
990 | - { |
|
991 | - return $this->status() === EEM_Event::postponed; |
|
992 | - } |
|
993 | - |
|
994 | - |
|
995 | - /** |
|
996 | - * Checks if the event is marked as cancelled |
|
997 | - * |
|
998 | - * @return boolean |
|
999 | - */ |
|
1000 | - public function is_cancelled() |
|
1001 | - { |
|
1002 | - return $this->status() === EEM_Event::cancelled; |
|
1003 | - } |
|
1004 | - |
|
1005 | - |
|
1006 | - /** |
|
1007 | - * Get the logical active status in a hierarchical order for all the datetimes. Note |
|
1008 | - * Basically, we order the datetimes by EVT_start_date. Then first test on whether the event is published. If its |
|
1009 | - * NOT published then we test for whether its expired or not. IF it IS published then we test first on whether an |
|
1010 | - * event has any active dates. If no active dates then we check for any upcoming dates. If no upcoming dates then |
|
1011 | - * the event is considered expired. |
|
1012 | - * NOTE: this method does NOT calculate whether the datetimes are sold out when event is published. Sold Out is a |
|
1013 | - * status set on the EVENT when it is not published and thus is done |
|
1014 | - * |
|
1015 | - * @param bool $reset |
|
1016 | - * @return bool | string - based on EE_Datetime active constants or FALSE if error. |
|
1017 | - * @throws EE_Error |
|
1018 | - */ |
|
1019 | - public function get_active_status($reset = false) |
|
1020 | - { |
|
1021 | - // if the active status has already been set, then just use that value (unless we are resetting it) |
|
1022 | - if (! empty($this->_active_status) && ! $reset) { |
|
1023 | - return $this->_active_status; |
|
1024 | - } |
|
1025 | - // first check if event id is present on this object |
|
1026 | - if (! $this->ID()) { |
|
1027 | - return false; |
|
1028 | - } |
|
1029 | - $where_params_for_event = array(array('EVT_ID' => $this->ID())); |
|
1030 | - // if event is published: |
|
1031 | - if ($this->status() === EEM_Event::post_status_publish || $this->status() === EEM_Event::post_status_private) { |
|
1032 | - // active? |
|
1033 | - if ( |
|
1034 | - EEM_Datetime::instance()->get_datetime_count_for_status( |
|
1035 | - EE_Datetime::active, |
|
1036 | - $where_params_for_event |
|
1037 | - ) > 0 |
|
1038 | - ) { |
|
1039 | - $this->_active_status = EE_Datetime::active; |
|
1040 | - } else { |
|
1041 | - // upcoming? |
|
1042 | - if ( |
|
1043 | - EEM_Datetime::instance()->get_datetime_count_for_status( |
|
1044 | - EE_Datetime::upcoming, |
|
1045 | - $where_params_for_event |
|
1046 | - ) > 0 |
|
1047 | - ) { |
|
1048 | - $this->_active_status = EE_Datetime::upcoming; |
|
1049 | - } else { |
|
1050 | - // expired? |
|
1051 | - if ( |
|
1052 | - EEM_Datetime::instance()->get_datetime_count_for_status( |
|
1053 | - EE_Datetime::expired, |
|
1054 | - $where_params_for_event |
|
1055 | - ) > 0 |
|
1056 | - ) { |
|
1057 | - $this->_active_status = EE_Datetime::expired; |
|
1058 | - } else { |
|
1059 | - // it would be odd if things make it this far because it basically means there are no datetime's |
|
1060 | - // attached to the event. So in this case it will just be considered inactive. |
|
1061 | - $this->_active_status = EE_Datetime::inactive; |
|
1062 | - } |
|
1063 | - } |
|
1064 | - } |
|
1065 | - } else { |
|
1066 | - // the event is not published, so let's just set it's active status according to its' post status |
|
1067 | - switch ($this->status()) { |
|
1068 | - case EEM_Event::sold_out: |
|
1069 | - $this->_active_status = EE_Datetime::sold_out; |
|
1070 | - break; |
|
1071 | - case EEM_Event::cancelled: |
|
1072 | - $this->_active_status = EE_Datetime::cancelled; |
|
1073 | - break; |
|
1074 | - case EEM_Event::postponed: |
|
1075 | - $this->_active_status = EE_Datetime::postponed; |
|
1076 | - break; |
|
1077 | - default: |
|
1078 | - $this->_active_status = EE_Datetime::inactive; |
|
1079 | - } |
|
1080 | - } |
|
1081 | - return $this->_active_status; |
|
1082 | - } |
|
1083 | - |
|
1084 | - |
|
1085 | - /** |
|
1086 | - * pretty_active_status |
|
1087 | - * |
|
1088 | - * @access public |
|
1089 | - * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
|
1090 | - * @return mixed void|string |
|
1091 | - * @throws EE_Error |
|
1092 | - */ |
|
1093 | - public function pretty_active_status($echo = true) |
|
1094 | - { |
|
1095 | - $active_status = $this->get_active_status(); |
|
1096 | - $status = '<span class="ee-status event-active-status-' |
|
1097 | - . $active_status |
|
1098 | - . '">' |
|
1099 | - . EEH_Template::pretty_status($active_status, false, 'sentence') |
|
1100 | - . '</span>'; |
|
1101 | - if ($echo) { |
|
1102 | - echo $status; |
|
1103 | - return ''; |
|
1104 | - } |
|
1105 | - return $status; |
|
1106 | - } |
|
1107 | - |
|
1108 | - |
|
1109 | - /** |
|
1110 | - * @return bool|int |
|
1111 | - * @throws EE_Error |
|
1112 | - */ |
|
1113 | - public function get_number_of_tickets_sold() |
|
1114 | - { |
|
1115 | - $tkt_sold = 0; |
|
1116 | - if (! $this->ID()) { |
|
1117 | - return 0; |
|
1118 | - } |
|
1119 | - $datetimes = $this->datetimes(); |
|
1120 | - foreach ($datetimes as $datetime) { |
|
1121 | - if ($datetime instanceof EE_Datetime) { |
|
1122 | - $tkt_sold += $datetime->sold(); |
|
1123 | - } |
|
1124 | - } |
|
1125 | - return $tkt_sold; |
|
1126 | - } |
|
1127 | - |
|
1128 | - |
|
1129 | - /** |
|
1130 | - * This just returns a count of all the registrations for this event |
|
1131 | - * |
|
1132 | - * @access public |
|
1133 | - * @return int |
|
1134 | - * @throws EE_Error |
|
1135 | - */ |
|
1136 | - public function get_count_of_all_registrations() |
|
1137 | - { |
|
1138 | - return EEM_Event::instance()->count_related($this, 'Registration'); |
|
1139 | - } |
|
1140 | - |
|
1141 | - |
|
1142 | - /** |
|
1143 | - * This returns the ticket with the earliest start time that is |
|
1144 | - * available for this event (across all datetimes attached to the event) |
|
1145 | - * |
|
1146 | - * @return EE_Base_Class|EE_Ticket|null |
|
1147 | - * @throws EE_Error |
|
1148 | - */ |
|
1149 | - public function get_ticket_with_earliest_start_time() |
|
1150 | - { |
|
1151 | - $where['Datetime.EVT_ID'] = $this->ID(); |
|
1152 | - $query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC')); |
|
1153 | - return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1154 | - } |
|
1155 | - |
|
1156 | - |
|
1157 | - /** |
|
1158 | - * This returns the ticket with the latest end time that is available |
|
1159 | - * for this event (across all datetimes attached to the event) |
|
1160 | - * |
|
1161 | - * @return EE_Base_Class|EE_Ticket|null |
|
1162 | - * @throws EE_Error |
|
1163 | - */ |
|
1164 | - public function get_ticket_with_latest_end_time() |
|
1165 | - { |
|
1166 | - $where['Datetime.EVT_ID'] = $this->ID(); |
|
1167 | - $query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC')); |
|
1168 | - return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1169 | - } |
|
1170 | - |
|
1171 | - |
|
1172 | - /** |
|
1173 | - * This returns the number of different ticket types currently on sale for this event. |
|
1174 | - * |
|
1175 | - * @return int |
|
1176 | - * @throws EE_Error |
|
1177 | - */ |
|
1178 | - public function countTicketsOnSale() |
|
1179 | - { |
|
1180 | - $where = array( |
|
1181 | - 'Datetime.EVT_ID' => $this->ID(), |
|
1182 | - 'TKT_start_date' => array('<', time()), |
|
1183 | - 'TKT_end_date' => array('>', time()), |
|
1184 | - ); |
|
1185 | - return EEM_Ticket::instance()->count(array($where)); |
|
1186 | - } |
|
1187 | - |
|
1188 | - |
|
1189 | - /** |
|
1190 | - * This returns whether there are any tickets on sale for this event. |
|
1191 | - * |
|
1192 | - * @return bool true = YES tickets on sale. |
|
1193 | - * @throws EE_Error |
|
1194 | - */ |
|
1195 | - public function tickets_on_sale() |
|
1196 | - { |
|
1197 | - return $this->countTicketsOnSale() > 0; |
|
1198 | - } |
|
1199 | - |
|
1200 | - |
|
1201 | - /** |
|
1202 | - * Gets the URL for viewing this event on the front-end. Overrides parent |
|
1203 | - * to check for an external URL first |
|
1204 | - * |
|
1205 | - * @return string |
|
1206 | - * @throws EE_Error |
|
1207 | - */ |
|
1208 | - public function get_permalink() |
|
1209 | - { |
|
1210 | - if ($this->external_url()) { |
|
1211 | - return $this->external_url(); |
|
1212 | - } |
|
1213 | - return parent::get_permalink(); |
|
1214 | - } |
|
1215 | - |
|
1216 | - |
|
1217 | - /** |
|
1218 | - * Gets the first term for 'espresso_event_categories' we can find |
|
1219 | - * |
|
1220 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1221 | - * @return EE_Base_Class|EE_Term|null |
|
1222 | - * @throws EE_Error |
|
1223 | - */ |
|
1224 | - public function first_event_category($query_params = array()) |
|
1225 | - { |
|
1226 | - $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1227 | - $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1228 | - return EEM_Term::instance()->get_one($query_params); |
|
1229 | - } |
|
1230 | - |
|
1231 | - |
|
1232 | - /** |
|
1233 | - * Gets all terms for 'espresso_event_categories' we can find |
|
1234 | - * |
|
1235 | - * @param array $query_params |
|
1236 | - * @return EE_Base_Class[]|EE_Term[] |
|
1237 | - * @throws EE_Error |
|
1238 | - */ |
|
1239 | - public function get_all_event_categories($query_params = array()) |
|
1240 | - { |
|
1241 | - $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1242 | - $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1243 | - return EEM_Term::instance()->get_all($query_params); |
|
1244 | - } |
|
1245 | - |
|
1246 | - |
|
1247 | - /** |
|
1248 | - * Adds a question group to this event |
|
1249 | - * |
|
1250 | - * @param EE_Question_Group|int $question_group_id_or_obj |
|
1251 | - * @param bool $for_primary if true, the question group will be added for the primary |
|
1252 | - * registrant, if false will be added for others. default: false |
|
1253 | - * @return EE_Base_Class|EE_Question_Group |
|
1254 | - * @throws EE_Error |
|
1255 | - * @throws InvalidArgumentException |
|
1256 | - * @throws InvalidDataTypeException |
|
1257 | - * @throws InvalidInterfaceException |
|
1258 | - * @throws ReflectionException |
|
1259 | - */ |
|
1260 | - public function add_question_group($question_group_id_or_obj, $for_primary = false) |
|
1261 | - { |
|
1262 | - // If the row already exists, it will be updated. If it doesn't, it will be inserted. |
|
1263 | - // That's in EE_HABTM_Relation::add_relation_to(). |
|
1264 | - return $this->_add_relation_to( |
|
1265 | - $question_group_id_or_obj, |
|
1266 | - 'Question_Group', |
|
1267 | - [ |
|
1268 | - EEM_Event_Question_Group::instance()->fieldNameForContext($for_primary) => true |
|
1269 | - ] |
|
1270 | - ); |
|
1271 | - } |
|
1272 | - |
|
1273 | - |
|
1274 | - /** |
|
1275 | - * Removes a question group from the event |
|
1276 | - * |
|
1277 | - * @param EE_Question_Group|int $question_group_id_or_obj |
|
1278 | - * @param bool $for_primary if true, the question group will be removed from the primary |
|
1279 | - * registrant, if false will be removed from others. default: false |
|
1280 | - * @return EE_Base_Class|EE_Question_Group |
|
1281 | - * @throws EE_Error |
|
1282 | - * @throws InvalidArgumentException |
|
1283 | - * @throws ReflectionException |
|
1284 | - * @throws InvalidDataTypeException |
|
1285 | - * @throws InvalidInterfaceException |
|
1286 | - */ |
|
1287 | - public function remove_question_group($question_group_id_or_obj, $for_primary = false) |
|
1288 | - { |
|
1289 | - // If the question group is used for the other type (primary or additional) |
|
1290 | - // then just update it. If not, delete it outright. |
|
1291 | - $existing_relation = $this->get_first_related( |
|
1292 | - 'Event_Question_Group', |
|
1293 | - [ |
|
1294 | - [ |
|
1295 | - 'QSG_ID' => EEM_Question_Group::instance()->ensure_is_ID($question_group_id_or_obj) |
|
1296 | - ] |
|
1297 | - ] |
|
1298 | - ); |
|
1299 | - $field_to_update = EEM_Event_Question_Group::instance()->fieldNameForContext($for_primary); |
|
1300 | - $other_field = EEM_Event_Question_Group::instance()->fieldNameForContext(! $for_primary); |
|
1301 | - if ($existing_relation->get($other_field) === false) { |
|
1302 | - // Delete it. It's now no longer for primary or additional question groups. |
|
1303 | - return $this->_remove_relation_to($question_group_id_or_obj, 'Question_Group'); |
|
1304 | - } |
|
1305 | - // Just update it. They'll still use this question group for the other category |
|
1306 | - $existing_relation->save( |
|
1307 | - [ |
|
1308 | - $field_to_update => false |
|
1309 | - ] |
|
1310 | - ); |
|
1311 | - } |
|
1312 | - |
|
1313 | - |
|
1314 | - /** |
|
1315 | - * Gets all the question groups, ordering them by QSG_order ascending |
|
1316 | - * |
|
1317 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1318 | - * @return EE_Base_Class[]|EE_Question_Group[] |
|
1319 | - * @throws EE_Error |
|
1320 | - */ |
|
1321 | - public function question_groups($query_params = array()) |
|
1322 | - { |
|
1323 | - $query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC')); |
|
1324 | - return $this->get_many_related('Question_Group', $query_params); |
|
1325 | - } |
|
1326 | - |
|
1327 | - |
|
1328 | - /** |
|
1329 | - * Implementation for EEI_Has_Icon interface method. |
|
1330 | - * |
|
1331 | - * @see EEI_Visual_Representation for comments |
|
1332 | - * @return string |
|
1333 | - */ |
|
1334 | - public function get_icon() |
|
1335 | - { |
|
1336 | - return '<span class="dashicons dashicons-flag"></span>'; |
|
1337 | - } |
|
1338 | - |
|
1339 | - |
|
1340 | - /** |
|
1341 | - * Implementation for EEI_Admin_Links interface method. |
|
1342 | - * |
|
1343 | - * @see EEI_Admin_Links for comments |
|
1344 | - * @return string |
|
1345 | - * @throws EE_Error |
|
1346 | - */ |
|
1347 | - public function get_admin_details_link() |
|
1348 | - { |
|
1349 | - return $this->get_admin_edit_link(); |
|
1350 | - } |
|
1351 | - |
|
1352 | - |
|
1353 | - /** |
|
1354 | - * Implementation for EEI_Admin_Links interface method. |
|
1355 | - * |
|
1356 | - * @see EEI_Admin_Links for comments |
|
1357 | - * @return string |
|
1358 | - * @throws EE_Error |
|
1359 | - */ |
|
1360 | - public function get_admin_edit_link() |
|
1361 | - { |
|
1362 | - return EEH_URL::add_query_args_and_nonce( |
|
1363 | - array( |
|
1364 | - 'page' => 'espresso_events', |
|
1365 | - 'action' => 'edit', |
|
1366 | - 'post' => $this->ID(), |
|
1367 | - ), |
|
1368 | - admin_url('admin.php') |
|
1369 | - ); |
|
1370 | - } |
|
1371 | - |
|
1372 | - |
|
1373 | - /** |
|
1374 | - * Implementation for EEI_Admin_Links interface method. |
|
1375 | - * |
|
1376 | - * @see EEI_Admin_Links for comments |
|
1377 | - * @return string |
|
1378 | - */ |
|
1379 | - public function get_admin_settings_link() |
|
1380 | - { |
|
1381 | - return EEH_URL::add_query_args_and_nonce( |
|
1382 | - array( |
|
1383 | - 'page' => 'espresso_events', |
|
1384 | - 'action' => 'default_event_settings', |
|
1385 | - ), |
|
1386 | - admin_url('admin.php') |
|
1387 | - ); |
|
1388 | - } |
|
1389 | - |
|
1390 | - |
|
1391 | - /** |
|
1392 | - * Implementation for EEI_Admin_Links interface method. |
|
1393 | - * |
|
1394 | - * @see EEI_Admin_Links for comments |
|
1395 | - * @return string |
|
1396 | - */ |
|
1397 | - public function get_admin_overview_link() |
|
1398 | - { |
|
1399 | - return EEH_URL::add_query_args_and_nonce( |
|
1400 | - array( |
|
1401 | - 'page' => 'espresso_events', |
|
1402 | - 'action' => 'default', |
|
1403 | - ), |
|
1404 | - admin_url('admin.php') |
|
1405 | - ); |
|
1406 | - } |
|
18 | + /** |
|
19 | + * cached value for the the logical active status for the event |
|
20 | + * |
|
21 | + * @see get_active_status() |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $_active_status = ''; |
|
25 | + |
|
26 | + /** |
|
27 | + * This is just used for caching the Primary Datetime for the Event on initial retrieval |
|
28 | + * |
|
29 | + * @var EE_Datetime |
|
30 | + */ |
|
31 | + protected $_Primary_Datetime; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var EventSpacesCalculator $available_spaces_calculator |
|
35 | + */ |
|
36 | + protected $available_spaces_calculator; |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * @param array $props_n_values incoming values |
|
41 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
42 | + * used.) |
|
43 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
44 | + * date_format and the second value is the time format |
|
45 | + * @return EE_Event |
|
46 | + * @throws EE_Error |
|
47 | + */ |
|
48 | + public static function new_instance($props_n_values = array(), $timezone = '', $date_formats = array()) |
|
49 | + { |
|
50 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
51 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * @param array $props_n_values incoming values from the database |
|
57 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
58 | + * the website will be used. |
|
59 | + * @return EE_Event |
|
60 | + * @throws EE_Error |
|
61 | + */ |
|
62 | + public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
63 | + { |
|
64 | + return new self($props_n_values, true, $timezone); |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * @return EventSpacesCalculator |
|
70 | + * @throws \EE_Error |
|
71 | + */ |
|
72 | + public function getAvailableSpacesCalculator() |
|
73 | + { |
|
74 | + if (! $this->available_spaces_calculator instanceof EventSpacesCalculator) { |
|
75 | + $this->available_spaces_calculator = new EventSpacesCalculator($this); |
|
76 | + } |
|
77 | + return $this->available_spaces_calculator; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * Overrides parent set() method so that all calls to set( 'status', $status ) can be routed to internal methods |
|
83 | + * |
|
84 | + * @param string $field_name |
|
85 | + * @param mixed $field_value |
|
86 | + * @param bool $use_default |
|
87 | + * @throws EE_Error |
|
88 | + */ |
|
89 | + public function set($field_name, $field_value, $use_default = false) |
|
90 | + { |
|
91 | + switch ($field_name) { |
|
92 | + case 'status': |
|
93 | + $this->set_status($field_value, $use_default); |
|
94 | + break; |
|
95 | + default: |
|
96 | + parent::set($field_name, $field_value, $use_default); |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * set_status |
|
103 | + * Checks if event status is being changed to SOLD OUT |
|
104 | + * and updates event meta data with previous event status |
|
105 | + * so that we can revert things if/when the event is no longer sold out |
|
106 | + * |
|
107 | + * @access public |
|
108 | + * @param string $new_status |
|
109 | + * @param bool $use_default |
|
110 | + * @return void |
|
111 | + * @throws EE_Error |
|
112 | + */ |
|
113 | + public function set_status($new_status = null, $use_default = false) |
|
114 | + { |
|
115 | + // if nothing is set, and we aren't explicitly wanting to reset the status, then just leave |
|
116 | + if (empty($new_status) && ! $use_default) { |
|
117 | + return; |
|
118 | + } |
|
119 | + // get current Event status |
|
120 | + $old_status = $this->status(); |
|
121 | + // if status has changed |
|
122 | + if ($old_status !== $new_status) { |
|
123 | + // TO sold_out |
|
124 | + if ($new_status === EEM_Event::sold_out) { |
|
125 | + // save the previous event status so that we can revert if the event is no longer sold out |
|
126 | + $this->add_post_meta('_previous_event_status', $old_status); |
|
127 | + do_action('AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status); |
|
128 | + // OR FROM sold_out |
|
129 | + } elseif ($old_status === EEM_Event::sold_out) { |
|
130 | + $this->delete_post_meta('_previous_event_status'); |
|
131 | + do_action('AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status); |
|
132 | + } |
|
133 | + // clear out the active status so that it gets reset the next time it is requested |
|
134 | + $this->_active_status = null; |
|
135 | + // update status |
|
136 | + parent::set('status', $new_status, $use_default); |
|
137 | + do_action('AHEE__EE_Event__set_status__after_update', $this); |
|
138 | + return; |
|
139 | + } |
|
140 | + // even though the old value matches the new value, it's still good to |
|
141 | + // allow the parent set method to have a say |
|
142 | + parent::set('status', $new_status, $use_default); |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * Gets all the datetimes for this event |
|
148 | + * |
|
149 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
150 | + * @return EE_Base_Class[]|EE_Datetime[] |
|
151 | + * @throws EE_Error |
|
152 | + */ |
|
153 | + public function datetimes($query_params = array()) |
|
154 | + { |
|
155 | + return $this->get_many_related('Datetime', $query_params); |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * Gets all the datetimes for this event, ordered by DTT_EVT_start in ascending order |
|
161 | + * |
|
162 | + * @return EE_Base_Class[]|EE_Datetime[] |
|
163 | + * @throws EE_Error |
|
164 | + */ |
|
165 | + public function datetimes_in_chronological_order() |
|
166 | + { |
|
167 | + return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC'))); |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * Gets all the datetimes for this event, ordered by the DTT_order on the datetime. |
|
173 | + * @darren, we should probably UNSET timezone on the EEM_Datetime model |
|
174 | + * after running our query, so that this timezone isn't set for EVERY query |
|
175 | + * on EEM_Datetime for the rest of the request, no? |
|
176 | + * |
|
177 | + * @param boolean $show_expired whether or not to include expired events |
|
178 | + * @param boolean $show_deleted whether or not to include deleted events |
|
179 | + * @param null $limit |
|
180 | + * @return EE_Datetime[] |
|
181 | + * @throws EE_Error |
|
182 | + */ |
|
183 | + public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null) |
|
184 | + { |
|
185 | + return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order( |
|
186 | + $this->ID(), |
|
187 | + $show_expired, |
|
188 | + $show_deleted, |
|
189 | + $limit |
|
190 | + ); |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + /** |
|
195 | + * Returns one related datetime. Mostly only used by some legacy code. |
|
196 | + * |
|
197 | + * @return EE_Base_Class|EE_Datetime |
|
198 | + * @throws EE_Error |
|
199 | + */ |
|
200 | + public function first_datetime() |
|
201 | + { |
|
202 | + return $this->get_first_related('Datetime'); |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + /** |
|
207 | + * Returns the 'primary' datetime for the event |
|
208 | + * |
|
209 | + * @param bool $try_to_exclude_expired |
|
210 | + * @param bool $try_to_exclude_deleted |
|
211 | + * @return EE_Datetime |
|
212 | + * @throws EE_Error |
|
213 | + */ |
|
214 | + public function primary_datetime($try_to_exclude_expired = true, $try_to_exclude_deleted = true) |
|
215 | + { |
|
216 | + if (! empty($this->_Primary_Datetime)) { |
|
217 | + return $this->_Primary_Datetime; |
|
218 | + } |
|
219 | + $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event( |
|
220 | + $this->ID(), |
|
221 | + $try_to_exclude_expired, |
|
222 | + $try_to_exclude_deleted |
|
223 | + ); |
|
224 | + return $this->_Primary_Datetime; |
|
225 | + } |
|
226 | + |
|
227 | + |
|
228 | + /** |
|
229 | + * Gets all the tickets available for purchase of this event |
|
230 | + * |
|
231 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
232 | + * @return EE_Base_Class[]|EE_Ticket[] |
|
233 | + * @throws EE_Error |
|
234 | + */ |
|
235 | + public function tickets($query_params = array()) |
|
236 | + { |
|
237 | + // first get all datetimes |
|
238 | + $datetimes = $this->datetimes_ordered(); |
|
239 | + if (! $datetimes) { |
|
240 | + return array(); |
|
241 | + } |
|
242 | + $datetime_ids = array(); |
|
243 | + foreach ($datetimes as $datetime) { |
|
244 | + $datetime_ids[] = $datetime->ID(); |
|
245 | + } |
|
246 | + $where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids)); |
|
247 | + // if incoming $query_params has where conditions let's merge but not override existing. |
|
248 | + if (is_array($query_params) && isset($query_params[0])) { |
|
249 | + $where_params = array_merge($query_params[0], $where_params); |
|
250 | + unset($query_params[0]); |
|
251 | + } |
|
252 | + // now add $where_params to $query_params |
|
253 | + $query_params[0] = $where_params; |
|
254 | + return EEM_Ticket::instance()->get_all($query_params); |
|
255 | + } |
|
256 | + |
|
257 | + |
|
258 | + /** |
|
259 | + * get all unexpired untrashed tickets |
|
260 | + * |
|
261 | + * @return EE_Ticket[] |
|
262 | + * @throws EE_Error |
|
263 | + */ |
|
264 | + public function active_tickets() |
|
265 | + { |
|
266 | + return $this->tickets( |
|
267 | + array( |
|
268 | + array( |
|
269 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
270 | + 'TKT_deleted' => false, |
|
271 | + ), |
|
272 | + ) |
|
273 | + ); |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + /** |
|
278 | + * @return bool |
|
279 | + * @throws EE_Error |
|
280 | + */ |
|
281 | + public function additional_limit() |
|
282 | + { |
|
283 | + return $this->get('EVT_additional_limit'); |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * @return bool |
|
289 | + * @throws EE_Error |
|
290 | + */ |
|
291 | + public function allow_overflow() |
|
292 | + { |
|
293 | + return $this->get('EVT_allow_overflow'); |
|
294 | + } |
|
295 | + |
|
296 | + |
|
297 | + /** |
|
298 | + * @return bool |
|
299 | + * @throws EE_Error |
|
300 | + */ |
|
301 | + public function created() |
|
302 | + { |
|
303 | + return $this->get('EVT_created'); |
|
304 | + } |
|
305 | + |
|
306 | + |
|
307 | + /** |
|
308 | + * @return bool |
|
309 | + * @throws EE_Error |
|
310 | + */ |
|
311 | + public function description() |
|
312 | + { |
|
313 | + return $this->get('EVT_desc'); |
|
314 | + } |
|
315 | + |
|
316 | + |
|
317 | + /** |
|
318 | + * Runs do_shortcode and wpautop on the description |
|
319 | + * |
|
320 | + * @return string of html |
|
321 | + * @throws EE_Error |
|
322 | + */ |
|
323 | + public function description_filtered() |
|
324 | + { |
|
325 | + return $this->get_pretty('EVT_desc'); |
|
326 | + } |
|
327 | + |
|
328 | + |
|
329 | + /** |
|
330 | + * @return bool |
|
331 | + * @throws EE_Error |
|
332 | + */ |
|
333 | + public function display_description() |
|
334 | + { |
|
335 | + return $this->get('EVT_display_desc'); |
|
336 | + } |
|
337 | + |
|
338 | + |
|
339 | + /** |
|
340 | + * @return bool |
|
341 | + * @throws EE_Error |
|
342 | + */ |
|
343 | + public function display_ticket_selector() |
|
344 | + { |
|
345 | + return (bool) $this->get('EVT_display_ticket_selector'); |
|
346 | + } |
|
347 | + |
|
348 | + |
|
349 | + /** |
|
350 | + * @return bool |
|
351 | + * @throws EE_Error |
|
352 | + */ |
|
353 | + public function external_url() |
|
354 | + { |
|
355 | + return $this->get('EVT_external_URL'); |
|
356 | + } |
|
357 | + |
|
358 | + |
|
359 | + /** |
|
360 | + * @return bool |
|
361 | + * @throws EE_Error |
|
362 | + */ |
|
363 | + public function member_only() |
|
364 | + { |
|
365 | + return $this->get('EVT_member_only'); |
|
366 | + } |
|
367 | + |
|
368 | + |
|
369 | + /** |
|
370 | + * @return bool |
|
371 | + * @throws EE_Error |
|
372 | + */ |
|
373 | + public function phone() |
|
374 | + { |
|
375 | + return $this->get('EVT_phone'); |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + /** |
|
380 | + * @return bool |
|
381 | + * @throws EE_Error |
|
382 | + */ |
|
383 | + public function modified() |
|
384 | + { |
|
385 | + return $this->get('EVT_modified'); |
|
386 | + } |
|
387 | + |
|
388 | + |
|
389 | + /** |
|
390 | + * @return bool |
|
391 | + * @throws EE_Error |
|
392 | + */ |
|
393 | + public function name() |
|
394 | + { |
|
395 | + return $this->get('EVT_name'); |
|
396 | + } |
|
397 | + |
|
398 | + |
|
399 | + /** |
|
400 | + * @return bool |
|
401 | + * @throws EE_Error |
|
402 | + */ |
|
403 | + public function order() |
|
404 | + { |
|
405 | + return $this->get('EVT_order'); |
|
406 | + } |
|
407 | + |
|
408 | + |
|
409 | + /** |
|
410 | + * @return bool|string |
|
411 | + * @throws EE_Error |
|
412 | + */ |
|
413 | + public function default_registration_status() |
|
414 | + { |
|
415 | + $event_default_registration_status = $this->get('EVT_default_registration_status'); |
|
416 | + return ! empty($event_default_registration_status) |
|
417 | + ? $event_default_registration_status |
|
418 | + : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
419 | + } |
|
420 | + |
|
421 | + |
|
422 | + /** |
|
423 | + * @param int $num_words |
|
424 | + * @param null $more |
|
425 | + * @param bool $not_full_desc |
|
426 | + * @return bool|string |
|
427 | + * @throws EE_Error |
|
428 | + */ |
|
429 | + public function short_description($num_words = 55, $more = null, $not_full_desc = false) |
|
430 | + { |
|
431 | + $short_desc = $this->get('EVT_short_desc'); |
|
432 | + if (! empty($short_desc) || $not_full_desc) { |
|
433 | + return $short_desc; |
|
434 | + } |
|
435 | + $full_desc = $this->get('EVT_desc'); |
|
436 | + return wp_trim_words($full_desc, $num_words, $more); |
|
437 | + } |
|
438 | + |
|
439 | + |
|
440 | + /** |
|
441 | + * @return bool |
|
442 | + * @throws EE_Error |
|
443 | + */ |
|
444 | + public function slug() |
|
445 | + { |
|
446 | + return $this->get('EVT_slug'); |
|
447 | + } |
|
448 | + |
|
449 | + |
|
450 | + /** |
|
451 | + * @return bool |
|
452 | + * @throws EE_Error |
|
453 | + */ |
|
454 | + public function timezone_string() |
|
455 | + { |
|
456 | + return $this->get('EVT_timezone_string'); |
|
457 | + } |
|
458 | + |
|
459 | + |
|
460 | + /** |
|
461 | + * @return bool |
|
462 | + * @throws EE_Error |
|
463 | + */ |
|
464 | + public function visible_on() |
|
465 | + { |
|
466 | + return $this->get('EVT_visible_on'); |
|
467 | + } |
|
468 | + |
|
469 | + |
|
470 | + /** |
|
471 | + * @return int |
|
472 | + * @throws EE_Error |
|
473 | + */ |
|
474 | + public function wp_user() |
|
475 | + { |
|
476 | + return $this->get('EVT_wp_user'); |
|
477 | + } |
|
478 | + |
|
479 | + |
|
480 | + /** |
|
481 | + * @return bool |
|
482 | + * @throws EE_Error |
|
483 | + */ |
|
484 | + public function donations() |
|
485 | + { |
|
486 | + return $this->get('EVT_donations'); |
|
487 | + } |
|
488 | + |
|
489 | + |
|
490 | + /** |
|
491 | + * @param $limit |
|
492 | + * @throws EE_Error |
|
493 | + */ |
|
494 | + public function set_additional_limit($limit) |
|
495 | + { |
|
496 | + $this->set('EVT_additional_limit', $limit); |
|
497 | + } |
|
498 | + |
|
499 | + |
|
500 | + /** |
|
501 | + * @param $created |
|
502 | + * @throws EE_Error |
|
503 | + */ |
|
504 | + public function set_created($created) |
|
505 | + { |
|
506 | + $this->set('EVT_created', $created); |
|
507 | + } |
|
508 | + |
|
509 | + |
|
510 | + /** |
|
511 | + * @param $desc |
|
512 | + * @throws EE_Error |
|
513 | + */ |
|
514 | + public function set_description($desc) |
|
515 | + { |
|
516 | + $this->set('EVT_desc', $desc); |
|
517 | + } |
|
518 | + |
|
519 | + |
|
520 | + /** |
|
521 | + * @param $display_desc |
|
522 | + * @throws EE_Error |
|
523 | + */ |
|
524 | + public function set_display_description($display_desc) |
|
525 | + { |
|
526 | + $this->set('EVT_display_desc', $display_desc); |
|
527 | + } |
|
528 | + |
|
529 | + |
|
530 | + /** |
|
531 | + * @param $display_ticket_selector |
|
532 | + * @throws EE_Error |
|
533 | + */ |
|
534 | + public function set_display_ticket_selector($display_ticket_selector) |
|
535 | + { |
|
536 | + $this->set('EVT_display_ticket_selector', $display_ticket_selector); |
|
537 | + } |
|
538 | + |
|
539 | + |
|
540 | + /** |
|
541 | + * @param $external_url |
|
542 | + * @throws EE_Error |
|
543 | + */ |
|
544 | + public function set_external_url($external_url) |
|
545 | + { |
|
546 | + $this->set('EVT_external_URL', $external_url); |
|
547 | + } |
|
548 | + |
|
549 | + |
|
550 | + /** |
|
551 | + * @param $member_only |
|
552 | + * @throws EE_Error |
|
553 | + */ |
|
554 | + public function set_member_only($member_only) |
|
555 | + { |
|
556 | + $this->set('EVT_member_only', $member_only); |
|
557 | + } |
|
558 | + |
|
559 | + |
|
560 | + /** |
|
561 | + * @param $event_phone |
|
562 | + * @throws EE_Error |
|
563 | + */ |
|
564 | + public function set_event_phone($event_phone) |
|
565 | + { |
|
566 | + $this->set('EVT_phone', $event_phone); |
|
567 | + } |
|
568 | + |
|
569 | + |
|
570 | + /** |
|
571 | + * @param $modified |
|
572 | + * @throws EE_Error |
|
573 | + */ |
|
574 | + public function set_modified($modified) |
|
575 | + { |
|
576 | + $this->set('EVT_modified', $modified); |
|
577 | + } |
|
578 | + |
|
579 | + |
|
580 | + /** |
|
581 | + * @param $name |
|
582 | + * @throws EE_Error |
|
583 | + */ |
|
584 | + public function set_name($name) |
|
585 | + { |
|
586 | + $this->set('EVT_name', $name); |
|
587 | + } |
|
588 | + |
|
589 | + |
|
590 | + /** |
|
591 | + * @param $order |
|
592 | + * @throws EE_Error |
|
593 | + */ |
|
594 | + public function set_order($order) |
|
595 | + { |
|
596 | + $this->set('EVT_order', $order); |
|
597 | + } |
|
598 | + |
|
599 | + |
|
600 | + /** |
|
601 | + * @param $short_desc |
|
602 | + * @throws EE_Error |
|
603 | + */ |
|
604 | + public function set_short_description($short_desc) |
|
605 | + { |
|
606 | + $this->set('EVT_short_desc', $short_desc); |
|
607 | + } |
|
608 | + |
|
609 | + |
|
610 | + /** |
|
611 | + * @param $slug |
|
612 | + * @throws EE_Error |
|
613 | + */ |
|
614 | + public function set_slug($slug) |
|
615 | + { |
|
616 | + $this->set('EVT_slug', $slug); |
|
617 | + } |
|
618 | + |
|
619 | + |
|
620 | + /** |
|
621 | + * @param $timezone_string |
|
622 | + * @throws EE_Error |
|
623 | + */ |
|
624 | + public function set_timezone_string($timezone_string) |
|
625 | + { |
|
626 | + $this->set('EVT_timezone_string', $timezone_string); |
|
627 | + } |
|
628 | + |
|
629 | + |
|
630 | + /** |
|
631 | + * @param $visible_on |
|
632 | + * @throws EE_Error |
|
633 | + */ |
|
634 | + public function set_visible_on($visible_on) |
|
635 | + { |
|
636 | + $this->set('EVT_visible_on', $visible_on); |
|
637 | + } |
|
638 | + |
|
639 | + |
|
640 | + /** |
|
641 | + * @param $wp_user |
|
642 | + * @throws EE_Error |
|
643 | + */ |
|
644 | + public function set_wp_user($wp_user) |
|
645 | + { |
|
646 | + $this->set('EVT_wp_user', $wp_user); |
|
647 | + } |
|
648 | + |
|
649 | + |
|
650 | + /** |
|
651 | + * @param $default_registration_status |
|
652 | + * @throws EE_Error |
|
653 | + */ |
|
654 | + public function set_default_registration_status($default_registration_status) |
|
655 | + { |
|
656 | + $this->set('EVT_default_registration_status', $default_registration_status); |
|
657 | + } |
|
658 | + |
|
659 | + |
|
660 | + /** |
|
661 | + * @param $donations |
|
662 | + * @throws EE_Error |
|
663 | + */ |
|
664 | + public function set_donations($donations) |
|
665 | + { |
|
666 | + $this->set('EVT_donations', $donations); |
|
667 | + } |
|
668 | + |
|
669 | + |
|
670 | + /** |
|
671 | + * Adds a venue to this event |
|
672 | + * |
|
673 | + * @param EE_Venue /int $venue_id_or_obj |
|
674 | + * @return EE_Base_Class|EE_Venue |
|
675 | + * @throws EE_Error |
|
676 | + */ |
|
677 | + public function add_venue($venue_id_or_obj) |
|
678 | + { |
|
679 | + return $this->_add_relation_to($venue_id_or_obj, 'Venue'); |
|
680 | + } |
|
681 | + |
|
682 | + |
|
683 | + /** |
|
684 | + * Removes a venue from the event |
|
685 | + * |
|
686 | + * @param EE_Venue /int $venue_id_or_obj |
|
687 | + * @return EE_Base_Class|EE_Venue |
|
688 | + * @throws EE_Error |
|
689 | + */ |
|
690 | + public function remove_venue($venue_id_or_obj) |
|
691 | + { |
|
692 | + return $this->_remove_relation_to($venue_id_or_obj, 'Venue'); |
|
693 | + } |
|
694 | + |
|
695 | + |
|
696 | + /** |
|
697 | + * Gets all the venues related ot the event. May provide additional $query_params if desired |
|
698 | + * |
|
699 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
700 | + * @return EE_Base_Class[]|EE_Venue[] |
|
701 | + * @throws EE_Error |
|
702 | + */ |
|
703 | + public function venues($query_params = array()) |
|
704 | + { |
|
705 | + return $this->get_many_related('Venue', $query_params); |
|
706 | + } |
|
707 | + |
|
708 | + |
|
709 | + /** |
|
710 | + * check if event id is present and if event is published |
|
711 | + * |
|
712 | + * @access public |
|
713 | + * @return boolean true yes, false no |
|
714 | + * @throws EE_Error |
|
715 | + */ |
|
716 | + private function _has_ID_and_is_published() |
|
717 | + { |
|
718 | + // first check if event id is present and not NULL, |
|
719 | + // then check if this event is published (or any of the equivalent "published" statuses) |
|
720 | + return |
|
721 | + $this->ID() && $this->ID() !== null |
|
722 | + && ( |
|
723 | + $this->status() === 'publish' |
|
724 | + || $this->status() === EEM_Event::sold_out |
|
725 | + || $this->status() === EEM_Event::postponed |
|
726 | + || $this->status() === EEM_Event::cancelled |
|
727 | + ); |
|
728 | + } |
|
729 | + |
|
730 | + |
|
731 | + /** |
|
732 | + * This simply compares the internal dates with NOW and determines if the event is upcoming or not. |
|
733 | + * |
|
734 | + * @access public |
|
735 | + * @return boolean true yes, false no |
|
736 | + * @throws EE_Error |
|
737 | + */ |
|
738 | + public function is_upcoming() |
|
739 | + { |
|
740 | + // check if event id is present and if this event is published |
|
741 | + if ($this->is_inactive()) { |
|
742 | + return false; |
|
743 | + } |
|
744 | + // set initial value |
|
745 | + $upcoming = false; |
|
746 | + // next let's get all datetimes and loop through them |
|
747 | + $datetimes = $this->datetimes_in_chronological_order(); |
|
748 | + foreach ($datetimes as $datetime) { |
|
749 | + if ($datetime instanceof EE_Datetime) { |
|
750 | + // if this dtt is expired then we continue cause one of the other datetimes might be upcoming. |
|
751 | + if ($datetime->is_expired()) { |
|
752 | + continue; |
|
753 | + } |
|
754 | + // if this dtt is active then we return false. |
|
755 | + if ($datetime->is_active()) { |
|
756 | + return false; |
|
757 | + } |
|
758 | + // otherwise let's check upcoming status |
|
759 | + $upcoming = $datetime->is_upcoming(); |
|
760 | + } |
|
761 | + } |
|
762 | + return $upcoming; |
|
763 | + } |
|
764 | + |
|
765 | + |
|
766 | + /** |
|
767 | + * @return bool |
|
768 | + * @throws EE_Error |
|
769 | + */ |
|
770 | + public function is_active() |
|
771 | + { |
|
772 | + // check if event id is present and if this event is published |
|
773 | + if ($this->is_inactive()) { |
|
774 | + return false; |
|
775 | + } |
|
776 | + // set initial value |
|
777 | + $active = false; |
|
778 | + // next let's get all datetimes and loop through them |
|
779 | + $datetimes = $this->datetimes_in_chronological_order(); |
|
780 | + foreach ($datetimes as $datetime) { |
|
781 | + if ($datetime instanceof EE_Datetime) { |
|
782 | + // if this dtt is expired then we continue cause one of the other datetimes might be active. |
|
783 | + if ($datetime->is_expired()) { |
|
784 | + continue; |
|
785 | + } |
|
786 | + // if this dtt is upcoming then we return false. |
|
787 | + if ($datetime->is_upcoming()) { |
|
788 | + return false; |
|
789 | + } |
|
790 | + // otherwise let's check active status |
|
791 | + $active = $datetime->is_active(); |
|
792 | + } |
|
793 | + } |
|
794 | + return $active; |
|
795 | + } |
|
796 | + |
|
797 | + |
|
798 | + /** |
|
799 | + * @return bool |
|
800 | + * @throws EE_Error |
|
801 | + */ |
|
802 | + public function is_expired() |
|
803 | + { |
|
804 | + // check if event id is present and if this event is published |
|
805 | + if ($this->is_inactive()) { |
|
806 | + return false; |
|
807 | + } |
|
808 | + // set initial value |
|
809 | + $expired = false; |
|
810 | + // first let's get all datetimes and loop through them |
|
811 | + $datetimes = $this->datetimes_in_chronological_order(); |
|
812 | + foreach ($datetimes as $datetime) { |
|
813 | + if ($datetime instanceof EE_Datetime) { |
|
814 | + // if this dtt is upcoming or active then we return false. |
|
815 | + if ($datetime->is_upcoming() || $datetime->is_active()) { |
|
816 | + return false; |
|
817 | + } |
|
818 | + // otherwise let's check active status |
|
819 | + $expired = $datetime->is_expired(); |
|
820 | + } |
|
821 | + } |
|
822 | + return $expired; |
|
823 | + } |
|
824 | + |
|
825 | + |
|
826 | + /** |
|
827 | + * @return bool |
|
828 | + * @throws EE_Error |
|
829 | + */ |
|
830 | + public function is_inactive() |
|
831 | + { |
|
832 | + // check if event id is present and if this event is published |
|
833 | + if ($this->_has_ID_and_is_published()) { |
|
834 | + return false; |
|
835 | + } |
|
836 | + return true; |
|
837 | + } |
|
838 | + |
|
839 | + |
|
840 | + /** |
|
841 | + * calculate spaces remaining based on "saleable" tickets |
|
842 | + * |
|
843 | + * @param array $tickets |
|
844 | + * @param bool $filtered |
|
845 | + * @return int|float |
|
846 | + * @throws EE_Error |
|
847 | + * @throws DomainException |
|
848 | + * @throws UnexpectedEntityException |
|
849 | + */ |
|
850 | + public function spaces_remaining($tickets = array(), $filtered = true) |
|
851 | + { |
|
852 | + $this->getAvailableSpacesCalculator()->setActiveTickets($tickets); |
|
853 | + $spaces_remaining = $this->getAvailableSpacesCalculator()->spacesRemaining(); |
|
854 | + return $filtered |
|
855 | + ? apply_filters( |
|
856 | + 'FHEE_EE_Event__spaces_remaining', |
|
857 | + $spaces_remaining, |
|
858 | + $this, |
|
859 | + $tickets |
|
860 | + ) |
|
861 | + : $spaces_remaining; |
|
862 | + } |
|
863 | + |
|
864 | + |
|
865 | + /** |
|
866 | + * perform_sold_out_status_check |
|
867 | + * checks all of this events's datetime reg_limit - sold values to determine if ANY datetimes have spaces |
|
868 | + * available... if NOT, then the event status will get toggled to 'sold_out' |
|
869 | + * |
|
870 | + * @return bool return the ACTUAL sold out state. |
|
871 | + * @throws EE_Error |
|
872 | + * @throws DomainException |
|
873 | + * @throws UnexpectedEntityException |
|
874 | + */ |
|
875 | + public function perform_sold_out_status_check() |
|
876 | + { |
|
877 | + // get all tickets |
|
878 | + $tickets = $this->tickets( |
|
879 | + array( |
|
880 | + 'default_where_conditions' => 'none', |
|
881 | + 'order_by' => array('TKT_qty' => 'ASC'), |
|
882 | + ) |
|
883 | + ); |
|
884 | + $all_expired = true; |
|
885 | + foreach ($tickets as $ticket) { |
|
886 | + if (! $ticket->is_expired()) { |
|
887 | + $all_expired = false; |
|
888 | + break; |
|
889 | + } |
|
890 | + } |
|
891 | + // if all the tickets are just expired, then don't update the event status to sold out |
|
892 | + if ($all_expired) { |
|
893 | + return true; |
|
894 | + } |
|
895 | + $spaces_remaining = $this->spaces_remaining($tickets); |
|
896 | + if ($spaces_remaining < 1) { |
|
897 | + if ($this->status() !== EEM_Event::post_status_private) { |
|
898 | + $this->set_status(EEM_Event::sold_out); |
|
899 | + $this->save(); |
|
900 | + } |
|
901 | + $sold_out = true; |
|
902 | + } else { |
|
903 | + $sold_out = false; |
|
904 | + // was event previously marked as sold out ? |
|
905 | + if ($this->status() === EEM_Event::sold_out) { |
|
906 | + // revert status to previous value, if it was set |
|
907 | + $previous_event_status = $this->get_post_meta('_previous_event_status', true); |
|
908 | + if ($previous_event_status) { |
|
909 | + $this->set_status($previous_event_status); |
|
910 | + $this->save(); |
|
911 | + } |
|
912 | + } |
|
913 | + } |
|
914 | + do_action('AHEE__EE_Event__perform_sold_out_status_check__end', $this, $sold_out, $spaces_remaining, $tickets); |
|
915 | + return $sold_out; |
|
916 | + } |
|
917 | + |
|
918 | + |
|
919 | + /** |
|
920 | + * This returns the total remaining spaces for sale on this event. |
|
921 | + * |
|
922 | + * @uses EE_Event::total_available_spaces() |
|
923 | + * @return float|int |
|
924 | + * @throws EE_Error |
|
925 | + * @throws DomainException |
|
926 | + * @throws UnexpectedEntityException |
|
927 | + */ |
|
928 | + public function spaces_remaining_for_sale() |
|
929 | + { |
|
930 | + return $this->total_available_spaces(true); |
|
931 | + } |
|
932 | + |
|
933 | + |
|
934 | + /** |
|
935 | + * This returns the total spaces available for an event |
|
936 | + * while considering all the qtys on the tickets and the reg limits |
|
937 | + * on the datetimes attached to this event. |
|
938 | + * |
|
939 | + * @param bool $consider_sold Whether to consider any tickets that have already sold in our calculation. |
|
940 | + * If this is false, then we return the most tickets that could ever be sold |
|
941 | + * for this event with the datetime and tickets setup on the event under optimal |
|
942 | + * selling conditions. Otherwise we return a live calculation of spaces available |
|
943 | + * based on tickets sold. Depending on setup and stage of sales, this |
|
944 | + * may appear to equal remaining tickets. However, the more tickets are |
|
945 | + * sold out, the more accurate the "live" total is. |
|
946 | + * @return float|int |
|
947 | + * @throws EE_Error |
|
948 | + * @throws DomainException |
|
949 | + * @throws UnexpectedEntityException |
|
950 | + */ |
|
951 | + public function total_available_spaces($consider_sold = false) |
|
952 | + { |
|
953 | + $spaces_available = $consider_sold |
|
954 | + ? $this->getAvailableSpacesCalculator()->spacesRemaining() |
|
955 | + : $this->getAvailableSpacesCalculator()->totalSpacesAvailable(); |
|
956 | + return apply_filters( |
|
957 | + 'FHEE_EE_Event__total_available_spaces__spaces_available', |
|
958 | + $spaces_available, |
|
959 | + $this, |
|
960 | + $this->getAvailableSpacesCalculator()->getDatetimes(), |
|
961 | + $this->getAvailableSpacesCalculator()->getActiveTickets() |
|
962 | + ); |
|
963 | + } |
|
964 | + |
|
965 | + |
|
966 | + /** |
|
967 | + * Checks if the event is set to sold out |
|
968 | + * |
|
969 | + * @param bool $actual whether or not to perform calculations to not only figure the |
|
970 | + * actual status but also to flip the status if necessary to sold |
|
971 | + * out If false, we just check the existing status of the event |
|
972 | + * @return boolean |
|
973 | + * @throws EE_Error |
|
974 | + */ |
|
975 | + public function is_sold_out($actual = false) |
|
976 | + { |
|
977 | + if (! $actual) { |
|
978 | + return $this->status() === EEM_Event::sold_out; |
|
979 | + } |
|
980 | + return $this->perform_sold_out_status_check(); |
|
981 | + } |
|
982 | + |
|
983 | + |
|
984 | + /** |
|
985 | + * Checks if the event is marked as postponed |
|
986 | + * |
|
987 | + * @return boolean |
|
988 | + */ |
|
989 | + public function is_postponed() |
|
990 | + { |
|
991 | + return $this->status() === EEM_Event::postponed; |
|
992 | + } |
|
993 | + |
|
994 | + |
|
995 | + /** |
|
996 | + * Checks if the event is marked as cancelled |
|
997 | + * |
|
998 | + * @return boolean |
|
999 | + */ |
|
1000 | + public function is_cancelled() |
|
1001 | + { |
|
1002 | + return $this->status() === EEM_Event::cancelled; |
|
1003 | + } |
|
1004 | + |
|
1005 | + |
|
1006 | + /** |
|
1007 | + * Get the logical active status in a hierarchical order for all the datetimes. Note |
|
1008 | + * Basically, we order the datetimes by EVT_start_date. Then first test on whether the event is published. If its |
|
1009 | + * NOT published then we test for whether its expired or not. IF it IS published then we test first on whether an |
|
1010 | + * event has any active dates. If no active dates then we check for any upcoming dates. If no upcoming dates then |
|
1011 | + * the event is considered expired. |
|
1012 | + * NOTE: this method does NOT calculate whether the datetimes are sold out when event is published. Sold Out is a |
|
1013 | + * status set on the EVENT when it is not published and thus is done |
|
1014 | + * |
|
1015 | + * @param bool $reset |
|
1016 | + * @return bool | string - based on EE_Datetime active constants or FALSE if error. |
|
1017 | + * @throws EE_Error |
|
1018 | + */ |
|
1019 | + public function get_active_status($reset = false) |
|
1020 | + { |
|
1021 | + // if the active status has already been set, then just use that value (unless we are resetting it) |
|
1022 | + if (! empty($this->_active_status) && ! $reset) { |
|
1023 | + return $this->_active_status; |
|
1024 | + } |
|
1025 | + // first check if event id is present on this object |
|
1026 | + if (! $this->ID()) { |
|
1027 | + return false; |
|
1028 | + } |
|
1029 | + $where_params_for_event = array(array('EVT_ID' => $this->ID())); |
|
1030 | + // if event is published: |
|
1031 | + if ($this->status() === EEM_Event::post_status_publish || $this->status() === EEM_Event::post_status_private) { |
|
1032 | + // active? |
|
1033 | + if ( |
|
1034 | + EEM_Datetime::instance()->get_datetime_count_for_status( |
|
1035 | + EE_Datetime::active, |
|
1036 | + $where_params_for_event |
|
1037 | + ) > 0 |
|
1038 | + ) { |
|
1039 | + $this->_active_status = EE_Datetime::active; |
|
1040 | + } else { |
|
1041 | + // upcoming? |
|
1042 | + if ( |
|
1043 | + EEM_Datetime::instance()->get_datetime_count_for_status( |
|
1044 | + EE_Datetime::upcoming, |
|
1045 | + $where_params_for_event |
|
1046 | + ) > 0 |
|
1047 | + ) { |
|
1048 | + $this->_active_status = EE_Datetime::upcoming; |
|
1049 | + } else { |
|
1050 | + // expired? |
|
1051 | + if ( |
|
1052 | + EEM_Datetime::instance()->get_datetime_count_for_status( |
|
1053 | + EE_Datetime::expired, |
|
1054 | + $where_params_for_event |
|
1055 | + ) > 0 |
|
1056 | + ) { |
|
1057 | + $this->_active_status = EE_Datetime::expired; |
|
1058 | + } else { |
|
1059 | + // it would be odd if things make it this far because it basically means there are no datetime's |
|
1060 | + // attached to the event. So in this case it will just be considered inactive. |
|
1061 | + $this->_active_status = EE_Datetime::inactive; |
|
1062 | + } |
|
1063 | + } |
|
1064 | + } |
|
1065 | + } else { |
|
1066 | + // the event is not published, so let's just set it's active status according to its' post status |
|
1067 | + switch ($this->status()) { |
|
1068 | + case EEM_Event::sold_out: |
|
1069 | + $this->_active_status = EE_Datetime::sold_out; |
|
1070 | + break; |
|
1071 | + case EEM_Event::cancelled: |
|
1072 | + $this->_active_status = EE_Datetime::cancelled; |
|
1073 | + break; |
|
1074 | + case EEM_Event::postponed: |
|
1075 | + $this->_active_status = EE_Datetime::postponed; |
|
1076 | + break; |
|
1077 | + default: |
|
1078 | + $this->_active_status = EE_Datetime::inactive; |
|
1079 | + } |
|
1080 | + } |
|
1081 | + return $this->_active_status; |
|
1082 | + } |
|
1083 | + |
|
1084 | + |
|
1085 | + /** |
|
1086 | + * pretty_active_status |
|
1087 | + * |
|
1088 | + * @access public |
|
1089 | + * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
|
1090 | + * @return mixed void|string |
|
1091 | + * @throws EE_Error |
|
1092 | + */ |
|
1093 | + public function pretty_active_status($echo = true) |
|
1094 | + { |
|
1095 | + $active_status = $this->get_active_status(); |
|
1096 | + $status = '<span class="ee-status event-active-status-' |
|
1097 | + . $active_status |
|
1098 | + . '">' |
|
1099 | + . EEH_Template::pretty_status($active_status, false, 'sentence') |
|
1100 | + . '</span>'; |
|
1101 | + if ($echo) { |
|
1102 | + echo $status; |
|
1103 | + return ''; |
|
1104 | + } |
|
1105 | + return $status; |
|
1106 | + } |
|
1107 | + |
|
1108 | + |
|
1109 | + /** |
|
1110 | + * @return bool|int |
|
1111 | + * @throws EE_Error |
|
1112 | + */ |
|
1113 | + public function get_number_of_tickets_sold() |
|
1114 | + { |
|
1115 | + $tkt_sold = 0; |
|
1116 | + if (! $this->ID()) { |
|
1117 | + return 0; |
|
1118 | + } |
|
1119 | + $datetimes = $this->datetimes(); |
|
1120 | + foreach ($datetimes as $datetime) { |
|
1121 | + if ($datetime instanceof EE_Datetime) { |
|
1122 | + $tkt_sold += $datetime->sold(); |
|
1123 | + } |
|
1124 | + } |
|
1125 | + return $tkt_sold; |
|
1126 | + } |
|
1127 | + |
|
1128 | + |
|
1129 | + /** |
|
1130 | + * This just returns a count of all the registrations for this event |
|
1131 | + * |
|
1132 | + * @access public |
|
1133 | + * @return int |
|
1134 | + * @throws EE_Error |
|
1135 | + */ |
|
1136 | + public function get_count_of_all_registrations() |
|
1137 | + { |
|
1138 | + return EEM_Event::instance()->count_related($this, 'Registration'); |
|
1139 | + } |
|
1140 | + |
|
1141 | + |
|
1142 | + /** |
|
1143 | + * This returns the ticket with the earliest start time that is |
|
1144 | + * available for this event (across all datetimes attached to the event) |
|
1145 | + * |
|
1146 | + * @return EE_Base_Class|EE_Ticket|null |
|
1147 | + * @throws EE_Error |
|
1148 | + */ |
|
1149 | + public function get_ticket_with_earliest_start_time() |
|
1150 | + { |
|
1151 | + $where['Datetime.EVT_ID'] = $this->ID(); |
|
1152 | + $query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC')); |
|
1153 | + return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1154 | + } |
|
1155 | + |
|
1156 | + |
|
1157 | + /** |
|
1158 | + * This returns the ticket with the latest end time that is available |
|
1159 | + * for this event (across all datetimes attached to the event) |
|
1160 | + * |
|
1161 | + * @return EE_Base_Class|EE_Ticket|null |
|
1162 | + * @throws EE_Error |
|
1163 | + */ |
|
1164 | + public function get_ticket_with_latest_end_time() |
|
1165 | + { |
|
1166 | + $where['Datetime.EVT_ID'] = $this->ID(); |
|
1167 | + $query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC')); |
|
1168 | + return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1169 | + } |
|
1170 | + |
|
1171 | + |
|
1172 | + /** |
|
1173 | + * This returns the number of different ticket types currently on sale for this event. |
|
1174 | + * |
|
1175 | + * @return int |
|
1176 | + * @throws EE_Error |
|
1177 | + */ |
|
1178 | + public function countTicketsOnSale() |
|
1179 | + { |
|
1180 | + $where = array( |
|
1181 | + 'Datetime.EVT_ID' => $this->ID(), |
|
1182 | + 'TKT_start_date' => array('<', time()), |
|
1183 | + 'TKT_end_date' => array('>', time()), |
|
1184 | + ); |
|
1185 | + return EEM_Ticket::instance()->count(array($where)); |
|
1186 | + } |
|
1187 | + |
|
1188 | + |
|
1189 | + /** |
|
1190 | + * This returns whether there are any tickets on sale for this event. |
|
1191 | + * |
|
1192 | + * @return bool true = YES tickets on sale. |
|
1193 | + * @throws EE_Error |
|
1194 | + */ |
|
1195 | + public function tickets_on_sale() |
|
1196 | + { |
|
1197 | + return $this->countTicketsOnSale() > 0; |
|
1198 | + } |
|
1199 | + |
|
1200 | + |
|
1201 | + /** |
|
1202 | + * Gets the URL for viewing this event on the front-end. Overrides parent |
|
1203 | + * to check for an external URL first |
|
1204 | + * |
|
1205 | + * @return string |
|
1206 | + * @throws EE_Error |
|
1207 | + */ |
|
1208 | + public function get_permalink() |
|
1209 | + { |
|
1210 | + if ($this->external_url()) { |
|
1211 | + return $this->external_url(); |
|
1212 | + } |
|
1213 | + return parent::get_permalink(); |
|
1214 | + } |
|
1215 | + |
|
1216 | + |
|
1217 | + /** |
|
1218 | + * Gets the first term for 'espresso_event_categories' we can find |
|
1219 | + * |
|
1220 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1221 | + * @return EE_Base_Class|EE_Term|null |
|
1222 | + * @throws EE_Error |
|
1223 | + */ |
|
1224 | + public function first_event_category($query_params = array()) |
|
1225 | + { |
|
1226 | + $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1227 | + $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1228 | + return EEM_Term::instance()->get_one($query_params); |
|
1229 | + } |
|
1230 | + |
|
1231 | + |
|
1232 | + /** |
|
1233 | + * Gets all terms for 'espresso_event_categories' we can find |
|
1234 | + * |
|
1235 | + * @param array $query_params |
|
1236 | + * @return EE_Base_Class[]|EE_Term[] |
|
1237 | + * @throws EE_Error |
|
1238 | + */ |
|
1239 | + public function get_all_event_categories($query_params = array()) |
|
1240 | + { |
|
1241 | + $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1242 | + $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1243 | + return EEM_Term::instance()->get_all($query_params); |
|
1244 | + } |
|
1245 | + |
|
1246 | + |
|
1247 | + /** |
|
1248 | + * Adds a question group to this event |
|
1249 | + * |
|
1250 | + * @param EE_Question_Group|int $question_group_id_or_obj |
|
1251 | + * @param bool $for_primary if true, the question group will be added for the primary |
|
1252 | + * registrant, if false will be added for others. default: false |
|
1253 | + * @return EE_Base_Class|EE_Question_Group |
|
1254 | + * @throws EE_Error |
|
1255 | + * @throws InvalidArgumentException |
|
1256 | + * @throws InvalidDataTypeException |
|
1257 | + * @throws InvalidInterfaceException |
|
1258 | + * @throws ReflectionException |
|
1259 | + */ |
|
1260 | + public function add_question_group($question_group_id_or_obj, $for_primary = false) |
|
1261 | + { |
|
1262 | + // If the row already exists, it will be updated. If it doesn't, it will be inserted. |
|
1263 | + // That's in EE_HABTM_Relation::add_relation_to(). |
|
1264 | + return $this->_add_relation_to( |
|
1265 | + $question_group_id_or_obj, |
|
1266 | + 'Question_Group', |
|
1267 | + [ |
|
1268 | + EEM_Event_Question_Group::instance()->fieldNameForContext($for_primary) => true |
|
1269 | + ] |
|
1270 | + ); |
|
1271 | + } |
|
1272 | + |
|
1273 | + |
|
1274 | + /** |
|
1275 | + * Removes a question group from the event |
|
1276 | + * |
|
1277 | + * @param EE_Question_Group|int $question_group_id_or_obj |
|
1278 | + * @param bool $for_primary if true, the question group will be removed from the primary |
|
1279 | + * registrant, if false will be removed from others. default: false |
|
1280 | + * @return EE_Base_Class|EE_Question_Group |
|
1281 | + * @throws EE_Error |
|
1282 | + * @throws InvalidArgumentException |
|
1283 | + * @throws ReflectionException |
|
1284 | + * @throws InvalidDataTypeException |
|
1285 | + * @throws InvalidInterfaceException |
|
1286 | + */ |
|
1287 | + public function remove_question_group($question_group_id_or_obj, $for_primary = false) |
|
1288 | + { |
|
1289 | + // If the question group is used for the other type (primary or additional) |
|
1290 | + // then just update it. If not, delete it outright. |
|
1291 | + $existing_relation = $this->get_first_related( |
|
1292 | + 'Event_Question_Group', |
|
1293 | + [ |
|
1294 | + [ |
|
1295 | + 'QSG_ID' => EEM_Question_Group::instance()->ensure_is_ID($question_group_id_or_obj) |
|
1296 | + ] |
|
1297 | + ] |
|
1298 | + ); |
|
1299 | + $field_to_update = EEM_Event_Question_Group::instance()->fieldNameForContext($for_primary); |
|
1300 | + $other_field = EEM_Event_Question_Group::instance()->fieldNameForContext(! $for_primary); |
|
1301 | + if ($existing_relation->get($other_field) === false) { |
|
1302 | + // Delete it. It's now no longer for primary or additional question groups. |
|
1303 | + return $this->_remove_relation_to($question_group_id_or_obj, 'Question_Group'); |
|
1304 | + } |
|
1305 | + // Just update it. They'll still use this question group for the other category |
|
1306 | + $existing_relation->save( |
|
1307 | + [ |
|
1308 | + $field_to_update => false |
|
1309 | + ] |
|
1310 | + ); |
|
1311 | + } |
|
1312 | + |
|
1313 | + |
|
1314 | + /** |
|
1315 | + * Gets all the question groups, ordering them by QSG_order ascending |
|
1316 | + * |
|
1317 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1318 | + * @return EE_Base_Class[]|EE_Question_Group[] |
|
1319 | + * @throws EE_Error |
|
1320 | + */ |
|
1321 | + public function question_groups($query_params = array()) |
|
1322 | + { |
|
1323 | + $query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC')); |
|
1324 | + return $this->get_many_related('Question_Group', $query_params); |
|
1325 | + } |
|
1326 | + |
|
1327 | + |
|
1328 | + /** |
|
1329 | + * Implementation for EEI_Has_Icon interface method. |
|
1330 | + * |
|
1331 | + * @see EEI_Visual_Representation for comments |
|
1332 | + * @return string |
|
1333 | + */ |
|
1334 | + public function get_icon() |
|
1335 | + { |
|
1336 | + return '<span class="dashicons dashicons-flag"></span>'; |
|
1337 | + } |
|
1338 | + |
|
1339 | + |
|
1340 | + /** |
|
1341 | + * Implementation for EEI_Admin_Links interface method. |
|
1342 | + * |
|
1343 | + * @see EEI_Admin_Links for comments |
|
1344 | + * @return string |
|
1345 | + * @throws EE_Error |
|
1346 | + */ |
|
1347 | + public function get_admin_details_link() |
|
1348 | + { |
|
1349 | + return $this->get_admin_edit_link(); |
|
1350 | + } |
|
1351 | + |
|
1352 | + |
|
1353 | + /** |
|
1354 | + * Implementation for EEI_Admin_Links interface method. |
|
1355 | + * |
|
1356 | + * @see EEI_Admin_Links for comments |
|
1357 | + * @return string |
|
1358 | + * @throws EE_Error |
|
1359 | + */ |
|
1360 | + public function get_admin_edit_link() |
|
1361 | + { |
|
1362 | + return EEH_URL::add_query_args_and_nonce( |
|
1363 | + array( |
|
1364 | + 'page' => 'espresso_events', |
|
1365 | + 'action' => 'edit', |
|
1366 | + 'post' => $this->ID(), |
|
1367 | + ), |
|
1368 | + admin_url('admin.php') |
|
1369 | + ); |
|
1370 | + } |
|
1371 | + |
|
1372 | + |
|
1373 | + /** |
|
1374 | + * Implementation for EEI_Admin_Links interface method. |
|
1375 | + * |
|
1376 | + * @see EEI_Admin_Links for comments |
|
1377 | + * @return string |
|
1378 | + */ |
|
1379 | + public function get_admin_settings_link() |
|
1380 | + { |
|
1381 | + return EEH_URL::add_query_args_and_nonce( |
|
1382 | + array( |
|
1383 | + 'page' => 'espresso_events', |
|
1384 | + 'action' => 'default_event_settings', |
|
1385 | + ), |
|
1386 | + admin_url('admin.php') |
|
1387 | + ); |
|
1388 | + } |
|
1389 | + |
|
1390 | + |
|
1391 | + /** |
|
1392 | + * Implementation for EEI_Admin_Links interface method. |
|
1393 | + * |
|
1394 | + * @see EEI_Admin_Links for comments |
|
1395 | + * @return string |
|
1396 | + */ |
|
1397 | + public function get_admin_overview_link() |
|
1398 | + { |
|
1399 | + return EEH_URL::add_query_args_and_nonce( |
|
1400 | + array( |
|
1401 | + 'page' => 'espresso_events', |
|
1402 | + 'action' => 'default', |
|
1403 | + ), |
|
1404 | + admin_url('admin.php') |
|
1405 | + ); |
|
1406 | + } |
|
1407 | 1407 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * Sets FK_ID |
47 | 47 | * |
48 | 48 | * @param int $FK_ID |
49 | - * @return boolean |
|
49 | + * @return boolean|null |
|
50 | 50 | */ |
51 | 51 | public function set_FK_ID($FK_ID) |
52 | 52 | { |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * Sets model |
70 | 70 | * |
71 | 71 | * @param string $model |
72 | - * @return boolean |
|
72 | + * @return boolean|null |
|
73 | 73 | */ |
74 | 74 | public function set_model($model) |
75 | 75 | { |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * Sets key |
93 | 93 | * |
94 | 94 | * @param string $key |
95 | - * @return boolean |
|
95 | + * @return boolean|null |
|
96 | 96 | */ |
97 | 97 | public function set_key($key) |
98 | 98 | { |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * Sets value |
116 | 116 | * |
117 | 117 | * @param string $value |
118 | - * @return boolean |
|
118 | + * @return boolean|null |
|
119 | 119 | */ |
120 | 120 | public function set_value($value) |
121 | 121 | { |
@@ -10,115 +10,115 @@ |
||
10 | 10 | class EE_Extra_Meta extends EE_Base_Class |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @param array $props_n_values |
|
15 | - * @return EE_Extra_Meta|mixed |
|
16 | - */ |
|
17 | - public static function new_instance($props_n_values = array()) |
|
18 | - { |
|
19 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
20 | - return $has_object ? $has_object : new self($props_n_values); |
|
21 | - } |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * @param array $props_n_values |
|
26 | - * @return EE_Extra_Meta |
|
27 | - */ |
|
28 | - public static function new_instance_from_db($props_n_values = array()) |
|
29 | - { |
|
30 | - return new self($props_n_values, true); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Gets FK_ID |
|
36 | - * |
|
37 | - * @return int |
|
38 | - */ |
|
39 | - public function FK_ID() |
|
40 | - { |
|
41 | - return $this->get('FK_ID'); |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * Sets FK_ID |
|
47 | - * |
|
48 | - * @param int $FK_ID |
|
49 | - * @return boolean |
|
50 | - */ |
|
51 | - public function set_FK_ID($FK_ID) |
|
52 | - { |
|
53 | - $this->set('FK_ID', $FK_ID); |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * Gets model |
|
59 | - * |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function model() |
|
63 | - { |
|
64 | - return $this->get('EXM_model'); |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * Sets model |
|
70 | - * |
|
71 | - * @param string $model |
|
72 | - * @return boolean |
|
73 | - */ |
|
74 | - public function set_model($model) |
|
75 | - { |
|
76 | - $this->set('EXM_model', $model); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * Gets key |
|
82 | - * |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function key() |
|
86 | - { |
|
87 | - return $this->get('EXM_key'); |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * Sets key |
|
93 | - * |
|
94 | - * @param string $key |
|
95 | - * @return boolean |
|
96 | - */ |
|
97 | - public function set_key($key) |
|
98 | - { |
|
99 | - $this->set('EXM_key', $key); |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * Gets value |
|
105 | - * |
|
106 | - * @return string |
|
107 | - */ |
|
108 | - public function value() |
|
109 | - { |
|
110 | - return $this->get('EXM_value'); |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * Sets value |
|
116 | - * |
|
117 | - * @param string $value |
|
118 | - * @return boolean |
|
119 | - */ |
|
120 | - public function set_value($value) |
|
121 | - { |
|
122 | - $this->set('EXM_value', $value); |
|
123 | - } |
|
13 | + /** |
|
14 | + * @param array $props_n_values |
|
15 | + * @return EE_Extra_Meta|mixed |
|
16 | + */ |
|
17 | + public static function new_instance($props_n_values = array()) |
|
18 | + { |
|
19 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
20 | + return $has_object ? $has_object : new self($props_n_values); |
|
21 | + } |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * @param array $props_n_values |
|
26 | + * @return EE_Extra_Meta |
|
27 | + */ |
|
28 | + public static function new_instance_from_db($props_n_values = array()) |
|
29 | + { |
|
30 | + return new self($props_n_values, true); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Gets FK_ID |
|
36 | + * |
|
37 | + * @return int |
|
38 | + */ |
|
39 | + public function FK_ID() |
|
40 | + { |
|
41 | + return $this->get('FK_ID'); |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * Sets FK_ID |
|
47 | + * |
|
48 | + * @param int $FK_ID |
|
49 | + * @return boolean |
|
50 | + */ |
|
51 | + public function set_FK_ID($FK_ID) |
|
52 | + { |
|
53 | + $this->set('FK_ID', $FK_ID); |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * Gets model |
|
59 | + * |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function model() |
|
63 | + { |
|
64 | + return $this->get('EXM_model'); |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * Sets model |
|
70 | + * |
|
71 | + * @param string $model |
|
72 | + * @return boolean |
|
73 | + */ |
|
74 | + public function set_model($model) |
|
75 | + { |
|
76 | + $this->set('EXM_model', $model); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * Gets key |
|
82 | + * |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function key() |
|
86 | + { |
|
87 | + return $this->get('EXM_key'); |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * Sets key |
|
93 | + * |
|
94 | + * @param string $key |
|
95 | + * @return boolean |
|
96 | + */ |
|
97 | + public function set_key($key) |
|
98 | + { |
|
99 | + $this->set('EXM_key', $key); |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * Gets value |
|
105 | + * |
|
106 | + * @return string |
|
107 | + */ |
|
108 | + public function value() |
|
109 | + { |
|
110 | + return $this->get('EXM_value'); |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * Sets value |
|
116 | + * |
|
117 | + * @param string $value |
|
118 | + * @return boolean |
|
119 | + */ |
|
120 | + public function set_value($value) |
|
121 | + { |
|
122 | + $this->set('EXM_value', $value); |
|
123 | + } |
|
124 | 124 | } |