@@ -125,14 +125,14 @@ |
||
125 | 125 | public function get_attendee_property_answer_value( EE_Registration $registration, $question_system_id = NULL, $pretty_answer = FALSE ){ |
126 | 126 | $field_name = NULL; |
127 | 127 | $value = NULL; |
128 | - //backward compat: we still want to find the question's ID |
|
129 | - if( is_numeric( $question_system_id ) ) { |
|
130 | - //find this question's QST_system value |
|
131 | - $question_id = $question_system_id; |
|
132 | - $question_system_id = EEM_Question::instance()->get_var( array( array( 'QST_ID' => $question_system_id ) ), 'QST_system' ); |
|
133 | - } else { |
|
134 | - $question_id = intval( EEM_Question::instance()->get_var( array( array( 'QST_system' => $question_system_id ) ), 'QST_ID' ) ); |
|
135 | - } |
|
128 | + //backward compat: we still want to find the question's ID |
|
129 | + if( is_numeric( $question_system_id ) ) { |
|
130 | + //find this question's QST_system value |
|
131 | + $question_id = $question_system_id; |
|
132 | + $question_system_id = EEM_Question::instance()->get_var( array( array( 'QST_ID' => $question_system_id ) ), 'QST_system' ); |
|
133 | + } else { |
|
134 | + $question_id = intval( EEM_Question::instance()->get_var( array( array( 'QST_system' => $question_system_id ) ), 'QST_ID' ) ); |
|
135 | + } |
|
136 | 136 | //only bother checking if the registration has an attendee |
137 | 137 | if( $registration->attendee() instanceof EE_Attendee ) { |
138 | 138 | $field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question( $question_system_id ); |
@@ -51,18 +51,18 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * constructor |
53 | 53 | */ |
54 | - protected function __construct( $timezone = NULL ){ |
|
55 | - $this->singular_item = __('Answer','event_espresso'); |
|
56 | - $this->plural_item = __('Answers','event_espresso'); |
|
54 | + protected function __construct($timezone = NULL) { |
|
55 | + $this->singular_item = __('Answer', 'event_espresso'); |
|
56 | + $this->plural_item = __('Answers', 'event_espresso'); |
|
57 | 57 | $this->_tables = array( |
58 | 58 | 'Answer'=> new EE_Primary_Table('esp_answer', 'ANS_ID') |
59 | 59 | ); |
60 | 60 | $this->_fields = array( |
61 | 61 | 'Answer'=>array( |
62 | - 'ANS_ID'=> new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID','event_espresso')), |
|
63 | - 'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID','event_espresso'), false, 0, 'Registration'), |
|
64 | - 'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID','event_espresso'), false, 0, 'Question'), |
|
65 | - 'ANS_value'=>new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value','event_espresso'), false, '') |
|
62 | + 'ANS_ID'=> new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID', 'event_espresso')), |
|
63 | + 'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'), |
|
64 | + 'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'), |
|
65 | + 'ANS_value'=>new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value', 'event_espresso'), false, '') |
|
66 | 66 | )); |
67 | 67 | $this->_model_relations = array( |
68 | 68 | 'Registration'=>new EE_Belongs_To_Relation(), |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | ); |
71 | 71 | $this->_model_chain_to_wp_user = 'Registration.Event'; |
72 | 72 | $this->_caps_slug = 'registrations'; |
73 | - parent::__construct( $timezone ); |
|
73 | + parent::__construct($timezone); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -83,19 +83,19 @@ discard block |
||
83 | 83 | * @param boolean $pretty_answer whether to call 'pretty_value' or just 'value' |
84 | 84 | * @return string |
85 | 85 | */ |
86 | - public function get_answer_value_to_question( EE_Registration $registration, $question_id = NULL,$pretty_answer = FALSE ){ |
|
87 | - $value = $this->get_attendee_property_answer_value( $registration, $question_id, $pretty_answer ); |
|
88 | - if ( $value === NULL ){ |
|
89 | - $answer_obj = $this->get_registration_question_answer_object( $registration, $question_id, $pretty_answer ); |
|
90 | - if( $answer_obj instanceof EE_Answer ){ |
|
91 | - if($pretty_answer){ |
|
86 | + public function get_answer_value_to_question(EE_Registration $registration, $question_id = NULL, $pretty_answer = FALSE) { |
|
87 | + $value = $this->get_attendee_property_answer_value($registration, $question_id, $pretty_answer); |
|
88 | + if ($value === NULL) { |
|
89 | + $answer_obj = $this->get_registration_question_answer_object($registration, $question_id, $pretty_answer); |
|
90 | + if ($answer_obj instanceof EE_Answer) { |
|
91 | + if ($pretty_answer) { |
|
92 | 92 | $value = $answer_obj->pretty_value(); |
93 | - }else{ |
|
93 | + } else { |
|
94 | 94 | $value = $answer_obj->value(); |
95 | 95 | } |
96 | 96 | } |
97 | 97 | } |
98 | - return apply_filters( 'FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id ); |
|
98 | + return apply_filters('FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | * @param int $question_id |
107 | 107 | * @return EE_Answer |
108 | 108 | */ |
109 | - public function get_registration_question_answer_object( EE_Registration $registration, $question_id = NULL){ |
|
110 | - $answer_obj = $this->get_one( array( array( 'QST_ID'=>$question_id, 'REG_ID'=>$registration->ID() ))); |
|
111 | - return apply_filters( 'FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id ); |
|
109 | + public function get_registration_question_answer_object(EE_Registration $registration, $question_id = NULL) { |
|
110 | + $answer_obj = $this->get_one(array(array('QST_ID'=>$question_id, 'REG_ID'=>$registration->ID()))); |
|
111 | + return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
@@ -122,39 +122,39 @@ discard block |
||
122 | 122 | * @return string|null (if the registration has no attendee, or the question_system_id is not a QST_ID or QST_system for |
123 | 123 | * a question corresponding to an attendee field, returns null) |
124 | 124 | */ |
125 | - public function get_attendee_property_answer_value( EE_Registration $registration, $question_system_id = NULL, $pretty_answer = FALSE ){ |
|
125 | + public function get_attendee_property_answer_value(EE_Registration $registration, $question_system_id = NULL, $pretty_answer = FALSE) { |
|
126 | 126 | $field_name = NULL; |
127 | 127 | $value = NULL; |
128 | 128 | //backward compat: we still want to find the question's ID |
129 | - if( is_numeric( $question_system_id ) ) { |
|
129 | + if (is_numeric($question_system_id)) { |
|
130 | 130 | //find this question's QST_system value |
131 | 131 | $question_id = $question_system_id; |
132 | - $question_system_id = EEM_Question::instance()->get_var( array( array( 'QST_ID' => $question_system_id ) ), 'QST_system' ); |
|
132 | + $question_system_id = EEM_Question::instance()->get_var(array(array('QST_ID' => $question_system_id)), 'QST_system'); |
|
133 | 133 | } else { |
134 | - $question_id = intval( EEM_Question::instance()->get_var( array( array( 'QST_system' => $question_system_id ) ), 'QST_ID' ) ); |
|
134 | + $question_id = intval(EEM_Question::instance()->get_var(array(array('QST_system' => $question_system_id)), 'QST_ID')); |
|
135 | 135 | } |
136 | 136 | //only bother checking if the registration has an attendee |
137 | - if( $registration->attendee() instanceof EE_Attendee ) { |
|
138 | - $field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question( $question_system_id ); |
|
139 | - if( $field_name ) { |
|
140 | - if( $pretty_answer ) { |
|
141 | - if( $field_name == 'STA_ID' ) { |
|
137 | + if ($registration->attendee() instanceof EE_Attendee) { |
|
138 | + $field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question($question_system_id); |
|
139 | + if ($field_name) { |
|
140 | + if ($pretty_answer) { |
|
141 | + if ($field_name == 'STA_ID') { |
|
142 | 142 | $state = $registration->attendee()->state_obj(); |
143 | - $value = $state instanceof EE_State ? $state->name() : sprintf( __('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID() ); |
|
144 | - } else if($field_name == 'CNT_ISO') { |
|
143 | + $value = $state instanceof EE_State ? $state->name() : sprintf(__('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID()); |
|
144 | + } else if ($field_name == 'CNT_ISO') { |
|
145 | 145 | $country = $registration->attendee()->country_obj(); |
146 | - $value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"),$registration->attendee()->country_ID()); |
|
146 | + $value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"), $registration->attendee()->country_ID()); |
|
147 | 147 | } else { |
148 | - $value = $registration->attendee()->get_pretty( $field_name ); |
|
148 | + $value = $registration->attendee()->get_pretty($field_name); |
|
149 | 149 | } |
150 | 150 | //if field name is blank, leave the value as null too |
151 | - }else{ |
|
152 | - $value = $registration->attendee()->get( $field_name ); |
|
151 | + } else { |
|
152 | + $value = $registration->attendee()->get($field_name); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | //if no field was found, leave value blank |
156 | 156 | } |
157 | - return apply_filters( 'FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id ); |
|
157 | + return apply_filters('FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -90,7 +92,7 @@ discard block |
||
90 | 92 | if( $answer_obj instanceof EE_Answer ){ |
91 | 93 | if($pretty_answer){ |
92 | 94 | $value = $answer_obj->pretty_value(); |
93 | - }else{ |
|
95 | + } else{ |
|
94 | 96 | $value = $answer_obj->value(); |
95 | 97 | } |
96 | 98 | } |
@@ -148,7 +150,7 @@ discard block |
||
148 | 150 | $value = $registration->attendee()->get_pretty( $field_name ); |
149 | 151 | } |
150 | 152 | //if field name is blank, leave the value as null too |
151 | - }else{ |
|
153 | + } else{ |
|
152 | 154 | $value = $registration->attendee()->get( $field_name ); |
153 | 155 | } |
154 | 156 | } |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_Ticket.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Ticket.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Ticket extends EEM_Soft_Delete_Base { |
28 | 28 | |
@@ -35,35 +35,35 @@ discard block |
||
35 | 35 | * @access private |
36 | 36 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
37 | 37 | */ |
38 | - protected function __construct( $timezone ) { |
|
39 | - $this->singular_item = __('Ticket','event_espresso'); |
|
40 | - $this->plural_item = __('Tickets','event_espresso'); |
|
38 | + protected function __construct($timezone) { |
|
39 | + $this->singular_item = __('Ticket', 'event_espresso'); |
|
40 | + $this->plural_item = __('Tickets', 'event_espresso'); |
|
41 | 41 | |
42 | 42 | $this->_tables = array( |
43 | 43 | 'Ticket'=> new EE_Primary_Table('esp_ticket', 'TKT_ID') |
44 | 44 | ); |
45 | 45 | $this->_fields = array( |
46 | 46 | 'Ticket'=>array( |
47 | - 'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso')), |
|
48 | - 'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID','event_espresso'), false, 0, 'Ticket_Template'), |
|
47 | + 'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso')), |
|
48 | + 'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID', 'event_espresso'), false, 0, 'Ticket_Template'), |
|
49 | 49 | 'TKT_name'=>new EE_Plain_Text_Field('TKT_name', __('Ticket Name', 'event_espresso'), false, ''), |
50 | - 'TKT_description'=>new EE_Post_Content_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, '' ), |
|
51 | - 'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket','event_espresso'), false, time(), $timezone ), |
|
52 | - 'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket','event_espresso'), false, time(), $timezone ), |
|
53 | - 'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0 ), |
|
54 | - 'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, EE_INF ), |
|
50 | + 'TKT_description'=>new EE_Post_Content_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, ''), |
|
51 | + 'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket', 'event_espresso'), false, time(), $timezone), |
|
52 | + 'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket', 'event_espresso'), false, time(), $timezone), |
|
53 | + 'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0), |
|
54 | + 'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, EE_INF), |
|
55 | 55 | 'TKT_price'=> new EE_Money_Field('TKT_price', 'Final calculated price for ticket', false, 0), |
56 | 56 | 'TKT_sold' => new EE_Integer_Field('TKT_sold', __('Number of this ticket sold', 'event_espresso'), false, 0), |
57 | - 'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available','event_espresso'), false, EE_INF), |
|
58 | - 'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, EE_INF ), |
|
59 | - 'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false ), |
|
60 | - 'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false,false), |
|
61 | - 'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false ), |
|
57 | + 'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available', 'event_espresso'), false, EE_INF), |
|
58 | + 'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, EE_INF), |
|
59 | + 'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false), |
|
60 | + 'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false, false), |
|
61 | + 'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false), |
|
62 | 62 | 'TKT_order' => new EE_Integer_Field('TKT_order', __('The order in which the Ticket is displayed in the editor (used for autosaves when the form doesn\'t have the ticket ID yet)', 'event_espresso'), false, 0), |
63 | - 'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0 ), |
|
63 | + 'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0), |
|
64 | 64 | 'TKT_deleted' => new EE_Trashed_Flag_Field('TKT_deleted', __('Flag indicating if this has been archived or not', 'event_espresso'), false, false), |
65 | - 'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE ), |
|
66 | - 'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0 ) |
|
65 | + 'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE), |
|
66 | + 'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0) |
|
67 | 67 | )); |
68 | 68 | $this->_model_relations = array( |
69 | 69 | 'Datetime'=>new EE_HABTM_Relation('Datetime_Ticket'), |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | ); |
76 | 76 | |
77 | 77 | //this model is generally available for reading |
78 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('TKT_is_default', 'Datetime.Event'); |
|
78 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public('TKT_is_default', 'Datetime.Event'); |
|
79 | 79 | //account for default tickets in the caps |
80 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
81 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
82 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
83 | - parent::__construct( $timezone ); |
|
80 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
81 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
82 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
83 | + parent::__construct($timezone); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function get_all_default_tickets() { |
93 | 93 | /** @type EE_Ticket[] $tickets */ |
94 | - $tickets = $this->get_all( array( array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC')) ); |
|
94 | + $tickets = $this->get_all(array(array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC'))); |
|
95 | 95 | //we need to set the start date and end date to today's date and the start of the default dtt |
96 | - return $this->_set_default_dates( $tickets ); |
|
96 | + return $this->_set_default_dates($tickets); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | * @param EE_Ticket[] $tickets |
104 | 104 | * @return EE_Ticket[] |
105 | 105 | */ |
106 | - private function _set_default_dates( $tickets ) { |
|
107 | - foreach ( $tickets as $ticket ) { |
|
108 | - $ticket->set('TKT_start_date', $this->current_time_for_query('TKT_start_date', true) ); |
|
109 | - $ticket->set('TKT_end_date', $this->current_time_for_query( 'TKT_end_date', true ) + (60 * 60 * 24 * 30 ) ); |
|
110 | - $ticket->set_end_time( $this->convert_datetime_for_query( 'TKT_end_date', '11:59 pm', 'g:i a', $this->_timezone ) ); |
|
106 | + private function _set_default_dates($tickets) { |
|
107 | + foreach ($tickets as $ticket) { |
|
108 | + $ticket->set('TKT_start_date', $this->current_time_for_query('TKT_start_date', true)); |
|
109 | + $ticket->set('TKT_end_date', $this->current_time_for_query('TKT_end_date', true) + (60 * 60 * 24 * 30)); |
|
110 | + $ticket->set_end_time($this->convert_datetime_for_query('TKT_end_date', '11:59 pm', 'g:i a', $this->_timezone)); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return $tickets; |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @param array $query_params |
123 | 123 | * @return int |
124 | 124 | */ |
125 | - public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()){ |
|
126 | - return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params ); |
|
125 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) { |
|
126 | + return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime($DTT_ID, $query_params); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | * @param EE_Ticket[] $tickets |
134 | 134 | * @return void |
135 | 135 | */ |
136 | - public function update_tickets_sold($tickets){ |
|
137 | - foreach($tickets as $ticket){ |
|
136 | + public function update_tickets_sold($tickets) { |
|
137 | + foreach ($tickets as $ticket) { |
|
138 | 138 | /* @var $ticket EE_Ticket */ |
139 | 139 | $ticket->update_tickets_sold(); |
140 | 140 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' ); |
|
2 | +require_once(EE_MODELS.'fields/EE_Text_Field_Base.php'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Class EE_Enum_Text_Field |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param mixed $default_value |
24 | 24 | * @param array $allowed_enum_values keys are values to be used in the DB, values are how they should be displayed |
25 | 25 | */ |
26 | - function __construct($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values){ |
|
26 | + function __construct($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values) { |
|
27 | 27 | $this->_allowed_enum_values = $allowed_enum_values; |
28 | 28 | parent::__construct($table_column, $nice_name, $nullable, $default_value); |
29 | 29 | } |
@@ -37,24 +37,24 @@ discard block |
||
37 | 37 | * @return string |
38 | 38 | * @throws EE_Error |
39 | 39 | */ |
40 | - function prepare_for_set( $value_inputted_for_field_on_model_object ) { |
|
41 | - if( |
|
40 | + function prepare_for_set($value_inputted_for_field_on_model_object) { |
|
41 | + if ( |
|
42 | 42 | $value_inputted_for_field_on_model_object !== null |
43 | - && ! array_key_exists( $value_inputted_for_field_on_model_object, $this->_allowed_enum_values ) |
|
44 | - ){ |
|
45 | - if( defined( 'WP_DEBUG' ) && WP_DEBUG ){ |
|
43 | + && ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values) |
|
44 | + ) { |
|
45 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
46 | 46 | $msg = sprintf( |
47 | - __('System is assigning incompatible value "%1$s" to field "%2$s"','event_espresso'), |
|
47 | + __('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'), |
|
48 | 48 | $value_inputted_for_field_on_model_object, |
49 | 49 | $this->_name |
50 | 50 | ); |
51 | 51 | $msg2 = sprintf( |
52 | - __('Allowed values for "%1$s" are "%2$s". You provided: "%3$s"','event_espresso'), |
|
52 | + __('Allowed values for "%1$s" are "%2$s". You provided: "%3$s"', 'event_espresso'), |
|
53 | 53 | $this->_name, |
54 | - implode( ", ", array_keys( $this->_allowed_enum_values ) ), |
|
54 | + implode(", ", array_keys($this->_allowed_enum_values)), |
|
55 | 55 | $value_inputted_for_field_on_model_object |
56 | 56 | ); |
57 | - EE_Error::add_error( "$msg||$msg2", __FILE__, __FUNCTION__, __LINE__ ); |
|
57 | + EE_Error::add_error("$msg||$msg2", __FILE__, __FUNCTION__, __LINE__); |
|
58 | 58 | } |
59 | 59 | return $this->get_default_value(); |
60 | 60 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * with the exception of a particular attribute |
27 | 27 | * @return object of the same class as what was called on |
28 | 28 | */ |
29 | - public function duplicate( $options = array() ); |
|
29 | + public function duplicate($options = array()); |
|
30 | 30 | |
31 | 31 | |
32 | 32 |
@@ -7,13 +7,13 @@ |
||
7 | 7 | <!-- Facebook sharing information tags --> |
8 | 8 | <meta property="og:title" content="<?php echo $subject; ?>" /> |
9 | 9 | <title><?php echo $subject; ?></title> |
10 | - <?php do_action( 'AHEE__EE_Email_Messenger_main_wrapper_template_head', $message_type, $subject, $from, $main_body ); ?> |
|
10 | + <?php do_action('AHEE__EE_Email_Messenger_main_wrapper_template_head', $message_type, $subject, $from, $main_body); ?> |
|
11 | 11 | </head> |
12 | -<?php do_action( 'AHEE__EE_Email_Messenger_main_wrapper_template_header', $message_type, $subject, $from, $main_body ); ?> |
|
12 | +<?php do_action('AHEE__EE_Email_Messenger_main_wrapper_template_header', $message_type, $subject, $from, $main_body); ?> |
|
13 | 13 | <body bgcolor="#FFFFFF" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0"> |
14 | -<?php do_action( 'AHEE__EE_Email_Messenger_main_wrapper_template_before_main_body', $message_type, $subject, $from, $main_body ); ?> |
|
14 | +<?php do_action('AHEE__EE_Email_Messenger_main_wrapper_template_before_main_body', $message_type, $subject, $from, $main_body); ?> |
|
15 | 15 | <?php echo $main_body; ?> |
16 | -<?php do_action( 'AHEE__EE_Email_Messenger_main_wrapper_template_after_main_body', $message_type, $subject, $from, $main_body ); ?> |
|
16 | +<?php do_action('AHEE__EE_Email_Messenger_main_wrapper_template_after_main_body', $message_type, $subject, $from, $main_body); ?> |
|
17 | 17 | </body> |
18 | -<?php do_action( 'AHEE__EE_Email_Messenger_main_wrapper_template_footer', $message_type, $subject, $from, $main_body ); ?> |
|
18 | +<?php do_action('AHEE__EE_Email_Messenger_main_wrapper_template_footer', $message_type, $subject, $from, $main_body); ?> |
|
19 | 19 | </html> |
20 | 20 | \ No newline at end of file |
@@ -27,21 +27,21 @@ |
||
27 | 27 | <!-- Primary Style Sheet --> |
28 | 28 | <link rel="stylesheet" type="text/css" href="<?php echo $main_css; ?>" /> |
29 | 29 | <!-- Make sure the buttons don't print --> |
30 | - <?php if ( isset( $extra_css )) : ?> |
|
30 | + <?php if (isset($extra_css)) : ?> |
|
31 | 31 | <!-- Additional Style Sheet --> |
32 | 32 | <link rel="stylesheet" type="text/css" href="<?php echo $extra_css; ?>" /> |
33 | 33 | <?php endif; ?> |
34 | 34 | <style type="text/css"> |
35 | 35 | @media print{ .noPrint{ display:none !important;height:0!important; width:0!important; margin:0!important; padding:0!important; }} |
36 | 36 | </style> |
37 | - <?php do_action( 'AHEE__EE_Html_Messenger_main_wrapper_template_head', $message_type, $page_title, $base_css, $print_css, $main_css, $main_body); ?> |
|
37 | + <?php do_action('AHEE__EE_Html_Messenger_main_wrapper_template_head', $message_type, $page_title, $base_css, $print_css, $main_css, $main_body); ?> |
|
38 | 38 | </head> |
39 | - <?php do_action( 'AHEE__EE_Html_Messenger_main_wrapper_template_header', $message_type, $page_title, $base_css, $print_css, $main_css, $main_body); ?> |
|
39 | + <?php do_action('AHEE__EE_Html_Messenger_main_wrapper_template_header', $message_type, $page_title, $base_css, $print_css, $main_css, $main_body); ?> |
|
40 | 40 | <body> |
41 | - <?php do_action( 'AHEE__EE_Html_Messenger_main_wrapper_template_before_main_body', $message_type, $page_title, $base_css, $print_css, $main_css, $main_body); ?> |
|
41 | + <?php do_action('AHEE__EE_Html_Messenger_main_wrapper_template_before_main_body', $message_type, $page_title, $base_css, $print_css, $main_css, $main_body); ?> |
|
42 | 42 | <?php echo $main_body; ?> |
43 | - <?php do_action( 'AHEE__EE_Html_Messenger_main_wrapper_template_after_main_body', $message_type, $page_title, $base_css, $print_css, $main_css, $main_body); ?> |
|
43 | + <?php do_action('AHEE__EE_Html_Messenger_main_wrapper_template_after_main_body', $message_type, $page_title, $base_css, $print_css, $main_css, $main_body); ?> |
|
44 | 44 | </body> |
45 | - <?php do_action( 'AHEE__EE_Html_Messenger_main_wrapper_template_footer', $message_type, $page_title, $base_css, $print_css, $main_css, $main_body); ?> |
|
45 | + <?php do_action('AHEE__EE_Html_Messenger_main_wrapper_template_footer', $message_type, $page_title, $base_css, $print_css, $main_css, $main_body); ?> |
|
46 | 46 | <?php wp_footer(); ?> |
47 | 47 | </html> |
48 | 48 | \ No newline at end of file |
@@ -1345,7 +1345,7 @@ |
||
1345 | 1345 | * This just returns whatever is set as the _event object property |
1346 | 1346 | * |
1347 | 1347 | * //todo this will become obsolete once the models are in place |
1348 | - * @return object |
|
1348 | + * @return EE_CPT_Base |
|
1349 | 1349 | */ |
1350 | 1350 | public function get_event_object() { |
1351 | 1351 | return $this->_cpt_model_obj; |
@@ -606,9 +606,9 @@ |
||
606 | 606 | // first check if event is active. |
607 | 607 | if ( |
608 | 608 | $orig_status === EEM_Event::cancelled |
609 | - || $orig_status === EEM_Event::postponed |
|
610 | - || $event->is_expired() |
|
611 | - || $event->is_inactive() |
|
609 | + || $orig_status === EEM_Event::postponed |
|
610 | + || $event->is_expired() |
|
611 | + || $event->is_inactive() |
|
612 | 612 | ) { |
613 | 613 | return; |
614 | 614 | } |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -1484,10 +1485,11 @@ discard block |
||
1484 | 1485 | //get the earliest datetime (if present); |
1485 | 1486 | $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
1486 | 1487 | |
1487 | - if ( !empty( $earliest_dtt ) ) |
|
1488 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1489 | - else |
|
1490 | - $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) ); |
|
1488 | + if ( !empty( $earliest_dtt ) ) { |
|
1489 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1490 | + } else { |
|
1491 | + $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) ); |
|
1492 | + } |
|
1491 | 1493 | } |
1492 | 1494 | |
1493 | 1495 | $template_args = array_merge( $template_args, $price_args ); |
@@ -1725,8 +1727,9 @@ discard block |
||
1725 | 1727 | } |
1726 | 1728 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1727 | 1729 | |
1728 | - if ( $redirect_after ) |
|
1729 | - $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1730 | + if ( $redirect_after ) { |
|
1731 | + $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1732 | + } |
|
1730 | 1733 | } |
1731 | 1734 | |
1732 | 1735 | /** |
@@ -1853,8 +1856,9 @@ discard block |
||
1853 | 1856 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1854 | 1857 | } |
1855 | 1858 | |
1856 | - if ( $redirect_after ) |
|
1857 | - $this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash')); |
|
1859 | + if ( $redirect_after ) { |
|
1860 | + $this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash')); |
|
1861 | + } |
|
1858 | 1862 | } |
1859 | 1863 | |
1860 | 1864 | /** |
@@ -2091,8 +2095,10 @@ discard block |
||
2091 | 2095 | * @return void |
2092 | 2096 | */ |
2093 | 2097 | private function _set_category_object() { |
2094 | - if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) |
|
2095 | - return; //already have the category object so get out. |
|
2098 | + if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) { |
|
2099 | + return; |
|
2100 | + } |
|
2101 | + //already have the category object so get out. |
|
2096 | 2102 | |
2097 | 2103 | //set default category object |
2098 | 2104 | $this->_set_empty_category_object(); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $this->_cpt_edit_routes = array( |
67 | 67 | 'espresso_events' => 'edit' |
68 | 68 | ); |
69 | - add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array( $this, 'verify_event_edit' ) ); |
|
69 | + add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array($this, 'verify_event_edit')); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | protected function _ajax_hooks() { |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | 'edit' => __('Update Event', 'event_espresso'), |
93 | 93 | 'add_category' => __('Save New Category', 'event_espresso'), |
94 | 94 | 'edit_category' => __('Update Category', 'event_espresso'), |
95 | - 'template_settings' => __( 'Update Settings', 'event_espresso' ) |
|
95 | + 'template_settings' => __('Update Settings', 'event_espresso') |
|
96 | 96 | ) |
97 | 97 | ); |
98 | 98 | } |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | //load field generator helper |
103 | 103 | |
104 | 104 | //is there a evt_id in the request? |
105 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0; |
|
106 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
105 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0; |
|
106 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
107 | 107 | |
108 | 108 | |
109 | 109 | $this->_page_routes = array( |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | 'help_tour' => array( |
318 | 318 | 'Event_Editor_Help_Tour' |
319 | 319 | ), |
320 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
320 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
321 | 321 | 'require_nonce' => FALSE |
322 | 322 | ), |
323 | 323 | 'edit' => array( |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | /*'help_tour' => array( |
374 | 374 | 'Event_Edit_Help_Tour' |
375 | 375 | ),*/ |
376 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
376 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
377 | 377 | 'require_nonce' => FALSE |
378 | 378 | ), |
379 | 379 | 'default_event_settings' => array( |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | 'filename' => 'events_default_settings_status' |
396 | 396 | ) |
397 | 397 | ), |
398 | - 'help_tour' => array( 'Event_Default_Settings_Help_Tour'), |
|
398 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
399 | 399 | 'require_nonce' => FALSE |
400 | 400 | ), |
401 | 401 | //template settings |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | 'filename' => 'general_settings_templates' |
412 | 412 | ) |
413 | 413 | ), |
414 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
414 | + 'help_tour' => array('Templates_Help_Tour'), |
|
415 | 415 | 'require_nonce' => FALSE |
416 | 416 | ), |
417 | 417 | //event category stuff |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | 'label' => __('Edit Category', 'event_espresso'), |
436 | 436 | 'order' => 15, |
437 | 437 | 'persistent' => FALSE, |
438 | - 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
438 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), $this->_current_page_view_url) : $this->_admin_base_url |
|
439 | 439 | ), |
440 | 440 | 'help_tabs' => array( |
441 | 441 | 'edit_category_help_tab' => array( |
@@ -505,14 +505,14 @@ discard block |
||
505 | 505 | |
506 | 506 | public function load_scripts_styles() { |
507 | 507 | |
508 | - wp_register_style('events-admin-css', EVENTS_ASSETS_URL . 'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
509 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
508 | + wp_register_style('events-admin-css', EVENTS_ASSETS_URL.'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
509 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
510 | 510 | wp_enqueue_style('events-admin-css'); |
511 | 511 | wp_enqueue_style('ee-cat-admin'); |
512 | 512 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
513 | 513 | //registers for all views |
514 | 514 | //scripts |
515 | - wp_register_script('event_editor_js', EVENTS_ASSETS_URL . 'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
515 | + wp_register_script('event_editor_js', EVENTS_ASSETS_URL.'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | /** |
@@ -530,11 +530,11 @@ discard block |
||
530 | 530 | public function load_scripts_styles_edit() { |
531 | 531 | //styles |
532 | 532 | wp_enqueue_style('espresso-ui-theme'); |
533 | - wp_register_style('event-editor-css', EVENTS_ASSETS_URL . 'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
533 | + wp_register_style('event-editor-css', EVENTS_ASSETS_URL.'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
534 | 534 | wp_enqueue_style('event-editor-css'); |
535 | 535 | |
536 | 536 | //scripts |
537 | - wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL . 'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION ); |
|
537 | + wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL.'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION); |
|
538 | 538 | wp_enqueue_script('event-datetime-metabox'); |
539 | 539 | |
540 | 540 | } |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | |
570 | 570 | |
571 | 571 | public function admin_init() { |
572 | - EE_Registry::$i18n_js_strings[ 'image_confirm' ] = __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' ); |
|
572 | + EE_Registry::$i18n_js_strings['image_confirm'] = __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso'); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | |
@@ -590,12 +590,12 @@ discard block |
||
590 | 590 | */ |
591 | 591 | public function verify_event_edit($event = NULL) { |
592 | 592 | // no event? |
593 | - if ( empty( $event )) { |
|
593 | + if (empty($event)) { |
|
594 | 594 | // set event |
595 | 595 | $event = $this->_cpt_model_obj; |
596 | 596 | } |
597 | 597 | // STILL no event? |
598 | - if ( empty ( $event )) { |
|
598 | + if (empty ($event)) { |
|
599 | 599 | return; |
600 | 600 | } |
601 | 601 | $orig_status = $event->status(); |
@@ -609,27 +609,27 @@ discard block |
||
609 | 609 | return; |
610 | 610 | } |
611 | 611 | //made it here so it IS active... next check that any of the tickets are sold. |
612 | - if ( $event->is_sold_out( true ) ) { |
|
613 | - if ( $orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status ) { |
|
612 | + if ($event->is_sold_out(true)) { |
|
613 | + if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
614 | 614 | EE_Error::add_attention( |
615 | 615 | sprintf( |
616 | - __( 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso' ), |
|
617 | - EEH_Template::pretty_status( EEM_Event::sold_out, FALSE, 'sentence' ) |
|
616 | + __('Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso'), |
|
617 | + EEH_Template::pretty_status(EEM_Event::sold_out, FALSE, 'sentence') |
|
618 | 618 | ) |
619 | 619 | ); |
620 | 620 | } |
621 | 621 | return; |
622 | - } else if ( $orig_status === EEM_Event::sold_out ) { |
|
622 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
623 | 623 | EE_Error::add_attention( |
624 | 624 | sprintf( |
625 | - __( 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
626 | - 'event_espresso' ), |
|
627 | - EEH_Template::pretty_status( $event->status(), false, 'sentence' ) |
|
625 | + __('Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
626 | + 'event_espresso'), |
|
627 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
628 | 628 | ) |
629 | 629 | ); |
630 | 630 | } |
631 | 631 | //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
632 | - if ( ! $event->tickets_on_sale() ) { |
|
632 | + if ( ! $event->tickets_on_sale()) { |
|
633 | 633 | return; |
634 | 634 | } |
635 | 635 | //made it here so show warning |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | */ |
649 | 649 | protected function _edit_event_warning() { |
650 | 650 | // we don't want to add warnings during these requests |
651 | - if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] === 'editpost' ) { |
|
651 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
652 | 652 | return; |
653 | 653 | } |
654 | 654 | EE_Error::add_attention( |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | ), |
680 | 680 | ); |
681 | 681 | |
682 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
682 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
683 | 683 | $this->_views['trash'] = array( |
684 | 684 | 'slug' => 'trash', |
685 | 685 | 'label' => __('Trash', 'event_espresso'), |
@@ -709,39 +709,39 @@ discard block |
||
709 | 709 | 'desc' => __('View Registrations for Event', 'event_espresso') |
710 | 710 | ) |
711 | 711 | ); |
712 | - $items = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items ); |
|
712 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
713 | 713 | $statuses = array( |
714 | 714 | 'sold_out_status' => array( |
715 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
716 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, FALSE, 'sentence' ) |
|
715 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
716 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, FALSE, 'sentence') |
|
717 | 717 | ), |
718 | 718 | 'active_status' => array( |
719 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
720 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::active, FALSE, 'sentence' ) |
|
719 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
720 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, FALSE, 'sentence') |
|
721 | 721 | ), |
722 | 722 | 'upcoming_status' => array( |
723 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
724 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, FALSE, 'sentence' ) |
|
723 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
724 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, FALSE, 'sentence') |
|
725 | 725 | ), |
726 | 726 | 'postponed_status' => array( |
727 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
728 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, FALSE, 'sentence' ) |
|
727 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
728 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, FALSE, 'sentence') |
|
729 | 729 | ), |
730 | 730 | 'cancelled_status' => array( |
731 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
732 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, FALSE, 'sentence' ) |
|
731 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
732 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, FALSE, 'sentence') |
|
733 | 733 | ), |
734 | 734 | 'expired_status' => array( |
735 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
736 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::expired, FALSE, 'sentence' ) |
|
735 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
736 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, FALSE, 'sentence') |
|
737 | 737 | ), |
738 | 738 | 'inactive_status' => array( |
739 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
740 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, FALSE, 'sentence' ) |
|
739 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
740 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, FALSE, 'sentence') |
|
741 | 741 | ) |
742 | 742 | ); |
743 | - $statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses ); |
|
744 | - return array_merge( $items, $statuses ); |
|
743 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
744 | + return array_merge($items, $statuses); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | |
@@ -753,8 +753,8 @@ discard block |
||
753 | 753 | * @return EEM_Event |
754 | 754 | */ |
755 | 755 | private function _event_model() { |
756 | - if ( ! $this->_event_model instanceof EEM_Event ) { |
|
757 | - $this->_event_model = EE_Registry::instance()->load_model( 'Event' ); |
|
756 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
757 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
758 | 758 | } |
759 | 759 | return $this->_event_model; |
760 | 760 | } |
@@ -773,12 +773,12 @@ discard block |
||
773 | 773 | * @param string $new_slug what the slug is |
774 | 774 | * @return string The new html string for the permalink area |
775 | 775 | */ |
776 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
776 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
777 | 777 | //make sure this is only when editing |
778 | - if ( !empty( $id ) ) { |
|
779 | - $post = get_post( $id ); |
|
780 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' . __('Shortcode', 'event_espresso') . '</a> '; |
|
781 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' . $post->ID . ']">'; |
|
778 | + if ( ! empty($id)) { |
|
779 | + $post = get_post($id); |
|
780 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">'.__('Shortcode', 'event_espresso').'</a> '; |
|
781 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='.$post->ID.']">'; |
|
782 | 782 | } |
783 | 783 | return $return; |
784 | 784 | } |
@@ -794,8 +794,8 @@ discard block |
||
794 | 794 | * @return string html for generated table |
795 | 795 | */ |
796 | 796 | protected function _events_overview_list_table() { |
797 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
798 | - $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button' ) . |
|
797 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
798 | + $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button'). |
|
799 | 799 | $this->_display_legend($this->_event_legend_items()); |
800 | 800 | $this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2'); |
801 | 801 | $this->display_admin_list_table_page_with_no_sidebar(); |
@@ -813,51 +813,51 @@ discard block |
||
813 | 813 | |
814 | 814 | |
815 | 815 | |
816 | - protected function _insert_update_cpt_item( $post_id, $post ) { |
|
816 | + protected function _insert_update_cpt_item($post_id, $post) { |
|
817 | 817 | |
818 | - if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) { |
|
818 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
819 | 819 | //getout we're not processing an event save. |
820 | 820 | return; |
821 | 821 | } |
822 | 822 | |
823 | 823 | $event_values = array( |
824 | - 'EVT_display_desc' => !empty( $this->_req_data['display_desc'] ) ? 1 : 0, |
|
825 | - 'EVT_display_ticket_selector' => !empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0, |
|
824 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
825 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
826 | 826 | 'EVT_additional_limit' => min( |
827 | - apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ), |
|
828 | - !empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : NULL ), |
|
829 | - 'EVT_default_registration_status' => !empty( $this->_req_data['EVT_default_registration_status'] ) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
830 | - 'EVT_member_only' => !empty( $this->_req_data['member_only'] ) ? 1 : 0, |
|
831 | - 'EVT_allow_overflow' => !empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0, |
|
832 | - 'EVT_timezone_string' => !empty( $this->_req_data['timezone_string'] ) ? $this->_req_data['timezone_string'] : NULL, |
|
833 | - 'EVT_external_URL' => !empty( $this->_req_data['externalURL'] ) ? $this->_req_data['externalURL'] : NULL, |
|
834 | - 'EVT_phone' => !empty( $this->_req_data['event_phone'] ) ? $this->_req_data['event_phone'] : NULL |
|
827 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
828 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : NULL ), |
|
829 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
830 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
831 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
832 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) ? $this->_req_data['timezone_string'] : NULL, |
|
833 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) ? $this->_req_data['externalURL'] : NULL, |
|
834 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) ? $this->_req_data['event_phone'] : NULL |
|
835 | 835 | ); |
836 | 836 | |
837 | 837 | //update event |
838 | - $success = $this->_event_model()->update_by_ID( $event_values, $post_id ); |
|
838 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
839 | 839 | |
840 | 840 | |
841 | 841 | //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
842 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status ); |
|
843 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
842 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
843 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
844 | 844 | |
845 | 845 | |
846 | 846 | //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
847 | - $event_update_callbacks = apply_filters( 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( array($this, '_default_venue_update' ), array( $this, '_default_tickets_update') ) ); |
|
847 | + $event_update_callbacks = apply_filters('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array(array($this, '_default_venue_update'), array($this, '_default_tickets_update'))); |
|
848 | 848 | |
849 | 849 | $att_success = TRUE; |
850 | 850 | |
851 | - foreach ( $event_update_callbacks as $e_callback ) { |
|
852 | - $_succ = call_user_func_array( $e_callback, array( $event, $this->_req_data ) ); |
|
853 | - $att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
851 | + foreach ($event_update_callbacks as $e_callback) { |
|
852 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
853 | + $att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | //any errors? |
857 | - if ( $success && FALSE === $att_success ) { |
|
858 | - EE_Error::add_error( __('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
859 | - } else if ( $success === FALSE ) { |
|
860 | - EE_Error::add_error( __('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
857 | + if ($success && FALSE === $att_success) { |
|
858 | + EE_Error::add_error(__('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
859 | + } else if ($success === FALSE) { |
|
860 | + EE_Error::add_error(__('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
861 | 861 | } |
862 | 862 | } |
863 | 863 | |
@@ -867,14 +867,14 @@ discard block |
||
867 | 867 | /** |
868 | 868 | * @see parent::restore_item() |
869 | 869 | */ |
870 | - protected function _restore_cpt_item( $post_id, $revision_id ) { |
|
870 | + protected function _restore_cpt_item($post_id, $revision_id) { |
|
871 | 871 | //copy existing event meta to new post |
872 | 872 | $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
873 | - if ( $post_evt instanceof EE_Event ) { |
|
873 | + if ($post_evt instanceof EE_Event) { |
|
874 | 874 | //meta revision restore |
875 | - $post_evt->restore_revision( $revision_id ); |
|
875 | + $post_evt->restore_revision($revision_id); |
|
876 | 876 | //related objs restore |
877 | - $post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) ); |
|
877 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
878 | 878 | } |
879 | 879 | } |
880 | 880 | |
@@ -887,52 +887,52 @@ discard block |
||
887 | 887 | * @param array $data The request data from the form |
888 | 888 | * @return bool Success or fail. |
889 | 889 | */ |
890 | - protected function _default_venue_update( $evtobj, $data ) { |
|
891 | - require_once( EE_MODELS . 'EEM_Venue.model.php' ); |
|
890 | + protected function _default_venue_update($evtobj, $data) { |
|
891 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
892 | 892 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
893 | 893 | $rows_affected = NULL; |
894 | - $venue_id = !empty( $data['venue_id'] ) ? $data['venue_id'] : NULL; |
|
894 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : NULL; |
|
895 | 895 | |
896 | 896 | // very important. If we don't have a venue name... |
897 | 897 | // then we'll get out because not necessary to create empty venue |
898 | - if ( empty( $data['venue_title'] ) ) { |
|
898 | + if (empty($data['venue_title'])) { |
|
899 | 899 | return false; |
900 | 900 | } |
901 | 901 | |
902 | 902 | $venue_array = array( |
903 | 903 | 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
904 | - 'VNU_name' => !empty( $data['venue_title'] ) ? $data['venue_title'] : NULL, |
|
905 | - 'VNU_desc' => !empty( $data['venue_description'] ) ? $data['venue_description'] : NULL, |
|
906 | - 'VNU_identifier' => !empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : NULL, |
|
907 | - 'VNU_short_desc' => !empty( $data['venue_short_description'] ) ? $data['venue_short_description'] : NULL, |
|
908 | - 'VNU_address' => !empty( $data['address'] ) ? $data['address'] : NULL, |
|
909 | - 'VNU_address2' => !empty( $data['address2'] ) ? $data['address2'] : NULL, |
|
910 | - 'VNU_city' => !empty( $data['city'] ) ? $data['city'] : NULL, |
|
911 | - 'STA_ID' => !empty( $data['state'] ) ? $data['state'] : NULL, |
|
912 | - 'CNT_ISO' => !empty( $data['countries'] ) ? $data['countries'] : NULL, |
|
913 | - 'VNU_zip' => !empty( $data['zip'] ) ? $data['zip'] : NULL, |
|
914 | - 'VNU_phone' => !empty( $data['venue_phone'] ) ? $data['venue_phone'] : NULL, |
|
915 | - 'VNU_capacity' => !empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : NULL, |
|
916 | - 'VNU_url' => !empty($data['venue_url'] ) ? $data['venue_url'] : NULL, |
|
917 | - 'VNU_virtual_phone' => !empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
918 | - 'VNU_virtual_url' => !empty( $data['virtual_url'] ) ? $data['virtual_url'] : NULL, |
|
919 | - 'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0, |
|
904 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : NULL, |
|
905 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : NULL, |
|
906 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : NULL, |
|
907 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] : NULL, |
|
908 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : NULL, |
|
909 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : NULL, |
|
910 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : NULL, |
|
911 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : NULL, |
|
912 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : NULL, |
|
913 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : NULL, |
|
914 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : NULL, |
|
915 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : NULL, |
|
916 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : NULL, |
|
917 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
918 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : NULL, |
|
919 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
920 | 920 | 'status' => 'publish' |
921 | 921 | ); |
922 | 922 | |
923 | 923 | |
924 | 924 | //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
925 | - if ( !empty( $venue_id ) ) { |
|
926 | - $update_where = array( $venue_model->primary_key_name() => $venue_id ); |
|
927 | - $rows_affected = $venue_model->update( $venue_array, array( $update_where ) ); |
|
925 | + if ( ! empty($venue_id)) { |
|
926 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
927 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
928 | 928 | //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
929 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
929 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
930 | 930 | return $rows_affected > 0 ? TRUE : FALSE; |
931 | 931 | } else { |
932 | 932 | //we insert the venue |
933 | - $venue_id = $venue_model->insert( $venue_array ); |
|
934 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
935 | - return !empty( $venue_id ) ? TRUE : FALSE; |
|
933 | + $venue_id = $venue_model->insert($venue_array); |
|
934 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
935 | + return ! empty($venue_id) ? TRUE : FALSE; |
|
936 | 936 | } |
937 | 937 | //when we have the ancestor come in it's already been handled by the revision save. |
938 | 938 | } |
@@ -946,54 +946,54 @@ discard block |
||
946 | 946 | * @param array $data The request data from the form |
947 | 947 | * @return bool success or fail |
948 | 948 | */ |
949 | - protected function _default_tickets_update( EE_Event $evtobj, $data ) { |
|
949 | + protected function _default_tickets_update(EE_Event $evtobj, $data) { |
|
950 | 950 | $success = true; |
951 | 951 | $saved_dtt = null; |
952 | 952 | $saved_tickets = array(); |
953 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
953 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
954 | 954 | |
955 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
955 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
956 | 956 | //trim all values to ensure any excess whitespace is removed. |
957 | - $dtt = array_map( 'trim', $dtt ); |
|
958 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
957 | + $dtt = array_map('trim', $dtt); |
|
958 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
959 | 959 | $datetime_values = array( |
960 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
960 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
961 | 961 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
962 | 962 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
963 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'], |
|
963 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
964 | 964 | 'DTT_order' => $row, |
965 | 965 | ); |
966 | 966 | |
967 | 967 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
968 | 968 | |
969 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
970 | - $DTM = EE_Registry::instance()->load_model('Datetime', array( $evtobj->get_timezone() ) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
971 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
972 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
973 | - foreach ( $datetime_values as $field => $value ) { |
|
974 | - $DTM->set( $field, $value ); |
|
969 | + if ( ! empty($dtt['DTT_ID'])) { |
|
970 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($evtobj->get_timezone()))->get_one_by_ID($dtt['DTT_ID']); |
|
971 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
972 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
973 | + foreach ($datetime_values as $field => $value) { |
|
974 | + $DTM->set($field, $value); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
978 | 978 | $saved_dtts[$DTM->ID()] = $DTM; |
979 | 979 | } else { |
980 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values ), FALSE, FALSE ); |
|
981 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
982 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
983 | - $DTM->set_timezone( $evtobj->get_timezone() ); |
|
984 | - foreach ( $datetime_values as $field => $value ) { |
|
985 | - $DTM->set( $field, $value ); |
|
980 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), FALSE, FALSE); |
|
981 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
982 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
983 | + $DTM->set_timezone($evtobj->get_timezone()); |
|
984 | + foreach ($datetime_values as $field => $value) { |
|
985 | + $DTM->set($field, $value); |
|
986 | 986 | } |
987 | 987 | } |
988 | 988 | $DTM->save(); |
989 | 989 | |
990 | - $DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' ); |
|
990 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
991 | 991 | |
992 | 992 | //load DTT helper |
993 | 993 | |
994 | 994 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
995 | - if( $DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end') ) { |
|
996 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start') ); |
|
995 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
996 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
997 | 997 | $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
998 | 998 | $DTT->save(); |
999 | 999 | } |
@@ -1001,45 +1001,45 @@ discard block |
||
1001 | 1001 | //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
1002 | 1002 | $saved_dtt = $DTT; |
1003 | 1003 | |
1004 | - $success = !$success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
1004 | + $success = ! $success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | //no dtts get deleted so we don't do any of that logic here. |
1008 | 1008 | //update tickets next |
1009 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
1010 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
1011 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
1009 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1010 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1011 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1012 | 1012 | $update_prices = false; |
1013 | - $ticket_price = isset( $data['edit_prices'][$row][1]['PRC_amount'] ) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1013 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1014 | 1014 | |
1015 | 1015 | // trim inputs to ensure any excess whitespace is removed. |
1016 | - $tkt = array_map( 'trim', $tkt ); |
|
1016 | + $tkt = array_map('trim', $tkt); |
|
1017 | 1017 | |
1018 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
1018 | + if (empty($tkt['TKT_start_date'])) { |
|
1019 | 1019 | //let's use now in the set timezone. |
1020 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
1021 | - $tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] ); |
|
1020 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1021 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
1024 | + if (empty($tkt['TKT_end_date'])) { |
|
1025 | 1025 | //use the start date of the first datetime |
1026 | 1026 | $dtt = $evtobj->first_datetime(); |
1027 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( $incoming_date_formats[0], $incoming_date_formats[1] ); |
|
1027 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time($incoming_date_formats[0], $incoming_date_formats[1]); |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | $TKT_values = array( |
1031 | - 'TKT_ID' => !empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
1032 | - 'TTM_ID' => !empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
1033 | - 'TKT_name' => !empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
1034 | - 'TKT_description' => !empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '', |
|
1031 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
1032 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1033 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1034 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1035 | 1035 | 'TKT_start_date' => $tkt['TKT_start_date'], |
1036 | 1036 | 'TKT_end_date' => $tkt['TKT_end_date'], |
1037 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1038 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt[ 'TKT_uses' ], |
|
1039 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
1040 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
1037 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1038 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1039 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1040 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1041 | 1041 | 'TKT_row' => $row, |
1042 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row, |
|
1042 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1043 | 1043 | 'TKT_price' => $ticket_price |
1044 | 1044 | ); |
1045 | 1045 | |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | |
1048 | 1048 | |
1049 | 1049 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
1050 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
1050 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1051 | 1051 | $TKT_values['TKT_ID'] = 0; |
1052 | 1052 | $TKT_values['TKT_is_default'] = 0; |
1053 | 1053 | $TKT_values['TKT_price'] = $ticket_price; |
@@ -1058,58 +1058,58 @@ discard block |
||
1058 | 1058 | //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
1059 | 1059 | //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
1060 | 1060 | |
1061 | - if ( !empty( $tkt['TKT_ID'] ) ) { |
|
1062 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $evtobj->get_timezone() ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
1063 | - if ( $TKT instanceof EE_Ticket ) { |
|
1064 | - $ticket_sold = $TKT->count_related( 'Registration', array( array( 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) ) ) ) > 0 ? true : false; |
|
1061 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1062 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($evtobj->get_timezone()))->get_one_by_ID($tkt['TKT_ID']); |
|
1063 | + if ($TKT instanceof EE_Ticket) { |
|
1064 | + $ticket_sold = $TKT->count_related('Registration', array(array('STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))))) > 0 ? true : false; |
|
1065 | 1065 | //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
1066 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) && ! $TKT->get( 'TKT_deleted' ) ? true : false; |
|
1067 | - $TKT->set_date_format( $incoming_date_formats[ 0 ] ); |
|
1068 | - $TKT->set_time_format( $incoming_date_formats[ 1 ] ); |
|
1066 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') && ! $TKT->get('TKT_deleted') ? true : false; |
|
1067 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1068 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1069 | 1069 | //set new values |
1070 | - foreach ( $TKT_values as $field => $value ) { |
|
1071 | - if ( $field == 'TKT_qty' ) { |
|
1072 | - $TKT->set_qty( $value ); |
|
1070 | + foreach ($TKT_values as $field => $value) { |
|
1071 | + if ($field == 'TKT_qty') { |
|
1072 | + $TKT->set_qty($value); |
|
1073 | 1073 | } else { |
1074 | - $TKT->set( $field, $value ); |
|
1074 | + $TKT->set($field, $value); |
|
1075 | 1075 | } |
1076 | 1076 | } |
1077 | 1077 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
1078 | - if ( $create_new_TKT ) { |
|
1078 | + if ($create_new_TKT) { |
|
1079 | 1079 | //archive the old ticket first |
1080 | - $TKT->set( 'TKT_deleted', 1 ); |
|
1080 | + $TKT->set('TKT_deleted', 1); |
|
1081 | 1081 | $TKT->save(); |
1082 | 1082 | //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
1083 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
1083 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1084 | 1084 | //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
1085 | 1085 | $TKT = clone $TKT; |
1086 | - $TKT->set( 'TKT_ID', 0 ); |
|
1087 | - $TKT->set( 'TKT_deleted', 0 ); |
|
1088 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1089 | - $TKT->set( 'TKT_sold', 0 ); |
|
1086 | + $TKT->set('TKT_ID', 0); |
|
1087 | + $TKT->set('TKT_deleted', 0); |
|
1088 | + $TKT->set('TKT_price', $ticket_price); |
|
1089 | + $TKT->set('TKT_sold', 0); |
|
1090 | 1090 | //now we need to make sure that $new prices are created as well and attached to new ticket. |
1091 | 1091 | $update_prices = true; |
1092 | 1092 | } |
1093 | 1093 | //make sure price is set if it hasn't been already |
1094 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1094 | + $TKT->set('TKT_price', $ticket_price); |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | } else { |
1098 | 1098 | //no TKT_id so a new TKT |
1099 | 1099 | $TKT_values['TKT_price'] = $ticket_price; |
1100 | - $TKT = EE_Registry::instance()->load_class('Ticket', array( $TKT_values ), FALSE, FALSE ); |
|
1101 | - if ( $TKT instanceof EE_Ticket ) { |
|
1100 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), FALSE, FALSE); |
|
1101 | + if ($TKT instanceof EE_Ticket) { |
|
1102 | 1102 | //need to reset values to properly account for the date formats |
1103 | - $TKT->set_date_format( $incoming_date_formats[0] ); |
|
1104 | - $TKT->set_time_format( $incoming_date_formats[1] ); |
|
1105 | - $TKT->set_timezone( $evtobj->get_timezone() ); |
|
1103 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1104 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1105 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1106 | 1106 | |
1107 | 1107 | //set new values |
1108 | - foreach ( $TKT_values as $field => $value ) { |
|
1109 | - if ( $field == 'TKT_qty' ) { |
|
1110 | - $TKT->set_qty( $value ); |
|
1108 | + foreach ($TKT_values as $field => $value) { |
|
1109 | + if ($field == 'TKT_qty') { |
|
1110 | + $TKT->set_qty($value); |
|
1111 | 1111 | } else { |
1112 | - $TKT->set( $field, $value ); |
|
1112 | + $TKT->set($field, $value); |
|
1113 | 1113 | } |
1114 | 1114 | } |
1115 | 1115 | |
@@ -1117,31 +1117,31 @@ discard block |
||
1117 | 1117 | } |
1118 | 1118 | } |
1119 | 1119 | // cap ticket qty by datetime reg limits |
1120 | - $TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) ); |
|
1120 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1121 | 1121 | //update ticket. |
1122 | 1122 | $TKT->save(); |
1123 | 1123 | |
1124 | 1124 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
1125 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
1126 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
1125 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1126 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1127 | 1127 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
1128 | 1128 | $TKT->save(); |
1129 | 1129 | } |
1130 | 1130 | |
1131 | 1131 | //initially let's add the ticket to the dtt |
1132 | - $saved_dtt->_add_relation_to( $TKT, 'Ticket' ); |
|
1132 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1133 | 1133 | |
1134 | 1134 | $saved_tickets[$TKT->ID()] = $TKT; |
1135 | 1135 | |
1136 | 1136 | //add prices to ticket |
1137 | - $this->_add_prices_to_ticket( $data['edit_prices'][$row], $TKT, $update_prices ); |
|
1137 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1138 | 1138 | } |
1139 | 1139 | //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
1140 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1141 | - $tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) ); |
|
1140 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1141 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1142 | 1142 | |
1143 | - foreach ( $tickets_removed as $id ) { |
|
1144 | - $id = absint( $id ); |
|
1143 | + foreach ($tickets_removed as $id) { |
|
1144 | + $id = absint($id); |
|
1145 | 1145 | |
1146 | 1146 | //get the ticket for this id |
1147 | 1147 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
1150 | 1150 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
1151 | 1151 | |
1152 | - foreach( $dtts as $dtt ) { |
|
1152 | + foreach ($dtts as $dtt) { |
|
1153 | 1153 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
1154 | 1154 | } |
1155 | 1155 | |
@@ -1160,7 +1160,7 @@ discard block |
||
1160 | 1160 | //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
1161 | 1161 | $tkt_to_remove->delete_permanently(); |
1162 | 1162 | } |
1163 | - return array( $saved_dtt, $saved_tickets ); |
|
1163 | + return array($saved_dtt, $saved_tickets); |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | |
@@ -1175,31 +1175,31 @@ discard block |
||
1175 | 1175 | * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
1176 | 1176 | * @return void |
1177 | 1177 | */ |
1178 | - private function _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = FALSE ) { |
|
1179 | - foreach ( $prices as $row => $prc ) { |
|
1178 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = FALSE) { |
|
1179 | + foreach ($prices as $row => $prc) { |
|
1180 | 1180 | $PRC_values = array( |
1181 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
1182 | - 'PRT_ID' => !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL, |
|
1183 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
1184 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
1185 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
1181 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
1182 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL, |
|
1183 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1184 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1185 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1186 | 1186 | 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
1187 | 1187 | 'PRC_order' => $row |
1188 | 1188 | ); |
1189 | 1189 | |
1190 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
1190 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1191 | 1191 | $PRC_values['PRC_ID'] = 0; |
1192 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
1192 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
1193 | 1193 | } else { |
1194 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
1194 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1195 | 1195 | //update this price with new values |
1196 | - foreach ( $PRC_values as $field => $newprc ) { |
|
1197 | - $PRC->set( $field, $newprc ); |
|
1196 | + foreach ($PRC_values as $field => $newprc) { |
|
1197 | + $PRC->set($field, $newprc); |
|
1198 | 1198 | } |
1199 | 1199 | $PRC->save(); |
1200 | 1200 | } |
1201 | 1201 | |
1202 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
1202 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1203 | 1203 | } |
1204 | 1204 | } |
1205 | 1205 | |
@@ -1237,9 +1237,9 @@ discard block |
||
1237 | 1237 | //load formatter helper |
1238 | 1238 | |
1239 | 1239 | //args for getting related registrations |
1240 | - $approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) ); |
|
1241 | - $not_approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved ) ); |
|
1242 | - $pending_payment_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment ) ); |
|
1240 | + $approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved)); |
|
1241 | + $not_approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved)); |
|
1242 | + $pending_payment_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment)); |
|
1243 | 1243 | |
1244 | 1244 | |
1245 | 1245 | // publish box |
@@ -1268,9 +1268,9 @@ discard block |
||
1268 | 1268 | ), |
1269 | 1269 | REG_ADMIN_URL |
1270 | 1270 | ), |
1271 | - 'approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $approved_query_args ), |
|
1272 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $not_approved_query_args ), |
|
1273 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( 'Registration', $pending_payment_query_args ), |
|
1271 | + 'approved_regs' => $this->_cpt_model_obj->count_related('Registration', $approved_query_args), |
|
1272 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related('Registration', $not_approved_query_args), |
|
1273 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related('Registration', $pending_payment_query_args), |
|
1274 | 1274 | 'misc_pub_section_class' => apply_filters( |
1275 | 1275 | 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
1276 | 1276 | 'misc-pub-section' |
@@ -1289,9 +1289,9 @@ discard block |
||
1289 | 1289 | 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
1290 | 1290 | $this->_cpt_model_obj |
1291 | 1291 | ); |
1292 | - $publish_box_extra_args[ 'event_editor_overview_add' ] = ob_get_clean(); |
|
1292 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1293 | 1293 | // load template |
1294 | - EEH_Template::display_template( EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', $publish_box_extra_args ); |
|
1294 | + EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', $publish_box_extra_args); |
|
1295 | 1295 | } |
1296 | 1296 | |
1297 | 1297 | |
@@ -1323,16 +1323,16 @@ discard block |
||
1323 | 1323 | $this->verify_cpt_object(); |
1324 | 1324 | add_meta_box( |
1325 | 1325 | 'espresso_event_editor_tickets', |
1326 | - __( 'Event Datetime & Ticket', 'event_espresso' ), |
|
1327 | - array( $this, 'ticket_metabox' ), |
|
1326 | + __('Event Datetime & Ticket', 'event_espresso'), |
|
1327 | + array($this, 'ticket_metabox'), |
|
1328 | 1328 | $this->page_slug, |
1329 | 1329 | 'normal', |
1330 | 1330 | 'high' |
1331 | 1331 | ); |
1332 | 1332 | add_meta_box( |
1333 | 1333 | 'espresso_event_editor_event_options', |
1334 | - __( 'Event Registration Options', 'event_espresso' ), |
|
1335 | - array( $this, 'registration_options_meta_box' ), |
|
1334 | + __('Event Registration Options', 'event_espresso'), |
|
1335 | + array($this, 'registration_options_meta_box'), |
|
1336 | 1336 | $this->page_slug, |
1337 | 1337 | 'side', |
1338 | 1338 | 'default' |
@@ -1362,36 +1362,36 @@ discard block |
||
1362 | 1362 | 'disabled' => '' |
1363 | 1363 | ); |
1364 | 1364 | |
1365 | - $event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : NULL; |
|
1365 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : NULL; |
|
1366 | 1366 | |
1367 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1367 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1368 | 1368 | |
1369 | 1369 | /** |
1370 | 1370 | * 1. Start with retrieving Datetimes |
1371 | 1371 | * 2. Fore each datetime get related tickets |
1372 | 1372 | * 3. For each ticket get related prices |
1373 | 1373 | */ |
1374 | - $times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event_id ); |
|
1374 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1375 | 1375 | /** @type EE_Datetime $first_datetime */ |
1376 | - $first_datetime = reset( $times ); |
|
1376 | + $first_datetime = reset($times); |
|
1377 | 1377 | //do we get related tickets? |
1378 | - if ( $first_datetime instanceof EE_Datetime |
|
1379 | - && $first_datetime->ID() !== 0 ) { |
|
1378 | + if ($first_datetime instanceof EE_Datetime |
|
1379 | + && $first_datetime->ID() !== 0) { |
|
1380 | 1380 | $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
1381 | 1381 | $template_args['time'] = $first_datetime; |
1382 | 1382 | $related_tickets = $first_datetime->tickets( |
1383 | 1383 | array( |
1384 | - array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), |
|
1384 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1385 | 1385 | 'default_where_conditions' => 'none' |
1386 | 1386 | ) |
1387 | 1387 | ); |
1388 | 1388 | |
1389 | - if ( !empty($related_tickets) ) { |
|
1389 | + if ( ! empty($related_tickets)) { |
|
1390 | 1390 | $template_args['total_ticket_rows'] = count($related_tickets); |
1391 | 1391 | $row = 0; |
1392 | - foreach ( $related_tickets as $ticket ) { |
|
1392 | + foreach ($related_tickets as $ticket) { |
|
1393 | 1393 | $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
1394 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row ); |
|
1394 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row); |
|
1395 | 1395 | |
1396 | 1396 | $row++; |
1397 | 1397 | } |
@@ -1399,13 +1399,13 @@ discard block |
||
1399 | 1399 | $template_args['total_ticket_rows'] = 1; |
1400 | 1400 | /** @type EE_Ticket $ticket */ |
1401 | 1401 | $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
1402 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket ); |
|
1402 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1403 | 1403 | } |
1404 | 1404 | } else { |
1405 | 1405 | $template_args['time'] = $times[0]; |
1406 | 1406 | /** @type EE_Ticket $ticket */ |
1407 | 1407 | $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
1408 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] ); |
|
1408 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1409 | 1409 | // NOTE: we're just sending the first default row |
1410 | 1410 | // (decaf can't manage default tickets so this should be sufficient); |
1411 | 1411 | } |
@@ -1414,8 +1414,8 @@ discard block |
||
1414 | 1414 | $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
1415 | 1415 | $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
1416 | 1416 | $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
1417 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE ); |
|
1418 | - $template = apply_filters( 'FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' ); |
|
1417 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row(EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE); |
|
1418 | + $template = apply_filters('FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'); |
|
1419 | 1419 | EEH_Template::display_template($template, $template_args); |
1420 | 1420 | } |
1421 | 1421 | |
@@ -1430,21 +1430,21 @@ discard block |
||
1430 | 1430 | * @param int $row |
1431 | 1431 | * @return string generated html for the ticket row. |
1432 | 1432 | */ |
1433 | - private function _get_ticket_row( $ticket, $skeleton = FALSE, $row = 0 ) { |
|
1433 | + private function _get_ticket_row($ticket, $skeleton = FALSE, $row = 0) { |
|
1434 | 1434 | $template_args = array( |
1435 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1436 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && !$skeleton ? ' tkt-archived' : '', |
|
1435 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1436 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' : '', |
|
1437 | 1437 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
1438 | 1438 | 'TKT_ID' => $ticket->get('TKT_ID'), |
1439 | 1439 | 'TKT_name' => $ticket->get('TKT_name'), |
1440 | 1440 | 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
1441 | 1441 | 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
1442 | 1442 | 'TKT_is_default' => $ticket->get('TKT_is_default'), |
1443 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty','input'), |
|
1443 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1444 | 1444 | 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
1445 | 1445 | 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
1446 | - 'trash_icon' => ( $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted') ) ) && ( !empty( $ticket ) && $ticket->get('TKT_sold') === 0 ) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1447 | - 'disabled' => $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted' ) ) ? '' : ' disabled=disabled' |
|
1446 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1447 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' : ' disabled=disabled' |
|
1448 | 1448 | ); |
1449 | 1449 | |
1450 | 1450 | $price = $ticket->ID() !== 0 ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) : EE_Registry::instance()->load_model('Price')->create_default_object(); |
@@ -1460,23 +1460,23 @@ discard block |
||
1460 | 1460 | |
1461 | 1461 | //make sure we have default start and end dates if skeleton |
1462 | 1462 | //handle rows that should NOT be empty |
1463 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1463 | + if (empty($template_args['TKT_start_date'])) { |
|
1464 | 1464 | //if empty then the start date will be now. |
1465 | 1465 | $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
1466 | 1466 | } |
1467 | 1467 | |
1468 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1468 | + if (empty($template_args['TKT_end_date'])) { |
|
1469 | 1469 | //get the earliest datetime (if present); |
1470 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1470 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1471 | 1471 | |
1472 | - if ( !empty( $earliest_dtt ) ) |
|
1472 | + if ( ! empty($earliest_dtt)) |
|
1473 | 1473 | $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
1474 | 1474 | else |
1475 | - $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) ); |
|
1475 | + $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))); |
|
1476 | 1476 | } |
1477 | 1477 | |
1478 | - $template_args = array_merge( $template_args, $price_args ); |
|
1479 | - $template = apply_filters( 'FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1478 | + $template_args = array_merge($template_args, $price_args); |
|
1479 | + $template = apply_filters('FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1480 | 1480 | return EEH_Template::display_template($template, $template_args, TRUE); |
1481 | 1481 | } |
1482 | 1482 | |
@@ -1505,8 +1505,8 @@ discard block |
||
1505 | 1505 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
1506 | 1506 | $template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description()); |
1507 | 1507 | $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false); |
1508 | - $template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values ); |
|
1509 | - $templatepath = EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php'; |
|
1508 | + $template_args['additional_registration_options'] = apply_filters('FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values); |
|
1509 | + $templatepath = EVENTS_TEMPLATE_PATH.'event_registration_options.template.php'; |
|
1510 | 1510 | EEH_Template::display_template($templatepath, $template_args); |
1511 | 1511 | } |
1512 | 1512 | |
@@ -1534,21 +1534,21 @@ discard block |
||
1534 | 1534 | $EEME = $this->_event_model(); |
1535 | 1535 | |
1536 | 1536 | $offset = ($current_page - 1) * $per_page; |
1537 | - $limit = $count ? NULL : $offset . ',' . $per_page; |
|
1537 | + $limit = $count ? NULL : $offset.','.$per_page; |
|
1538 | 1538 | $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
1539 | 1539 | $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
1540 | 1540 | |
1541 | 1541 | if (isset($this->_req_data['month_range'])) { |
1542 | 1542 | $pieces = explode(' ', $this->_req_data['month_range'], 3); |
1543 | - $month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1544 | - $year_r = !empty($pieces[1]) ? $pieces[1] : ''; |
|
1543 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1544 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1545 | 1545 | } |
1546 | 1546 | |
1547 | 1547 | $where = array(); |
1548 | 1548 | |
1549 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
|
1549 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL; |
|
1550 | 1550 | //determine what post_status our condition will have for the query. |
1551 | - switch ( $status ) { |
|
1551 | + switch ($status) { |
|
1552 | 1552 | case 'month' : |
1553 | 1553 | case 'today' : |
1554 | 1554 | case NULL : |
@@ -1556,7 +1556,7 @@ discard block |
||
1556 | 1556 | break; |
1557 | 1557 | |
1558 | 1558 | case 'draft' : |
1559 | - $where['status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1559 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1560 | 1560 | break; |
1561 | 1561 | |
1562 | 1562 | default : |
@@ -1564,43 +1564,43 @@ discard block |
||
1564 | 1564 | } |
1565 | 1565 | |
1566 | 1566 | //categories? |
1567 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1567 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1568 | 1568 | |
1569 | - if ( !empty ( $category ) ) { |
|
1569 | + if ( ! empty ($category)) { |
|
1570 | 1570 | $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1571 | 1571 | $where['Term_Taxonomy.term_id'] = $category; |
1572 | 1572 | } |
1573 | 1573 | |
1574 | 1574 | //date where conditions |
1575 | - $start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' ); |
|
1575 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1576 | 1576 | if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
1577 | - $DateTime = new DateTime( $year_r . '-' . $month_r . '-01 00:00:00', new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) ); |
|
1578 | - $start = $DateTime->format( implode( ' ', $start_formats ) ); |
|
1579 | - $end = $DateTime->setDate( $year_r, $month_r, $DateTime->format('t') )->setTime(23,59,59)->format( implode( ' ', $start_formats ) ); |
|
1580 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array( $start, $end ) ); |
|
1577 | + $DateTime = new DateTime($year_r.'-'.$month_r.'-01 00:00:00', new DateTimeZone(EEM_Datetime::instance()->get_timezone())); |
|
1578 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1579 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1580 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1581 | 1581 | } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
1582 | - $DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1583 | - $start = $DateTime->setTime( 0,0,0 )->format( implode( ' ', $start_formats ) ); |
|
1584 | - $end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1585 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1586 | - } else if ( isset($this->_req_data['status']) && $this->_req_data['status'] == 'month' ) { |
|
1587 | - $now = date( 'Y-m-01' ); |
|
1588 | - $DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1589 | - $start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) ); |
|
1590 | - $end = $DateTime->setDate( date('Y'), date('m'), $DateTime->format('t' ) )->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1591 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1582 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1583 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1584 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1585 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1586 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1587 | + $now = date('Y-m-01'); |
|
1588 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1589 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1590 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1591 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1592 | 1592 | } |
1593 | 1593 | |
1594 | 1594 | |
1595 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1596 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
1595 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1596 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
1597 | 1597 | } else { |
1598 | - if ( ! isset( $where['status'] ) ) { |
|
1599 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
1598 | + if ( ! isset($where['status'])) { |
|
1599 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1600 | 1600 | $where['OR'] = array( |
1601 | - 'status*restrict_private' => array( '!=', 'private' ), |
|
1601 | + 'status*restrict_private' => array('!=', 'private'), |
|
1602 | 1602 | 'AND' => array( |
1603 | - 'status*inclusive' => array( '=', 'private' ), |
|
1603 | + 'status*inclusive' => array('=', 'private'), |
|
1604 | 1604 | 'EVT_wp_user' => get_current_user_id() |
1605 | 1605 | ) |
1606 | 1606 | ); |
@@ -1608,16 +1608,16 @@ discard block |
||
1608 | 1608 | } |
1609 | 1609 | } |
1610 | 1610 | |
1611 | - if ( isset( $this->_req_data['EVT_wp_user'] ) ) { |
|
1612 | - if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1611 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1612 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1613 | 1613 | $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
1614 | 1614 | } |
1615 | 1615 | } |
1616 | 1616 | |
1617 | 1617 | |
1618 | 1618 | //search query handling |
1619 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1620 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1619 | + if (isset($this->_req_data['s'])) { |
|
1620 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1621 | 1621 | $where['OR'] = array( |
1622 | 1622 | 'EVT_name' => array('LIKE', $search_string), |
1623 | 1623 | 'EVT_desc' => array('LIKE', $search_string), |
@@ -1626,32 +1626,32 @@ discard block |
||
1626 | 1626 | } |
1627 | 1627 | |
1628 | 1628 | |
1629 | - $where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data ); |
|
1630 | - $query_params = apply_filters( 'FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID' ), $this->_req_data ); |
|
1629 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1630 | + $query_params = apply_filters('FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID'), $this->_req_data); |
|
1631 | 1631 | |
1632 | 1632 | |
1633 | 1633 | //let's first check if we have special requests coming in. |
1634 | - if ( isset( $this->_req_data['active_status'] ) ) { |
|
1635 | - switch ( $this->_req_data['active_status'] ) { |
|
1634 | + if (isset($this->_req_data['active_status'])) { |
|
1635 | + switch ($this->_req_data['active_status']) { |
|
1636 | 1636 | case 'upcoming' : |
1637 | - return $EEME->get_upcoming_events( $query_params, $count ); |
|
1637 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1638 | 1638 | break; |
1639 | 1639 | |
1640 | 1640 | case 'expired' : |
1641 | - return $EEME->get_expired_events( $query_params, $count ); |
|
1641 | + return $EEME->get_expired_events($query_params, $count); |
|
1642 | 1642 | break; |
1643 | 1643 | |
1644 | 1644 | case 'active' : |
1645 | - return $EEME->get_active_events( $query_params, $count ); |
|
1645 | + return $EEME->get_active_events($query_params, $count); |
|
1646 | 1646 | break; |
1647 | 1647 | |
1648 | 1648 | case 'inactive' : |
1649 | - return $EEME->get_inactive_events( $query_params, $count ); |
|
1649 | + return $EEME->get_inactive_events($query_params, $count); |
|
1650 | 1650 | break; |
1651 | 1651 | } |
1652 | 1652 | } |
1653 | 1653 | |
1654 | - $events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params ); |
|
1654 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1655 | 1655 | |
1656 | 1656 | return $events; |
1657 | 1657 | } |
@@ -1660,23 +1660,23 @@ discard block |
||
1660 | 1660 | |
1661 | 1661 | |
1662 | 1662 | //handling for WordPress CPT actions (trash, restore, delete) |
1663 | - public function trash_cpt_item( $post_id ) { |
|
1663 | + public function trash_cpt_item($post_id) { |
|
1664 | 1664 | $this->_req_data['EVT_ID'] = $post_id; |
1665 | - $this->_trash_or_restore_event( 'trash', FALSE ); |
|
1665 | + $this->_trash_or_restore_event('trash', FALSE); |
|
1666 | 1666 | } |
1667 | 1667 | |
1668 | 1668 | |
1669 | 1669 | |
1670 | 1670 | |
1671 | - public function restore_cpt_item( $post_id ) { |
|
1671 | + public function restore_cpt_item($post_id) { |
|
1672 | 1672 | $this->_req_data['EVT_ID'] = $post_id; |
1673 | - $this->_trash_or_restore_event( 'draft', FALSE ); |
|
1673 | + $this->_trash_or_restore_event('draft', FALSE); |
|
1674 | 1674 | } |
1675 | 1675 | |
1676 | 1676 | |
1677 | - public function delete_cpt_item( $post_id ) { |
|
1677 | + public function delete_cpt_item($post_id) { |
|
1678 | 1678 | $this->_req_data['EVT_ID'] = $post_id; |
1679 | - $this->_delete_event( FALSE ); |
|
1679 | + $this->_delete_event(FALSE); |
|
1680 | 1680 | } |
1681 | 1681 | |
1682 | 1682 | |
@@ -1688,7 +1688,7 @@ discard block |
||
1688 | 1688 | * @param string $event_status |
1689 | 1689 | * @return void |
1690 | 1690 | */ |
1691 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) { |
|
1691 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE) { |
|
1692 | 1692 | //determine the event id and set to array. |
1693 | 1693 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE; |
1694 | 1694 | // loop thru events |
@@ -1696,7 +1696,7 @@ discard block |
||
1696 | 1696 | // clean status |
1697 | 1697 | $event_status = sanitize_key($event_status); |
1698 | 1698 | // grab status |
1699 | - if (!empty($event_status)) { |
|
1699 | + if ( ! empty($event_status)) { |
|
1700 | 1700 | $success = $this->_change_event_status($EVT_ID, $event_status); |
1701 | 1701 | } else { |
1702 | 1702 | $success = FALSE; |
@@ -1710,7 +1710,7 @@ discard block |
||
1710 | 1710 | } |
1711 | 1711 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1712 | 1712 | |
1713 | - if ( $redirect_after ) |
|
1713 | + if ($redirect_after) |
|
1714 | 1714 | $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
1715 | 1715 | } |
1716 | 1716 | |
@@ -1725,7 +1725,7 @@ discard block |
||
1725 | 1725 | // clean status |
1726 | 1726 | $event_status = sanitize_key($event_status); |
1727 | 1727 | // grab status |
1728 | - if (!empty($event_status)) { |
|
1728 | + if ( ! empty($event_status)) { |
|
1729 | 1729 | $success = TRUE; |
1730 | 1730 | //determine the event id and set to array. |
1731 | 1731 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
@@ -1760,15 +1760,15 @@ discard block |
||
1760 | 1760 | * @param string $event_status |
1761 | 1761 | * @return bool |
1762 | 1762 | */ |
1763 | - private function _change_event_status( $EVT_ID = 0, $event_status = '') { |
|
1763 | + private function _change_event_status($EVT_ID = 0, $event_status = '') { |
|
1764 | 1764 | // grab event id |
1765 | - if (!$EVT_ID) { |
|
1765 | + if ( ! $EVT_ID) { |
|
1766 | 1766 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1767 | 1767 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1768 | 1768 | return FALSE; |
1769 | 1769 | } |
1770 | 1770 | |
1771 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1771 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1772 | 1772 | |
1773 | 1773 | // clean status |
1774 | 1774 | $event_status = sanitize_key($event_status); |
@@ -1794,7 +1794,7 @@ discard block |
||
1794 | 1794 | $hook = FALSE; |
1795 | 1795 | } |
1796 | 1796 | //use class to change status |
1797 | - $this->_cpt_model_obj->set_status( $event_status ); |
|
1797 | + $this->_cpt_model_obj->set_status($event_status); |
|
1798 | 1798 | $success = $this->_cpt_model_obj->save(); |
1799 | 1799 | |
1800 | 1800 | if ($success === FALSE) { |
@@ -1816,15 +1816,15 @@ discard block |
||
1816 | 1816 | * @access protected |
1817 | 1817 | * @param bool $redirect_after |
1818 | 1818 | */ |
1819 | - protected function _delete_event( $redirect_after = TRUE ) { |
|
1819 | + protected function _delete_event($redirect_after = TRUE) { |
|
1820 | 1820 | //determine the event id and set to array. |
1821 | 1821 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : NULL; |
1822 | - $EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID; |
|
1822 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
1823 | 1823 | |
1824 | 1824 | |
1825 | 1825 | // loop thru events |
1826 | 1826 | if ($EVT_ID) { |
1827 | - $success = $this->_permanently_delete_event( $EVT_ID ); |
|
1827 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
1828 | 1828 | // get list of events with no prices |
1829 | 1829 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
1830 | 1830 | // remove this event from the list of events with no prices |
@@ -1838,7 +1838,7 @@ discard block |
||
1838 | 1838 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1839 | 1839 | } |
1840 | 1840 | |
1841 | - if ( $redirect_after ) |
|
1841 | + if ($redirect_after) |
|
1842 | 1842 | $this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash')); |
1843 | 1843 | } |
1844 | 1844 | |
@@ -1856,12 +1856,12 @@ discard block |
||
1856 | 1856 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
1857 | 1857 | // loop thru events |
1858 | 1858 | foreach ($EVT_IDs as $EVT_ID) { |
1859 | - $EVT_ID = absint( $EVT_ID ); |
|
1860 | - if ( $EVT_ID ) { |
|
1861 | - $results = $this->_permanently_delete_event( $EVT_ID ); |
|
1859 | + $EVT_ID = absint($EVT_ID); |
|
1860 | + if ($EVT_ID) { |
|
1861 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
1862 | 1862 | $success = $results !== FALSE ? $success : FALSE; |
1863 | 1863 | // remove this event from the list of events with no prices |
1864 | - unset( $espresso_no_ticket_prices[ $EVT_ID ] ); |
|
1864 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
1865 | 1865 | } else { |
1866 | 1866 | $success = FALSE; |
1867 | 1867 | $msg = __('An error occurred. An event could not be deleted because a valid event ID was not not supplied.', 'event_espresso'); |
@@ -1881,9 +1881,9 @@ discard block |
||
1881 | 1881 | * @param int $EVT_ID |
1882 | 1882 | * @return bool |
1883 | 1883 | */ |
1884 | - private function _permanently_delete_event( $EVT_ID = 0 ) { |
|
1884 | + private function _permanently_delete_event($EVT_ID = 0) { |
|
1885 | 1885 | // grab event id |
1886 | - if ( ! $EVT_ID ) { |
|
1886 | + if ( ! $EVT_ID) { |
|
1887 | 1887 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1888 | 1888 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1889 | 1889 | return FALSE; |
@@ -1892,19 +1892,19 @@ discard block |
||
1892 | 1892 | ! $this->_cpt_model_obj instanceof EE_Event |
1893 | 1893 | || $this->_cpt_model_obj->ID() !== $EVT_ID |
1894 | 1894 | ) { |
1895 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1895 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1896 | 1896 | } |
1897 | 1897 | |
1898 | - if ( ! $this->_cpt_model_obj instanceof EE_Event ) { |
|
1898 | + if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
1899 | 1899 | return false; |
1900 | 1900 | } |
1901 | 1901 | |
1902 | 1902 | //need to delete related tickets and prices first. |
1903 | 1903 | $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
1904 | - foreach ( $datetimes as $datetime ) { |
|
1904 | + foreach ($datetimes as $datetime) { |
|
1905 | 1905 | $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
1906 | 1906 | $tickets = $datetime->get_many_related('Ticket'); |
1907 | - foreach ( $tickets as $ticket ) { |
|
1907 | + foreach ($tickets as $ticket) { |
|
1908 | 1908 | $ticket->_remove_relation_to($datetime, 'Datetime'); |
1909 | 1909 | $ticket->delete_related_permanently('Price'); |
1910 | 1910 | $ticket->delete_permanently(); |
@@ -1914,14 +1914,14 @@ discard block |
||
1914 | 1914 | |
1915 | 1915 | //what about related venues or terms? |
1916 | 1916 | $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
1917 | - foreach ( $venues as $venue ) { |
|
1917 | + foreach ($venues as $venue) { |
|
1918 | 1918 | $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
1919 | 1919 | } |
1920 | 1920 | |
1921 | 1921 | //any attached question groups? |
1922 | 1922 | $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
1923 | - if ( !empty( $question_groups ) ) { |
|
1924 | - foreach ( $question_groups as $question_group ) { |
|
1923 | + if ( ! empty($question_groups)) { |
|
1924 | + foreach ($question_groups as $question_group) { |
|
1925 | 1925 | $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
1926 | 1926 | } |
1927 | 1927 | } |
@@ -1930,12 +1930,12 @@ discard block |
||
1930 | 1930 | |
1931 | 1931 | |
1932 | 1932 | //Message Template Groups |
1933 | - $this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' ); |
|
1933 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
1934 | 1934 | |
1935 | 1935 | /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
1936 | 1936 | $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
1937 | 1937 | |
1938 | - foreach ( $term_taxonomies as $term_taxonomy ) { |
|
1938 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
1939 | 1939 | $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
1940 | 1940 | } |
1941 | 1941 | |
@@ -1949,7 +1949,7 @@ discard block |
||
1949 | 1949 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1950 | 1950 | return FALSE; |
1951 | 1951 | } |
1952 | - do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID ); |
|
1952 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
1953 | 1953 | return TRUE; |
1954 | 1954 | } |
1955 | 1955 | |
@@ -1966,7 +1966,7 @@ discard block |
||
1966 | 1966 | */ |
1967 | 1967 | public function total_events() { |
1968 | 1968 | |
1969 | - $count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
1969 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
1970 | 1970 | return $count; |
1971 | 1971 | } |
1972 | 1972 | |
@@ -1981,10 +1981,10 @@ discard block |
||
1981 | 1981 | */ |
1982 | 1982 | public function total_events_draft() { |
1983 | 1983 | $where = array( |
1984 | - 'status' => array( 'IN', array('draft', 'auto-draft' ) ) |
|
1984 | + 'status' => array('IN', array('draft', 'auto-draft')) |
|
1985 | 1985 | ); |
1986 | 1986 | |
1987 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
1987 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1988 | 1988 | return $count; |
1989 | 1989 | } |
1990 | 1990 | |
@@ -2003,7 +2003,7 @@ discard block |
||
2003 | 2003 | 'status' => 'trash' |
2004 | 2004 | ); |
2005 | 2005 | |
2006 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2006 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2007 | 2007 | return $count; |
2008 | 2008 | } |
2009 | 2009 | |
@@ -2031,11 +2031,11 @@ discard block |
||
2031 | 2031 | // translated |
2032 | 2032 | TRUE |
2033 | 2033 | ); |
2034 | - $this->_template_args['default_reg_status'] = isset( EE_Registry::instance()->CFG->registration->default_STS_ID ) ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) : EEM_Registration::status_id_pending_payment; |
|
2034 | + $this->_template_args['default_reg_status'] = isset(EE_Registry::instance()->CFG->registration->default_STS_ID) ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) : EEM_Registration::status_id_pending_payment; |
|
2035 | 2035 | |
2036 | 2036 | $this->_set_add_edit_form_tags('update_default_event_settings'); |
2037 | 2037 | $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
2038 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH . 'event_settings.template.php', $this->_template_args, TRUE); |
|
2038 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_settings.template.php', $this->_template_args, TRUE); |
|
2039 | 2039 | $this->display_admin_page_with_sidebar(); |
2040 | 2040 | } |
2041 | 2041 | |
@@ -2061,9 +2061,9 @@ discard block |
||
2061 | 2061 | |
2062 | 2062 | protected function _template_settings() { |
2063 | 2063 | $this->_admin_page_title = __('Template Settings (Preview)', 'event_espresso'); |
2064 | - $this->_template_args['preview_img'] = '<img src="' . EVENTS_ASSETS_URL . DS . 'images' . DS . 'caffeinated_template_features.jpg" alt="' . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) . '" />'; |
|
2065 | - $this->_template_args['preview_text'] = '<strong>'.__( 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso' ).'</strong>'; |
|
2066 | - $this->display_admin_caf_preview_page( 'template_settings_tab' ); |
|
2064 | + $this->_template_args['preview_img'] = '<img src="'.EVENTS_ASSETS_URL.DS.'images'.DS.'caffeinated_template_features.jpg" alt="'.esc_attr__('Template Settings Preview screenshot', 'event_espresso').'" />'; |
|
2065 | + $this->_template_args['preview_text'] = '<strong>'.__('Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso').'</strong>'; |
|
2066 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2067 | 2067 | } |
2068 | 2068 | |
2069 | 2069 | |
@@ -2076,22 +2076,22 @@ discard block |
||
2076 | 2076 | * @return void |
2077 | 2077 | */ |
2078 | 2078 | private function _set_category_object() { |
2079 | - if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) |
|
2079 | + if (isset($this->_category->id) && ! empty($this->_category->id)) |
|
2080 | 2080 | return; //already have the category object so get out. |
2081 | 2081 | |
2082 | 2082 | //set default category object |
2083 | 2083 | $this->_set_empty_category_object(); |
2084 | 2084 | |
2085 | 2085 | //only set if we've got an id |
2086 | - if ( !isset($this->_req_data['EVT_CAT_ID'] ) ) { |
|
2086 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2087 | 2087 | return; |
2088 | 2088 | } |
2089 | 2089 | |
2090 | 2090 | $category_id = absint($this->_req_data['EVT_CAT_ID']); |
2091 | 2091 | |
2092 | - $term = get_term( $category_id, 'espresso_event_categories' ); |
|
2092 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2093 | 2093 | |
2094 | - if ( !empty( $term ) ) { |
|
2094 | + if ( ! empty($term)) { |
|
2095 | 2095 | $this->_category->category_name = $term->name; |
2096 | 2096 | $this->_category->category_identifier = $term->slug; |
2097 | 2097 | $this->_category->category_desc = $term->description; |
@@ -2105,13 +2105,13 @@ discard block |
||
2105 | 2105 | |
2106 | 2106 | private function _set_empty_category_object() { |
2107 | 2107 | $this->_category = new stdClass(); |
2108 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2108 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2109 | 2109 | $this->_category->id = $this->_category->parent = 0; |
2110 | 2110 | } |
2111 | 2111 | |
2112 | 2112 | |
2113 | 2113 | protected function _category_list_table() { |
2114 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2114 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2115 | 2115 | $this->_search_btn_label = __('Categories', 'event_espresso'); |
2116 | 2116 | $this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2'); |
2117 | 2117 | $this->display_admin_list_table_page_with_sidebar(); |
@@ -2127,14 +2127,14 @@ discard block |
||
2127 | 2127 | $this->_set_add_edit_form_tags($route); |
2128 | 2128 | |
2129 | 2129 | $this->_set_category_object(); |
2130 | - $id = !empty($this->_category->id) ? $this->_category->id : ''; |
|
2130 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2131 | 2131 | |
2132 | 2132 | $delete_action = 'delete_category'; |
2133 | 2133 | |
2134 | 2134 | //custom redirect |
2135 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'category_list'), $this->_admin_base_url ); |
|
2135 | + $redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url); |
|
2136 | 2136 | |
2137 | - $this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect ); |
|
2137 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2138 | 2138 | |
2139 | 2139 | //take care of contents |
2140 | 2140 | $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
@@ -2148,25 +2148,25 @@ discard block |
||
2148 | 2148 | 'type' => 'wp_editor', |
2149 | 2149 | 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
2150 | 2150 | 'class' => 'my_editor_custom', |
2151 | - 'wpeditor_args' => array('media_buttons' => FALSE ) |
|
2151 | + 'wpeditor_args' => array('media_buttons' => FALSE) |
|
2152 | 2152 | ); |
2153 | - $_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' ); |
|
2153 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2154 | 2154 | |
2155 | - $all_terms = get_terms( array('espresso_event_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) ); |
|
2155 | + $all_terms = get_terms(array('espresso_event_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id))); |
|
2156 | 2156 | |
2157 | 2157 | //setup category select for term parents. |
2158 | 2158 | $category_select_values[] = array( |
2159 | 2159 | 'text' => __('No Parent', 'event_espresso'), |
2160 | 2160 | 'id' => 0 |
2161 | 2161 | ); |
2162 | - foreach ( $all_terms as $term ) { |
|
2162 | + foreach ($all_terms as $term) { |
|
2163 | 2163 | $category_select_values[] = array( |
2164 | 2164 | 'text' => $term->name, |
2165 | 2165 | 'id' => $term->term_id |
2166 | 2166 | ); |
2167 | 2167 | } |
2168 | 2168 | |
2169 | - $category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent ); |
|
2169 | + $category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent); |
|
2170 | 2170 | |
2171 | 2171 | $template_args = array( |
2172 | 2172 | 'category' => $this->_category, |
@@ -2176,15 +2176,15 @@ discard block |
||
2176 | 2176 | 'disable' => '', |
2177 | 2177 | 'disabled_message' => FALSE |
2178 | 2178 | ); |
2179 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2180 | - return EEH_Template::display_template($template, $template_args, TRUE ); |
|
2179 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2180 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
2181 | 2181 | } |
2182 | 2182 | |
2183 | 2183 | |
2184 | 2184 | protected function _delete_categories() { |
2185 | - $cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2185 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2186 | 2186 | |
2187 | - foreach ( $cat_ids as $cat_id ) { |
|
2187 | + foreach ($cat_ids as $cat_id) { |
|
2188 | 2188 | $this->_delete_category($cat_id); |
2189 | 2189 | } |
2190 | 2190 | |
@@ -2192,7 +2192,7 @@ discard block |
||
2192 | 2192 | $query_args = array( |
2193 | 2193 | 'action' => 'category_list' |
2194 | 2194 | ); |
2195 | - $this->_redirect_after_action(0,'','',$query_args); |
|
2195 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2196 | 2196 | |
2197 | 2197 | } |
2198 | 2198 | |
@@ -2202,61 +2202,61 @@ discard block |
||
2202 | 2202 | |
2203 | 2203 | protected function _delete_category($cat_id) { |
2204 | 2204 | global $wpdb; |
2205 | - $cat_id = absint( $cat_id ); |
|
2206 | - wp_delete_term( $cat_id, 'espresso_event_categories' ); |
|
2205 | + $cat_id = absint($cat_id); |
|
2206 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2207 | 2207 | } |
2208 | 2208 | |
2209 | 2209 | |
2210 | 2210 | |
2211 | 2211 | protected function _insert_or_update_category($new_category) { |
2212 | 2212 | |
2213 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE ); |
|
2213 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE); |
|
2214 | 2214 | $success = 0; //we already have a success message so lets not send another. |
2215 | 2215 | |
2216 | - if ( $cat_id ) { |
|
2216 | + if ($cat_id) { |
|
2217 | 2217 | $query_args = array( |
2218 | 2218 | 'action' => 'edit_category', |
2219 | 2219 | 'EVT_CAT_ID' => $cat_id |
2220 | 2220 | ); |
2221 | 2221 | } else { |
2222 | - $query_args = array( 'action' => 'add_category' ); |
|
2222 | + $query_args = array('action' => 'add_category'); |
|
2223 | 2223 | } |
2224 | - $this->_redirect_after_action( $success, '','', $query_args, TRUE ); |
|
2224 | + $this->_redirect_after_action($success, '', '', $query_args, TRUE); |
|
2225 | 2225 | |
2226 | 2226 | } |
2227 | 2227 | |
2228 | 2228 | |
2229 | 2229 | |
2230 | - private function _insert_category( $update = FALSE ) { |
|
2230 | + private function _insert_category($update = FALSE) { |
|
2231 | 2231 | $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
2232 | - $category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : ''; |
|
2233 | - $category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : ''; |
|
2234 | - $category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0; |
|
2232 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2233 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2234 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2235 | 2235 | |
2236 | - if ( empty( $category_name ) ) { |
|
2237 | - $msg = __( 'You must add a name for the category.', 'event_espresso' ); |
|
2238 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2236 | + if (empty($category_name)) { |
|
2237 | + $msg = __('You must add a name for the category.', 'event_espresso'); |
|
2238 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2239 | 2239 | return false; |
2240 | 2240 | } |
2241 | 2241 | |
2242 | - $term_args=array( |
|
2242 | + $term_args = array( |
|
2243 | 2243 | 'name'=>$category_name, |
2244 | 2244 | 'description'=>$category_desc, |
2245 | 2245 | 'parent'=>$category_parent |
2246 | 2246 | ); |
2247 | 2247 | //was the category_identifier input disabled? |
2248 | - if(isset($this->_req_data['category_identifier'])){ |
|
2248 | + if (isset($this->_req_data['category_identifier'])) { |
|
2249 | 2249 | $term_args['slug'] = $this->_req_data['category_identifier']; |
2250 | 2250 | } |
2251 | - $insert_ids = $update ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_event_categories', $term_args ); |
|
2251 | + $insert_ids = $update ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2252 | 2252 | |
2253 | - if ( !is_array( $insert_ids ) ) { |
|
2254 | - $msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' ); |
|
2255 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2253 | + if ( ! is_array($insert_ids)) { |
|
2254 | + $msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso'); |
|
2255 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2256 | 2256 | } else { |
2257 | 2257 | $cat_id = $insert_ids['term_id']; |
2258 | - $msg = sprintf ( __('The category %s was successfully saved', 'event_espresso'), $category_name ); |
|
2259 | - EE_Error::add_success( $msg ); |
|
2258 | + $msg = sprintf(__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
2259 | + EE_Error::add_success($msg); |
|
2260 | 2260 | } |
2261 | 2261 | |
2262 | 2262 | return $cat_id; |
@@ -2265,32 +2265,32 @@ discard block |
||
2265 | 2265 | |
2266 | 2266 | |
2267 | 2267 | |
2268 | - public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) { |
|
2268 | + public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) { |
|
2269 | 2269 | global $wpdb; |
2270 | 2270 | |
2271 | 2271 | //testing term stuff |
2272 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2273 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC'; |
|
2274 | - $limit = ($current_page-1)*$per_page; |
|
2272 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2273 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2274 | + $limit = ($current_page - 1) * $per_page; |
|
2275 | 2275 | |
2276 | - $where = array( 'taxonomy' => 'espresso_event_categories' ); |
|
2276 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2277 | 2277 | |
2278 | - if ( isset( $this->_req_data['s'] ) ) { |
|
2279 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2278 | + if (isset($this->_req_data['s'])) { |
|
2279 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2280 | 2280 | $where['OR'] = array( |
2281 | - 'Term.name' => array( 'LIKE', $sstr), |
|
2282 | - 'description' => array( 'LIKE', $sstr ) |
|
2281 | + 'Term.name' => array('LIKE', $sstr), |
|
2282 | + 'description' => array('LIKE', $sstr) |
|
2283 | 2283 | ); |
2284 | 2284 | } |
2285 | 2285 | |
2286 | 2286 | $query_params = array( |
2287 | - $where , |
|
2288 | - 'order_by' => array( $orderby => $order ), |
|
2289 | - 'limit' => $limit . ',' . $per_page, |
|
2287 | + $where, |
|
2288 | + 'order_by' => array($orderby => $order), |
|
2289 | + 'limit' => $limit.','.$per_page, |
|
2290 | 2290 | 'force_join' => array('Term') |
2291 | 2291 | ); |
2292 | 2292 | |
2293 | - $categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params ); |
|
2293 | + $categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2294 | 2294 | |
2295 | 2295 | return $categories; |
2296 | 2296 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | /** |
28 | 28 | * Applies all teh individual item validation strategies on each item in the array |
29 | 29 | * @param array $normalized_value |
30 | - * @return boolean |
|
30 | + * @return boolean|null |
|
31 | 31 | */ |
32 | 32 | function validate($normalized_value) { |
33 | 33 | if( is_array($normalized_value)){ |
@@ -112,7 +112,7 @@ |
||
112 | 112 | if ( |
113 | 113 | ! ( |
114 | 114 | $this->checkout->payment_method instanceof EE_Payment_Method |
115 | - && $this->checkout->payment_method->is_off_site() |
|
115 | + && $this->checkout->payment_method->is_off_site() |
|
116 | 116 | ) |
117 | 117 | ) { |
118 | 118 | // mark this reg step as completed |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | * @param EE_Checkout $checkout |
23 | 23 | * @return \EE_SPCO_Reg_Step_Finalize_Registration |
24 | 24 | */ |
25 | - public function __construct( EE_Checkout $checkout ) { |
|
25 | + public function __construct(EE_Checkout $checkout) { |
|
26 | 26 | $this->_slug = 'finalize_registration'; |
27 | - $this->_name = __( 'Finalize Registration', 'event_espresso' ); |
|
27 | + $this->_name = __('Finalize Registration', 'event_espresso'); |
|
28 | 28 | $this->_submit_button_text = $this->_name; |
29 | 29 | $this->_template = ''; |
30 | 30 | $this->checkout = $checkout; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function initialize_reg_step() { |
49 | 49 | // there's actually no reg form to process if this is the final step |
50 | - if ( $this->is_current_step() ) { |
|
50 | + if ($this->is_current_step()) { |
|
51 | 51 | $this->checkout->step = $_REQUEST['step'] = $this->slug(); |
52 | 52 | $this->checkout->action = $_REQUEST['action'] = 'process_reg_step'; |
53 | 53 | $this->checkout->generate_reg_form = false; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function process_reg_step() { |
75 | 75 | // ensure all data gets refreshed from the db |
76 | - $this->checkout->refresh_all_entities( true ); |
|
76 | + $this->checkout->refresh_all_entities(true); |
|
77 | 77 | // ensures that all details and statuses for transaction, registration, and payments are updated |
78 | 78 | $txn_update_params = $this->_finalize_transaction(); |
79 | 79 | // DEBUG LOG |
@@ -102,13 +102,13 @@ discard block |
||
102 | 102 | $txn_update_params |
103 | 103 | ); |
104 | 104 | // check if transaction has a primary registrant and that it has a related Attendee object |
105 | - if ( ! $this->_validate_primary_registrant() ) { |
|
105 | + if ( ! $this->_validate_primary_registrant()) { |
|
106 | 106 | return false; |
107 | 107 | } |
108 | 108 | // you don't have to go home but you can't stay here ! |
109 | 109 | $this->checkout->redirect = true; |
110 | 110 | $this->checkout->continue_reg = true; |
111 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
111 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
112 | 112 | if ( |
113 | 113 | ! ( |
114 | 114 | $this->checkout->payment_method instanceof EE_Payment_Method |
@@ -133,26 +133,26 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function _finalize_transaction() { |
135 | 135 | /** @type EE_Transaction_Processor $transaction_processor */ |
136 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
136 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
137 | 137 | //set revisit flag in txn processor |
138 | - $transaction_processor->set_revisit( $this->checkout->revisit ); |
|
138 | + $transaction_processor->set_revisit($this->checkout->revisit); |
|
139 | 139 | // at this point we'll consider a TXN to not have been abandoned |
140 | - $transaction_processor->toggle_abandoned_transaction_status( $this->checkout->transaction ); |
|
141 | - if ( $this->checkout->cart instanceof EE_Cart ) { |
|
140 | + $transaction_processor->toggle_abandoned_transaction_status($this->checkout->transaction); |
|
141 | + if ($this->checkout->cart instanceof EE_Cart) { |
|
142 | 142 | // save TXN data to the cart |
143 | 143 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
144 | 144 | $this->checkout->transaction->ID() |
145 | 145 | ); |
146 | 146 | } |
147 | 147 | /** @type EE_Transaction_Payments $transaction_payments */ |
148 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
148 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
149 | 149 | // maybe update status, but don't save transaction just yet |
150 | - $transaction_payments->update_transaction_status_based_on_total_paid( $this->checkout->transaction, false ); |
|
150 | + $transaction_payments->update_transaction_status_based_on_total_paid($this->checkout->transaction, false); |
|
151 | 151 | // maybe send messages |
152 | 152 | $this->_trigger_notifications(); |
153 | 153 | // this will result in the base session properties getting saved to the TXN_Session_data field |
154 | 154 | $this->checkout->transaction->set_txn_session_data( |
155 | - EE_Registry::instance()->SSN->get_session_data( null, true ) |
|
155 | + EE_Registry::instance()->SSN->get_session_data(null, true) |
|
156 | 156 | ); |
157 | 157 | // update the TXN if payment conditions have changed |
158 | 158 | return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | * @throws \EE_Error |
175 | 175 | */ |
176 | 176 | protected function _trigger_notifications() { |
177 | - if ( $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
178 | - $is_revisit = filter_var( $this->checkout->revisit, FILTER_VALIDATE_BOOLEAN ); |
|
179 | - if ( $this->checkout->payment_method->is_off_site() ) { |
|
180 | - $gateway= $this->checkout->payment_method->type_obj()->get_gateway(); |
|
177 | + if ($this->checkout->payment_method instanceof EE_Payment_Method) { |
|
178 | + $is_revisit = filter_var($this->checkout->revisit, FILTER_VALIDATE_BOOLEAN); |
|
179 | + if ($this->checkout->payment_method->is_off_site()) { |
|
180 | + $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
|
181 | 181 | if ( |
182 | 182 | ! $is_revisit |
183 | 183 | && $gateway instanceof EE_Offsite_Gateway |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | ) |
188 | 188 | ) { |
189 | 189 | // first time through SPCO and we are processing the payment notification NOW |
190 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
190 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
191 | 191 | } else { |
192 | 192 | // do NOT trigger notifications because this is a revisit, OR it was already done during the IPN |
193 | - remove_all_filters( 'FHEE__EED_Messages___maybe_registration__deliver_notifications' ); |
|
193 | + remove_all_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications'); |
|
194 | 194 | add_filter( |
195 | 195 | 'FHEE__EED_Messages___maybe_registration__deliver_notifications', |
196 | 196 | '__return_false', |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | } |
200 | 200 | } else if ( |
201 | 201 | // if SPCO revisit and TXN status has changed due to a payment |
202 | - $is_revisit && ( $this->checkout->txn_status_updated || $this->checkout->any_reg_status_updated() ) |
|
202 | + $is_revisit && ($this->checkout->txn_status_updated || $this->checkout->any_reg_status_updated()) |
|
203 | 203 | ) { |
204 | 204 | // send out notifications |
205 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
206 | - } else if ( ! $is_revisit ) { |
|
207 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
205 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
206 | + } else if ( ! $is_revisit) { |
|
207 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | } |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | * @throws \EE_Error |
219 | 219 | */ |
220 | 220 | protected function _validate_primary_registrant() { |
221 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
221 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
222 | 222 | EE_Error::add_error( |
223 | - __( 'A valid Primary Registration for this Transaction could not be found.', 'event_espresso' ), |
|
223 | + __('A valid Primary Registration for this Transaction could not be found.', 'event_espresso'), |
|
224 | 224 | __FILE__, |
225 | 225 | __FUNCTION__, |
226 | 226 | __LINE__ |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | } |
232 | 232 | // setup URL for redirect |
233 | 233 | $this->checkout->redirect_url = add_query_arg( |
234 | - array( 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link() ), |
|
234 | + array('e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link()), |
|
235 | 235 | $this->checkout->thank_you_page_url |
236 | 236 | ); |
237 | 237 | return true; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function update_reg_step() { |
246 | 246 | EE_Error::doing_it_wrong( |
247 | - __CLASS__ . '::' . __FILE__, |
|
247 | + __CLASS__.'::'.__FILE__, |
|
248 | 248 | __( |
249 | 249 | 'Can not call update_reg_step() on the Finalize Registration reg step.', |
250 | 250 | 'event_espresso' |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | protected function _get_billing_values_from_form( $billing_form ){ |
443 | 443 | if($billing_form instanceof EE_Form_Section_Proper ){ |
444 | 444 | return $billing_form->input_pretty_values( true ); |
445 | - }else{ |
|
445 | + } else{ |
|
446 | 446 | return NULL; |
447 | 447 | } |
448 | 448 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | public function supports_sending_refunds(){ |
551 | 551 | if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
552 | 552 | return $this->_gateway->supports_sending_refunds(); |
553 | - }else{ |
|
553 | + } else{ |
|
554 | 554 | return false; |
555 | 555 | } |
556 | 556 | } |
@@ -588,11 +588,11 @@ discard block |
||
588 | 588 | public function payment_occurs(){ |
589 | 589 | if( ! $this->_gateway){ |
590 | 590 | return EE_PMT_Base::offline; |
591 | - }elseif($this->_gateway instanceof EE_Onsite_Gateway){ |
|
591 | + } elseif($this->_gateway instanceof EE_Onsite_Gateway){ |
|
592 | 592 | return EE_PMT_Base::onsite; |
593 | - }elseif($this->_gateway instanceof EE_Offsite_Gateway){ |
|
593 | + } elseif($this->_gateway instanceof EE_Offsite_Gateway){ |
|
594 | 594 | return EE_PMT_Base::offsite; |
595 | - }else{ |
|
595 | + } else{ |
|
596 | 596 | throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"),get_class($this))); |
597 | 597 | } |
598 | 598 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @since $VID:$ |
15 | 15 | * |
16 | 16 | */ |
17 | -abstract class EE_PMT_Base{ |
|
17 | +abstract class EE_PMT_Base { |
|
18 | 18 | |
19 | 19 | const onsite = 'on-site'; |
20 | 20 | const offsite = 'off-site'; |
@@ -95,31 +95,31 @@ discard block |
||
95 | 95 | * @return EE_PMT_Base |
96 | 96 | */ |
97 | 97 | function __construct($pm_instance = NULL) { |
98 | - if ( $pm_instance instanceof EE_Payment_Method ){ |
|
98 | + if ($pm_instance instanceof EE_Payment_Method) { |
|
99 | 99 | $this->set_instance($pm_instance); |
100 | 100 | } |
101 | - if($this->_gateway){ |
|
102 | - $this->_gateway->set_payment_model( EEM_Payment::instance() ); |
|
103 | - $this->_gateway->set_payment_log( EEM_Change_Log::instance() ); |
|
104 | - $this->_gateway->set_template_helper( new EEH_Template() ); |
|
105 | - $this->_gateway->set_line_item_helper( new EEH_Line_Item() ); |
|
106 | - $this->_gateway->set_money_helper( new EEH_Money() ); |
|
101 | + if ($this->_gateway) { |
|
102 | + $this->_gateway->set_payment_model(EEM_Payment::instance()); |
|
103 | + $this->_gateway->set_payment_log(EEM_Change_Log::instance()); |
|
104 | + $this->_gateway->set_template_helper(new EEH_Template()); |
|
105 | + $this->_gateway->set_line_item_helper(new EEH_Line_Item()); |
|
106 | + $this->_gateway->set_money_helper(new EEH_Money()); |
|
107 | 107 | } |
108 | - if ( ! isset( $this->_has_billing_form ) ) { |
|
108 | + if ( ! isset($this->_has_billing_form)) { |
|
109 | 109 | // by default, On Site gateways have a billing form |
110 | - if ( $this->payment_occurs() == EE_PMT_Base::onsite ) { |
|
111 | - $this->set_has_billing_form( true ); |
|
110 | + if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
|
111 | + $this->set_has_billing_form(true); |
|
112 | 112 | } else { |
113 | - $this->set_has_billing_form( false ); |
|
113 | + $this->set_has_billing_form(false); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - if( ! $this->_pretty_name){ |
|
117 | + if ( ! $this->_pretty_name) { |
|
118 | 118 | throw new EE_Error(sprintf(__("You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", "event_espresso"))); |
119 | 119 | } |
120 | 120 | //if the child didn't specify a default button, use the credit card one |
121 | - if( $this->_default_button_url === NULL){ |
|
122 | - $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods' . DS . 'pay-by-credit-card.png'; |
|
121 | + if ($this->_default_button_url === NULL) { |
|
122 | + $this->_default_button_url = EE_PLUGIN_DIR_URL.'payment_methods'.DS.'pay-by-credit-card.png'; |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | /** |
129 | 129 | * @param boolean $has_billing_form |
130 | 130 | */ |
131 | - public function set_has_billing_form( $has_billing_form ) { |
|
132 | - $this->_has_billing_form = filter_var( $has_billing_form, FILTER_VALIDATE_BOOLEAN ); |
|
131 | + public function set_has_billing_form($has_billing_form) { |
|
132 | + $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | /** |
138 | 138 | * sets the file_folder property |
139 | 139 | */ |
140 | - protected function _set_file_folder(){ |
|
140 | + protected function _set_file_folder() { |
|
141 | 141 | $reflector = new ReflectionClass(get_class($this)); |
142 | 142 | $fn = $reflector->getFileName(); |
143 | - $this->_file_folder = dirname($fn).DS; |
|
143 | + $this->_file_folder = dirname($fn).DS; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | /** |
149 | 149 | * sets the file URL with a trailing slash for this PMT |
150 | 150 | */ |
151 | - protected function _set_file_url(){ |
|
152 | - $plugins_dir_fixed = str_replace('\\',DS,WP_PLUGIN_DIR); |
|
153 | - $file_folder_fixed = str_replace('\\',DS,$this->file_folder()); |
|
154 | - $file_path = str_replace($plugins_dir_fixed,WP_PLUGIN_URL,$file_folder_fixed); |
|
151 | + protected function _set_file_url() { |
|
152 | + $plugins_dir_fixed = str_replace('\\', DS, WP_PLUGIN_DIR); |
|
153 | + $file_folder_fixed = str_replace('\\', DS, $this->file_folder()); |
|
154 | + $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed); |
|
155 | 155 | $this->_file_url = $file_path; |
156 | 156 | } |
157 | 157 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * Gets the default description on all payment methods of this type |
160 | 160 | * @return string |
161 | 161 | */ |
162 | - public function default_description(){ |
|
162 | + public function default_description() { |
|
163 | 163 | return $this->_default_description; |
164 | 164 | } |
165 | 165 | |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * Returns the folder containing the PMT child class, with a trailing slash |
170 | 170 | * @return string |
171 | 171 | */ |
172 | - public function file_folder(){ |
|
173 | - if( ! $this->_file_folder ) { |
|
172 | + public function file_folder() { |
|
173 | + if ( ! $this->_file_folder) { |
|
174 | 174 | $this->_set_file_folder(); |
175 | 175 | } |
176 | 176 | return $this->_file_folder; |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | /** |
182 | 182 | * @return string |
183 | 183 | */ |
184 | - public function file_url(){ |
|
185 | - if( ! $this->_file_url ) { |
|
184 | + public function file_url() { |
|
185 | + if ( ! $this->_file_url) { |
|
186 | 186 | $this->_set_file_url(); |
187 | 187 | } |
188 | 188 | return $this->_file_url; |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | * Its important teh payment method instance is set before |
196 | 196 | * @param EE_Payment_Method $payment_method_instance |
197 | 197 | */ |
198 | - function set_instance($payment_method_instance){ |
|
198 | + function set_instance($payment_method_instance) { |
|
199 | 199 | $this->_pm_instance = $payment_method_instance; |
200 | 200 | //if they have already requested the settings form, make sure its |
201 | 201 | //data matches this model object |
202 | - if($this->_settings_form){ |
|
202 | + if ($this->_settings_form) { |
|
203 | 203 | $this->settings_form()->populate_model_obj($payment_method_instance); |
204 | 204 | } |
205 | - if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
|
205 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
206 | 206 | $this->_gateway->set_settings($payment_method_instance->settings_array()); |
207 | 207 | } |
208 | 208 | } |
@@ -213,14 +213,14 @@ discard block |
||
213 | 213 | * Gets teh form for displaying to admins where they setup the payment method |
214 | 214 | * @return EE_Payment_Method_Form |
215 | 215 | */ |
216 | - function settings_form(){ |
|
217 | - if( ! $this->_settings_form){ |
|
216 | + function settings_form() { |
|
217 | + if ( ! $this->_settings_form) { |
|
218 | 218 | $this->_settings_form = $this->generate_new_settings_form(); |
219 | - $this->_settings_form->set_payment_method_type( $this ); |
|
220 | - $this->_settings_form->_construct_finalize(NULL, NULL ); |
|
219 | + $this->_settings_form->set_payment_method_type($this); |
|
220 | + $this->_settings_form->_construct_finalize(NULL, NULL); |
|
221 | 221 | //if we have already assigned a model object to this pmt, make |
222 | 222 | //sure its reflected in teh form we just generated |
223 | - if($this->_pm_instance){ |
|
223 | + if ($this->_pm_instance) { |
|
224 | 224 | $this->_settings_form->populate_model_obj($this->_pm_instance); |
225 | 225 | } |
226 | 226 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * this payment method type's settings form later in the request |
247 | 247 | * @param EE_Payment_Method_Form $form |
248 | 248 | */ |
249 | - public function set_settings_form($form){ |
|
249 | + public function set_settings_form($form) { |
|
250 | 250 | $this->_settings_form = $form; |
251 | 251 | } |
252 | 252 | |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | * @param array $extra_args |
270 | 270 | * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null |
271 | 271 | */ |
272 | - public function billing_form( EE_Transaction $transaction = NULL, $extra_args = array() ){ |
|
272 | + public function billing_form(EE_Transaction $transaction = NULL, $extra_args = array()) { |
|
273 | 273 | // has billing form already been regenerated ? or overwrite cache? |
274 | - if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form ){ |
|
275 | - $this->_billing_form = $this->generate_new_billing_form( $transaction, $extra_args ); |
|
274 | + if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
275 | + $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
|
276 | 276 | } |
277 | 277 | //if we know who the attendee is, and this is a billing form |
278 | 278 | //that uses attendee info, populate it |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | $transaction instanceof EE_Transaction && |
282 | 282 | $transaction->primary_registration() instanceof EE_Registration && |
283 | 283 | $transaction->primary_registration()->attendee() instanceof EE_Attendee |
284 | - ){ |
|
285 | - $this->_billing_form->populate_from_attendee( $transaction->primary_registration()->attendee() ); |
|
284 | + ) { |
|
285 | + $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee()); |
|
286 | 286 | } |
287 | 287 | return $this->_billing_form; |
288 | 288 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @param \EE_Transaction $transaction |
294 | 294 | * @return \EE_Billing_Info_Form |
295 | 295 | */ |
296 | - abstract function generate_new_billing_form( EE_Transaction $transaction = NULL ); |
|
296 | + abstract function generate_new_billing_form(EE_Transaction $transaction = NULL); |
|
297 | 297 | |
298 | 298 | |
299 | 299 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @param \EE_Billing_Info_Form $billing_form |
305 | 305 | * @return \EE_Billing_Info_Form |
306 | 306 | */ |
307 | - public function apply_billing_form_debug_settings( EE_Billing_Info_Form $billing_form ) { |
|
307 | + public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) { |
|
308 | 308 | return $billing_form; |
309 | 309 | } |
310 | 310 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * if you have form |
316 | 316 | * @param EE_Payment_Method $form |
317 | 317 | */ |
318 | - public function set_billing_form($form){ |
|
318 | + public function set_billing_form($form) { |
|
319 | 319 | $this->_billing_form = $form; |
320 | 320 | } |
321 | 321 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | * Returns whether or not this payment method requires HTTPS to be used |
326 | 326 | * @return boolean |
327 | 327 | */ |
328 | - function requires_https(){ |
|
328 | + function requires_https() { |
|
329 | 329 | return $this->_requires_https; |
330 | 330 | } |
331 | 331 | |
@@ -343,9 +343,9 @@ discard block |
||
343 | 343 | * @return EE_Payment |
344 | 344 | * @throws EE_Error |
345 | 345 | */ |
346 | - function process_payment( EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null,$fail_url = '', $method = 'CART', $by_admin = false ){ |
|
346 | + function process_payment(EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null, $fail_url = '', $method = 'CART', $by_admin = false) { |
|
347 | 347 | // @todo: add surcharge for the payment method, if any |
348 | - if ( $this->_gateway ) { |
|
348 | + if ($this->_gateway) { |
|
349 | 349 | //there is a gateway, so we're going to make a payment object |
350 | 350 | //but wait! do they already have a payment in progress that we thought was failed? |
351 | 351 | $duplicate_properties = array( |
@@ -356,10 +356,10 @@ discard block |
||
356 | 356 | 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), |
357 | 357 | 'PAY_gateway_response' => null, |
358 | 358 | ); |
359 | - $payment = EEM_Payment::instance()->get_one( array( $duplicate_properties )); |
|
359 | + $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
|
360 | 360 | //if we didn't already have a payment in progress for the same thing, |
361 | 361 | //then we actually want to make a new payment |
362 | - if ( ! $payment instanceof EE_Payment ){ |
|
362 | + if ( ! $payment instanceof EE_Payment) { |
|
363 | 363 | $payment = EE_Payment::new_instance( |
364 | 364 | array_merge( |
365 | 365 | $duplicate_properties, |
@@ -375,10 +375,10 @@ discard block |
||
375 | 375 | } |
376 | 376 | //make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it |
377 | 377 | $payment->save(); |
378 | - $billing_values = $this->_get_billing_values_from_form( $billing_info ); |
|
378 | + $billing_values = $this->_get_billing_values_from_form($billing_info); |
|
379 | 379 | |
380 | 380 | // Offsite Gateway |
381 | - if( $this->_gateway instanceof EE_Offsite_Gateway ){ |
|
381 | + if ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
382 | 382 | |
383 | 383 | $payment = $this->_gateway->set_redirection_info( |
384 | 384 | $payment, |
@@ -394,17 +394,17 @@ discard block |
||
394 | 394 | ); |
395 | 395 | $payment->save(); |
396 | 396 | // Onsite Gateway |
397 | - } elseif ( $this->_gateway instanceof EE_Onsite_Gateway ) { |
|
397 | + } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
398 | 398 | |
399 | - $payment = $this->_gateway->do_direct_payment($payment,$billing_values); |
|
399 | + $payment = $this->_gateway->do_direct_payment($payment, $billing_values); |
|
400 | 400 | $payment->save(); |
401 | 401 | |
402 | 402 | } else { |
403 | 403 | throw new EE_Error( |
404 | 404 | sprintf( |
405 | - __('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso' ), |
|
405 | + __('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso'), |
|
406 | 406 | get_class($this), |
407 | - gettype( $this->_gateway ) |
|
407 | + gettype($this->_gateway) |
|
408 | 408 | ) |
409 | 409 | ); |
410 | 410 | } |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | } |
427 | 427 | |
428 | 428 | // if there is billing info, clean it and save it now |
429 | - if( $billing_info instanceof EE_Billing_Attendee_Info_Form ){ |
|
430 | - $this->_save_billing_info_to_attendee( $billing_info, $transaction ); |
|
429 | + if ($billing_info instanceof EE_Billing_Attendee_Info_Form) { |
|
430 | + $this->_save_billing_info_to_attendee($billing_info, $transaction); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | return $payment; |
@@ -440,10 +440,10 @@ discard block |
||
440 | 440 | * @param EE_Billing_Info_Form $billing_form |
441 | 441 | * @return array |
442 | 442 | */ |
443 | - protected function _get_billing_values_from_form( $billing_form ){ |
|
444 | - if($billing_form instanceof EE_Form_Section_Proper ){ |
|
445 | - return $billing_form->input_pretty_values( true ); |
|
446 | - }else{ |
|
443 | + protected function _get_billing_values_from_form($billing_form) { |
|
444 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
445 | + return $billing_form->input_pretty_values(true); |
|
446 | + } else { |
|
447 | 447 | return NULL; |
448 | 448 | } |
449 | 449 | } |
@@ -457,13 +457,13 @@ discard block |
||
457 | 457 | * @return EE_Payment |
458 | 458 | * @throws EE_Error |
459 | 459 | */ |
460 | - public function handle_ipn($req_data,$transaction){ |
|
460 | + public function handle_ipn($req_data, $transaction) { |
|
461 | 461 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
462 | - if( ! $this->_gateway instanceof EE_Offsite_Gateway){ |
|
463 | - throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r( $this->_gateway, TRUE ))); |
|
462 | + if ( ! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
463 | + throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r($this->_gateway, TRUE))); |
|
464 | 464 | |
465 | 465 | } |
466 | - $payment = $this->_gateway->handle_payment_update( $req_data, $transaction ); |
|
466 | + $payment = $this->_gateway->handle_payment_update($req_data, $transaction); |
|
467 | 467 | return $payment; |
468 | 468 | } |
469 | 469 | |
@@ -476,22 +476,22 @@ discard block |
||
476 | 476 | * @param EE_Transaction $transaction |
477 | 477 | * @return boolean success |
478 | 478 | */ |
479 | - protected function _save_billing_info_to_attendee($billing_form, $transaction){ |
|
480 | - if( ! $transaction || ! $transaction instanceof EE_Transaction){ |
|
479 | + protected function _save_billing_info_to_attendee($billing_form, $transaction) { |
|
480 | + if ( ! $transaction || ! $transaction instanceof EE_Transaction) { |
|
481 | 481 | EE_Error::add_error(__("Cannot save billing info because no transaction was specified", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
482 | 482 | return false; |
483 | 483 | } |
484 | 484 | $primary_reg = $transaction->primary_registration(); |
485 | - if( ! $primary_reg ){ |
|
485 | + if ( ! $primary_reg) { |
|
486 | 486 | EE_Error::add_error(__("Cannot save billing info because the transaction has no primary registration", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
487 | 487 | return false; |
488 | 488 | } |
489 | 489 | $attendee = $primary_reg->attendee(); |
490 | - if( ! $attendee ){ |
|
490 | + if ( ! $attendee) { |
|
491 | 491 | EE_Error::add_error(__("Cannot save billing info because the transaction's primary registration has no attendee!", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
492 | 492 | return false; |
493 | 493 | } |
494 | - return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method() ); |
|
494 | + return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method()); |
|
495 | 495 | |
496 | 496 | } |
497 | 497 | |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | * @param array $req_data |
505 | 505 | * @return EE_Payment |
506 | 506 | */ |
507 | - protected function find_payment_for_ipn( EE_Transaction $transaction, $req_data = array() ){ |
|
507 | + protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array()) { |
|
508 | 508 | return $transaction->last_payment(); |
509 | 509 | } |
510 | 510 | |
@@ -521,8 +521,8 @@ discard block |
||
521 | 521 | * and identifies the IPN as being for this payment method (not just fo ra payment method of this type) |
522 | 522 | * @throws EE_Error |
523 | 523 | */ |
524 | - public function handle_unclaimed_ipn( $req_data = array() ){ |
|
525 | - throw new EE_Error(sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this) )); |
|
524 | + public function handle_unclaimed_ipn($req_data = array()) { |
|
525 | + throw new EE_Error(sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this))); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | * @param EE_Transaction $transaction |
539 | 539 | * @return EE_Payment |
540 | 540 | */ |
541 | - public function finalize_payment_for($transaction){ |
|
541 | + public function finalize_payment_for($transaction) { |
|
542 | 542 | return $transaction->last_payment(); |
543 | 543 | } |
544 | 544 | |
@@ -548,10 +548,10 @@ discard block |
||
548 | 548 | * Whether or not this payment method's gateway supports sending refund requests |
549 | 549 | * @return boolean |
550 | 550 | */ |
551 | - public function supports_sending_refunds(){ |
|
552 | - if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
|
551 | + public function supports_sending_refunds() { |
|
552 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
553 | 553 | return $this->_gateway->supports_sending_refunds(); |
554 | - }else{ |
|
554 | + } else { |
|
555 | 555 | return false; |
556 | 556 | } |
557 | 557 | } |
@@ -565,14 +565,14 @@ discard block |
||
565 | 565 | * @throws EE_Error |
566 | 566 | * @return EE_Payment |
567 | 567 | */ |
568 | - public function process_refund( EE_Payment $payment, $refund_info = array()){ |
|
569 | - if ( $this->_gateway && $this->_gateway instanceof EE_Gateway ) { |
|
570 | - return $this->_gateway->do_direct_refund( $payment, $refund_info ); |
|
568 | + public function process_refund(EE_Payment $payment, $refund_info = array()) { |
|
569 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
570 | + return $this->_gateway->do_direct_refund($payment, $refund_info); |
|
571 | 571 | } else { |
572 | 572 | throw new EE_Error( |
573 | 573 | sprintf( |
574 | - __( 'Payment Method Type "%s" does not support sending refund requests', 'event_espresso' ), |
|
575 | - get_class( $this ) |
|
574 | + __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'), |
|
575 | + get_class($this) |
|
576 | 576 | ) |
577 | 577 | ); |
578 | 578 | } |
@@ -586,15 +586,15 @@ discard block |
||
586 | 586 | * @return string |
587 | 587 | * @throws EE_Error |
588 | 588 | */ |
589 | - public function payment_occurs(){ |
|
590 | - if( ! $this->_gateway){ |
|
589 | + public function payment_occurs() { |
|
590 | + if ( ! $this->_gateway) { |
|
591 | 591 | return EE_PMT_Base::offline; |
592 | - }elseif($this->_gateway instanceof EE_Onsite_Gateway){ |
|
592 | + }elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
593 | 593 | return EE_PMT_Base::onsite; |
594 | - }elseif($this->_gateway instanceof EE_Offsite_Gateway){ |
|
594 | + }elseif ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
595 | 595 | return EE_PMT_Base::offsite; |
596 | - }else{ |
|
597 | - throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"),get_class($this))); |
|
596 | + } else { |
|
597 | + throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"), get_class($this))); |
|
598 | 598 | } |
599 | 599 | } |
600 | 600 | |
@@ -607,8 +607,8 @@ discard block |
||
607 | 607 | * @param EE_Payment $payment |
608 | 608 | * @return string |
609 | 609 | */ |
610 | - public function payment_overview_content(EE_Payment $payment){ |
|
611 | - return EEH_Template::display_template(EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php', array('payment_method'=>$this->_pm_instance,'payment'=>$payment) , true); |
|
610 | + public function payment_overview_content(EE_Payment $payment) { |
|
611 | + return EEH_Template::display_template(EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php', array('payment_method'=>$this->_pm_instance, 'payment'=>$payment), true); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | * @type array $template_args any arguments you want passed to the template file while rendering. |
622 | 622 | * Keys will be variable names and values with be their values. |
623 | 623 | */ |
624 | - public function help_tabs_config(){ |
|
624 | + public function help_tabs_config() { |
|
625 | 625 | return array(); |
626 | 626 | } |
627 | 627 | |
@@ -632,9 +632,9 @@ discard block |
||
632 | 632 | * the payment method's table's PMT_type column) |
633 | 633 | * @return string |
634 | 634 | */ |
635 | - public function system_name(){ |
|
635 | + public function system_name() { |
|
636 | 636 | $classname = get_class($this); |
637 | - return str_replace("EE_PMT_",'',$classname); |
|
637 | + return str_replace("EE_PMT_", '', $classname); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | * A pretty i18n version of the PMT name |
644 | 644 | * @return string |
645 | 645 | */ |
646 | - public function pretty_name(){ |
|
646 | + public function pretty_name() { |
|
647 | 647 | return $this->_pretty_name; |
648 | 648 | } |
649 | 649 | |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | * Gets the default absolute URL to the payment method type's button |
654 | 654 | * @return string |
655 | 655 | */ |
656 | - public function default_button_url(){ |
|
656 | + public function default_button_url() { |
|
657 | 657 | return $this->_default_button_url; |
658 | 658 | } |
659 | 659 | |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | * Gets the gateway used by this payment method (if any) |
664 | 664 | * @return EE_Gateway |
665 | 665 | */ |
666 | - public function get_gateway(){ |
|
666 | + public function get_gateway() { |
|
667 | 667 | return $this->_gateway; |
668 | 668 | } |
669 | 669 | |
@@ -672,8 +672,8 @@ discard block |
||
672 | 672 | /** |
673 | 673 | * @return string html for the link to a help tab |
674 | 674 | */ |
675 | - public function get_help_tab_link(){ |
|
676 | - return EEH_Template::get_help_tab_link( $this->get_help_tab_name() ); |
|
675 | + public function get_help_tab_link() { |
|
676 | + return EEH_Template::get_help_tab_link($this->get_help_tab_name()); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | |
@@ -682,8 +682,8 @@ discard block |
||
682 | 682 | * Returns the name of the help tab for this PMT |
683 | 683 | * @return string |
684 | 684 | */ |
685 | - public function get_help_tab_name(){ |
|
686 | - return 'ee_' . strtolower( $this->system_name() ) . '_help_tab'; |
|
685 | + public function get_help_tab_name() { |
|
686 | + return 'ee_'.strtolower($this->system_name()).'_help_tab'; |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | /** |
@@ -691,8 +691,8 @@ discard block |
||
691 | 691 | * this PMT by an admin |
692 | 692 | * @return string |
693 | 693 | */ |
694 | - public function cap_name(){ |
|
695 | - return 'ee_payment_method_' . strtolower( $this->system_name() ); |
|
694 | + public function cap_name() { |
|
695 | + return 'ee_payment_method_'.strtolower($this->system_name()); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | /** |
@@ -704,9 +704,9 @@ discard block |
||
704 | 704 | * @param EE_Payment $payment |
705 | 705 | * @return void |
706 | 706 | */ |
707 | - public function update_txn_based_on_payment( $payment ){ |
|
708 | - if( $this->_gateway instanceof EE_Gateway ){ |
|
709 | - $this->_gateway->update_txn_based_on_payment( $payment ); |
|
707 | + public function update_txn_based_on_payment($payment) { |
|
708 | + if ($this->_gateway instanceof EE_Gateway) { |
|
709 | + $this->_gateway->update_txn_based_on_payment($payment); |
|
710 | 710 | } |
711 | 711 | } |
712 | 712 |