@@ -11,39 +11,39 @@ |
||
11 | 11 | class EEM_Question_Option extends EEM_Soft_Delete_Base |
12 | 12 | { |
13 | 13 | |
14 | - // private instance of the Attendee object |
|
15 | - protected static $_instance = null; |
|
14 | + // private instance of the Attendee object |
|
15 | + protected static $_instance = null; |
|
16 | 16 | |
17 | - protected function __construct($timezone = null) |
|
18 | - { |
|
19 | - $this->singular_item = __('Question Option', 'event_espresso'); |
|
20 | - $this->plural_item = __('Question Options', 'event_espresso'); |
|
17 | + protected function __construct($timezone = null) |
|
18 | + { |
|
19 | + $this->singular_item = __('Question Option', 'event_espresso'); |
|
20 | + $this->plural_item = __('Question Options', 'event_espresso'); |
|
21 | 21 | |
22 | - $this->_tables = array( |
|
23 | - 'Question_Option'=>new EE_Primary_Table('esp_question_option', 'QSO_ID') |
|
24 | - ); |
|
25 | - $this->_fields = array( |
|
26 | - 'Question_Option'=>array( |
|
27 | - 'QSO_ID'=>new EE_Primary_Key_Int_Field('QSO_ID', __('Question Option ID', 'event_espresso')), |
|
28 | - 'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'), |
|
29 | - 'QSO_value'=>new EE_Plain_Text_Field('QSO_value', __("Question Option Value", "event_espresso"), false, ''), |
|
30 | - 'QSO_desc'=>new EE_Post_Content_Field('QSO_desc', __('Question Option Description', 'event_espresso'), false, ''), |
|
31 | - 'QSO_order' => new EE_Integer_Field('QSO_order', __('Question Option Order', 'event_espresso'), false, 0), |
|
32 | - 'QSO_system'=>new EE_Plain_Text_Field('QSO_system', __('Internal string ID for question option', 'event_espresso'), true, null), |
|
33 | - 'QSO_deleted'=>new EE_Trashed_Flag_Field('QSO_deleted', __('Flag indicating Option was trashed', 'event_espresso'), false, false) |
|
34 | - ) |
|
35 | - ); |
|
36 | - $this->_model_relations = array( |
|
37 | - 'Question'=>new EE_Belongs_To_Relation() |
|
38 | - ); |
|
22 | + $this->_tables = array( |
|
23 | + 'Question_Option'=>new EE_Primary_Table('esp_question_option', 'QSO_ID') |
|
24 | + ); |
|
25 | + $this->_fields = array( |
|
26 | + 'Question_Option'=>array( |
|
27 | + 'QSO_ID'=>new EE_Primary_Key_Int_Field('QSO_ID', __('Question Option ID', 'event_espresso')), |
|
28 | + 'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'), |
|
29 | + 'QSO_value'=>new EE_Plain_Text_Field('QSO_value', __("Question Option Value", "event_espresso"), false, ''), |
|
30 | + 'QSO_desc'=>new EE_Post_Content_Field('QSO_desc', __('Question Option Description', 'event_espresso'), false, ''), |
|
31 | + 'QSO_order' => new EE_Integer_Field('QSO_order', __('Question Option Order', 'event_espresso'), false, 0), |
|
32 | + 'QSO_system'=>new EE_Plain_Text_Field('QSO_system', __('Internal string ID for question option', 'event_espresso'), true, null), |
|
33 | + 'QSO_deleted'=>new EE_Trashed_Flag_Field('QSO_deleted', __('Flag indicating Option was trashed', 'event_espresso'), false, false) |
|
34 | + ) |
|
35 | + ); |
|
36 | + $this->_model_relations = array( |
|
37 | + 'Question'=>new EE_Belongs_To_Relation() |
|
38 | + ); |
|
39 | 39 | |
40 | - $this->_model_chain_to_wp_user = 'Question'; |
|
41 | - // this model is generally available for reading |
|
42 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
43 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSO_system'); |
|
44 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSO_system'); |
|
45 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSO_system'); |
|
46 | - $this->_caps_slug = 'questions'; |
|
47 | - parent::__construct($timezone); |
|
48 | - } |
|
40 | + $this->_model_chain_to_wp_user = 'Question'; |
|
41 | + // this model is generally available for reading |
|
42 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
43 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSO_system'); |
|
44 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSO_system'); |
|
45 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSO_system'); |
|
46 | + $this->_caps_slug = 'questions'; |
|
47 | + parent::__construct($timezone); |
|
48 | + } |
|
49 | 49 | } |
@@ -39,10 +39,10 @@ |
||
39 | 39 | |
40 | 40 | $this->_model_chain_to_wp_user = 'Question'; |
41 | 41 | // this model is generally available for reading |
42 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
43 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSO_system'); |
|
44 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSO_system'); |
|
45 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSO_system'); |
|
42 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
43 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('QSO_system'); |
|
44 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('QSO_system'); |
|
45 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('QSO_system'); |
|
46 | 46 | $this->_caps_slug = 'questions'; |
47 | 47 | parent::__construct($timezone); |
48 | 48 | } |
@@ -9,142 +9,142 @@ |
||
9 | 9 | class EEM_Answer extends EEM_Base |
10 | 10 | { |
11 | 11 | |
12 | - /** |
|
13 | - * private instance of the EEM_Answer object |
|
14 | - * @type EEM_Answer |
|
15 | - */ |
|
16 | - protected static $_instance = null; |
|
12 | + /** |
|
13 | + * private instance of the EEM_Answer object |
|
14 | + * @type EEM_Answer |
|
15 | + */ |
|
16 | + protected static $_instance = null; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Mapping from system question ids to attendee field names |
|
20 | - * @type array |
|
21 | - * @deprecated since version 4.8.8 |
|
22 | - */ |
|
23 | - protected $_question_id_to_att_field_map = array( |
|
24 | - EEM_Attendee::fname_question_id => 'ATT_fname', |
|
25 | - EEM_Attendee::lname_question_id => 'ATT_lname', |
|
26 | - EEM_Attendee::email_question_id => 'ATT_email', |
|
27 | - EEM_Attendee::address_question_id => 'ATT_address', |
|
28 | - EEM_Attendee::address2_question_id => 'ATT_address2', |
|
29 | - EEM_Attendee::city_question_id => 'ATT_city', |
|
30 | - EEM_Attendee::state_question_id => 'STA_ID', |
|
31 | - EEM_Attendee::country_question_id => 'CNT_ISO', |
|
32 | - EEM_Attendee::zip_question_id => 'ATT_zip', |
|
33 | - EEM_Attendee::phone_question_id => 'ATT_phone' |
|
34 | - ); |
|
18 | + /** |
|
19 | + * Mapping from system question ids to attendee field names |
|
20 | + * @type array |
|
21 | + * @deprecated since version 4.8.8 |
|
22 | + */ |
|
23 | + protected $_question_id_to_att_field_map = array( |
|
24 | + EEM_Attendee::fname_question_id => 'ATT_fname', |
|
25 | + EEM_Attendee::lname_question_id => 'ATT_lname', |
|
26 | + EEM_Attendee::email_question_id => 'ATT_email', |
|
27 | + EEM_Attendee::address_question_id => 'ATT_address', |
|
28 | + EEM_Attendee::address2_question_id => 'ATT_address2', |
|
29 | + EEM_Attendee::city_question_id => 'ATT_city', |
|
30 | + EEM_Attendee::state_question_id => 'STA_ID', |
|
31 | + EEM_Attendee::country_question_id => 'CNT_ISO', |
|
32 | + EEM_Attendee::zip_question_id => 'ATT_zip', |
|
33 | + EEM_Attendee::phone_question_id => 'ATT_phone' |
|
34 | + ); |
|
35 | 35 | |
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * constructor |
|
40 | - */ |
|
41 | - protected function __construct($timezone = null) |
|
42 | - { |
|
43 | - $this->singular_item = __('Answer', 'event_espresso'); |
|
44 | - $this->plural_item = __('Answers', 'event_espresso'); |
|
45 | - $this->_tables = array( |
|
46 | - 'Answer'=> new EE_Primary_Table('esp_answer', 'ANS_ID') |
|
47 | - ); |
|
48 | - $this->_fields = array( |
|
49 | - 'Answer'=>array( |
|
50 | - 'ANS_ID'=> new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID', 'event_espresso')), |
|
51 | - 'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'), |
|
52 | - 'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'), |
|
53 | - 'ANS_value'=>new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value', 'event_espresso'), false, '') |
|
54 | - )); |
|
55 | - $this->_model_relations = array( |
|
56 | - 'Registration'=>new EE_Belongs_To_Relation(), |
|
57 | - 'Question'=>new EE_Belongs_To_Relation() |
|
58 | - ); |
|
59 | - $this->_model_chain_to_wp_user = 'Registration.Event'; |
|
60 | - $this->_caps_slug = 'registrations'; |
|
61 | - parent::__construct($timezone); |
|
62 | - } |
|
38 | + /** |
|
39 | + * constructor |
|
40 | + */ |
|
41 | + protected function __construct($timezone = null) |
|
42 | + { |
|
43 | + $this->singular_item = __('Answer', 'event_espresso'); |
|
44 | + $this->plural_item = __('Answers', 'event_espresso'); |
|
45 | + $this->_tables = array( |
|
46 | + 'Answer'=> new EE_Primary_Table('esp_answer', 'ANS_ID') |
|
47 | + ); |
|
48 | + $this->_fields = array( |
|
49 | + 'Answer'=>array( |
|
50 | + 'ANS_ID'=> new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID', 'event_espresso')), |
|
51 | + 'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'), |
|
52 | + 'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'), |
|
53 | + 'ANS_value'=>new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value', 'event_espresso'), false, '') |
|
54 | + )); |
|
55 | + $this->_model_relations = array( |
|
56 | + 'Registration'=>new EE_Belongs_To_Relation(), |
|
57 | + 'Question'=>new EE_Belongs_To_Relation() |
|
58 | + ); |
|
59 | + $this->_model_chain_to_wp_user = 'Registration.Event'; |
|
60 | + $this->_caps_slug = 'registrations'; |
|
61 | + parent::__construct($timezone); |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * Gets the string answer to the question for this registration (it could either be stored |
|
68 | - * on the attendee or in the answer table. This function finds its value regardless) |
|
69 | - * @param EE_Registration $registration |
|
70 | - * @param int $question_id |
|
71 | - * @param boolean $pretty_answer whether to call 'pretty_value' or just 'value' |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function get_answer_value_to_question(EE_Registration $registration, $question_id = null, $pretty_answer = false) |
|
75 | - { |
|
76 | - $value = $this->get_attendee_property_answer_value($registration, $question_id, $pretty_answer); |
|
77 | - if ($value === null) { |
|
78 | - $answer_obj = $this->get_registration_question_answer_object($registration, $question_id); |
|
79 | - if ($answer_obj instanceof EE_Answer) { |
|
80 | - if ($pretty_answer) { |
|
81 | - $value = $answer_obj->pretty_value(); |
|
82 | - } else { |
|
83 | - $value = $answer_obj->value(); |
|
84 | - } |
|
85 | - } |
|
86 | - } |
|
87 | - return apply_filters('FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id); |
|
88 | - } |
|
66 | + /** |
|
67 | + * Gets the string answer to the question for this registration (it could either be stored |
|
68 | + * on the attendee or in the answer table. This function finds its value regardless) |
|
69 | + * @param EE_Registration $registration |
|
70 | + * @param int $question_id |
|
71 | + * @param boolean $pretty_answer whether to call 'pretty_value' or just 'value' |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function get_answer_value_to_question(EE_Registration $registration, $question_id = null, $pretty_answer = false) |
|
75 | + { |
|
76 | + $value = $this->get_attendee_property_answer_value($registration, $question_id, $pretty_answer); |
|
77 | + if ($value === null) { |
|
78 | + $answer_obj = $this->get_registration_question_answer_object($registration, $question_id); |
|
79 | + if ($answer_obj instanceof EE_Answer) { |
|
80 | + if ($pretty_answer) { |
|
81 | + $value = $answer_obj->pretty_value(); |
|
82 | + } else { |
|
83 | + $value = $answer_obj->value(); |
|
84 | + } |
|
85 | + } |
|
86 | + } |
|
87 | + return apply_filters('FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id); |
|
88 | + } |
|
89 | 89 | |
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * Gets the EE_Answer object for the question for this registration (if it exists) |
|
94 | - * @param EE_Registration $registration |
|
95 | - * @param int $question_id |
|
96 | - * @return EE_Answer |
|
97 | - */ |
|
98 | - public function get_registration_question_answer_object(EE_Registration $registration, $question_id = null) |
|
99 | - { |
|
100 | - $answer_obj = $this->get_one(array( array( 'QST_ID'=>$question_id, 'REG_ID'=>$registration->ID() ))); |
|
101 | - return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id); |
|
102 | - } |
|
92 | + /** |
|
93 | + * Gets the EE_Answer object for the question for this registration (if it exists) |
|
94 | + * @param EE_Registration $registration |
|
95 | + * @param int $question_id |
|
96 | + * @return EE_Answer |
|
97 | + */ |
|
98 | + public function get_registration_question_answer_object(EE_Registration $registration, $question_id = null) |
|
99 | + { |
|
100 | + $answer_obj = $this->get_one(array( array( 'QST_ID'=>$question_id, 'REG_ID'=>$registration->ID() ))); |
|
101 | + return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id); |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * Gets the string answer to the question for this registration's attendee |
|
108 | - * @param EE_Registration $registration |
|
109 | - * @param int|string $question_system_id if an INT this is understood to be the question's ID; if a string then it should be its QST_system value. |
|
110 | - * Passing in the QST_system value is more efficient |
|
111 | - * @param boolean $pretty_answer |
|
112 | - * @return string|null (if the registration has no attendee, or the question_system_id is not a QST_ID or QST_system for |
|
113 | - * a question corresponding to an attendee field, returns null) |
|
114 | - */ |
|
115 | - public function get_attendee_property_answer_value(EE_Registration $registration, $question_system_id = null, $pretty_answer = false) |
|
116 | - { |
|
117 | - $field_name = null; |
|
118 | - $value = null; |
|
119 | - // backward compat: we still want to find the question's ID |
|
120 | - if (is_numeric($question_system_id)) { |
|
121 | - // find this question's QST_system value |
|
122 | - $question_id = $question_system_id; |
|
123 | - $question_system_id = EEM_Question::instance()->get_var(array( array( 'QST_ID' => $question_system_id ) ), 'QST_system'); |
|
124 | - } else { |
|
125 | - $question_id = (int) EEM_Question::instance()->get_var(array( array( 'QST_system' => $question_system_id ) ), 'QST_ID'); |
|
126 | - } |
|
127 | - // only bother checking if the registration has an attendee |
|
128 | - if ($registration->attendee() instanceof EE_Attendee) { |
|
129 | - $field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question($question_system_id); |
|
130 | - if ($field_name) { |
|
131 | - if ($pretty_answer) { |
|
132 | - if ($field_name === 'STA_ID') { |
|
133 | - $state = $registration->attendee()->state_obj(); |
|
134 | - $value = $state instanceof EE_State ? $state->name() : sprintf(__('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID()); |
|
135 | - } elseif ($field_name === 'CNT_ISO') { |
|
136 | - $country = $registration->attendee()->country_obj(); |
|
137 | - $value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"), $registration->attendee()->country_ID()); |
|
138 | - } else { |
|
139 | - $value = $registration->attendee()->get_pretty($field_name); |
|
140 | - } |
|
141 | - // if field name is blank, leave the value as null too |
|
142 | - } else { |
|
143 | - $value = $registration->attendee()->get($field_name); |
|
144 | - } |
|
145 | - } |
|
146 | - // if no field was found, leave value blank |
|
147 | - } |
|
148 | - return apply_filters('FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id); |
|
149 | - } |
|
106 | + /** |
|
107 | + * Gets the string answer to the question for this registration's attendee |
|
108 | + * @param EE_Registration $registration |
|
109 | + * @param int|string $question_system_id if an INT this is understood to be the question's ID; if a string then it should be its QST_system value. |
|
110 | + * Passing in the QST_system value is more efficient |
|
111 | + * @param boolean $pretty_answer |
|
112 | + * @return string|null (if the registration has no attendee, or the question_system_id is not a QST_ID or QST_system for |
|
113 | + * a question corresponding to an attendee field, returns null) |
|
114 | + */ |
|
115 | + public function get_attendee_property_answer_value(EE_Registration $registration, $question_system_id = null, $pretty_answer = false) |
|
116 | + { |
|
117 | + $field_name = null; |
|
118 | + $value = null; |
|
119 | + // backward compat: we still want to find the question's ID |
|
120 | + if (is_numeric($question_system_id)) { |
|
121 | + // find this question's QST_system value |
|
122 | + $question_id = $question_system_id; |
|
123 | + $question_system_id = EEM_Question::instance()->get_var(array( array( 'QST_ID' => $question_system_id ) ), 'QST_system'); |
|
124 | + } else { |
|
125 | + $question_id = (int) EEM_Question::instance()->get_var(array( array( 'QST_system' => $question_system_id ) ), 'QST_ID'); |
|
126 | + } |
|
127 | + // only bother checking if the registration has an attendee |
|
128 | + if ($registration->attendee() instanceof EE_Attendee) { |
|
129 | + $field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question($question_system_id); |
|
130 | + if ($field_name) { |
|
131 | + if ($pretty_answer) { |
|
132 | + if ($field_name === 'STA_ID') { |
|
133 | + $state = $registration->attendee()->state_obj(); |
|
134 | + $value = $state instanceof EE_State ? $state->name() : sprintf(__('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID()); |
|
135 | + } elseif ($field_name === 'CNT_ISO') { |
|
136 | + $country = $registration->attendee()->country_obj(); |
|
137 | + $value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"), $registration->attendee()->country_ID()); |
|
138 | + } else { |
|
139 | + $value = $registration->attendee()->get_pretty($field_name); |
|
140 | + } |
|
141 | + // if field name is blank, leave the value as null too |
|
142 | + } else { |
|
143 | + $value = $registration->attendee()->get($field_name); |
|
144 | + } |
|
145 | + } |
|
146 | + // if no field was found, leave value blank |
|
147 | + } |
|
148 | + return apply_filters('FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id); |
|
149 | + } |
|
150 | 150 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function get_registration_question_answer_object(EE_Registration $registration, $question_id = null) |
99 | 99 | { |
100 | - $answer_obj = $this->get_one(array( array( 'QST_ID'=>$question_id, 'REG_ID'=>$registration->ID() ))); |
|
100 | + $answer_obj = $this->get_one(array(array('QST_ID'=>$question_id, 'REG_ID'=>$registration->ID()))); |
|
101 | 101 | return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id); |
102 | 102 | } |
103 | 103 | |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | if (is_numeric($question_system_id)) { |
121 | 121 | // find this question's QST_system value |
122 | 122 | $question_id = $question_system_id; |
123 | - $question_system_id = EEM_Question::instance()->get_var(array( array( 'QST_ID' => $question_system_id ) ), 'QST_system'); |
|
123 | + $question_system_id = EEM_Question::instance()->get_var(array(array('QST_ID' => $question_system_id)), 'QST_system'); |
|
124 | 124 | } else { |
125 | - $question_id = (int) EEM_Question::instance()->get_var(array( array( 'QST_system' => $question_system_id ) ), 'QST_ID'); |
|
125 | + $question_id = (int) EEM_Question::instance()->get_var(array(array('QST_system' => $question_system_id)), 'QST_ID'); |
|
126 | 126 | } |
127 | 127 | // only bother checking if the registration has an attendee |
128 | 128 | if ($registration->attendee() instanceof EE_Attendee) { |
@@ -13,45 +13,45 @@ |
||
13 | 13 | */ |
14 | 14 | class EEM_Message_Template extends EEM_Base |
15 | 15 | { |
16 | - // private instance of the EEM_Message_Template object |
|
17 | - protected static $_instance = null; |
|
16 | + // private instance of the EEM_Message_Template object |
|
17 | + protected static $_instance = null; |
|
18 | 18 | |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * private constructor to prevent direct creation |
|
23 | - * |
|
24 | - * @Constructor |
|
25 | - * @access protected |
|
26 | - * @param string $timezone |
|
27 | - * @throws \EE_Error |
|
28 | - */ |
|
29 | - protected function __construct($timezone = null) |
|
30 | - { |
|
31 | - $this->singular_item = __('Message Template', 'event_espresso'); |
|
32 | - $this->plural_item = __('Message Templates', 'event_espresso'); |
|
21 | + /** |
|
22 | + * private constructor to prevent direct creation |
|
23 | + * |
|
24 | + * @Constructor |
|
25 | + * @access protected |
|
26 | + * @param string $timezone |
|
27 | + * @throws \EE_Error |
|
28 | + */ |
|
29 | + protected function __construct($timezone = null) |
|
30 | + { |
|
31 | + $this->singular_item = __('Message Template', 'event_espresso'); |
|
32 | + $this->plural_item = __('Message Templates', 'event_espresso'); |
|
33 | 33 | |
34 | - $this->_tables = array( |
|
35 | - 'Message_Template' => new EE_Primary_Table('esp_message_template', 'MTP_ID') |
|
36 | - ); |
|
37 | - $this->_fields = array( |
|
38 | - 'Message_Template'=> array( |
|
39 | - 'MTP_ID'=> new EE_Primary_Key_Int_Field('MTP_ID', __('Message Template ID', 'event_espresso')), |
|
40 | - 'GRP_ID' => new EE_Foreign_Key_Int_Field('GRP_ID', __('Message Template Group ID', 'event_espresso'), false, 0, 'Message_Template_Group'), |
|
41 | - 'MTP_template_field'=>new EE_Plain_Text_Field('MTP_template_field', __('Field Name for this Template', 'event_espresso'), false, 'default'), |
|
42 | - 'MTP_context'=>new EE_Plain_Text_Field('MTP_context', __('Message Type Context for this field', 'event_espresso'), false, 'admin'), |
|
43 | - 'MTP_content'=>new EE_Serialized_Text_Field('MTP_content', __('The field content for the template', 'event_espresso'), false, ''), |
|
44 | - ) |
|
45 | - ); |
|
34 | + $this->_tables = array( |
|
35 | + 'Message_Template' => new EE_Primary_Table('esp_message_template', 'MTP_ID') |
|
36 | + ); |
|
37 | + $this->_fields = array( |
|
38 | + 'Message_Template'=> array( |
|
39 | + 'MTP_ID'=> new EE_Primary_Key_Int_Field('MTP_ID', __('Message Template ID', 'event_espresso')), |
|
40 | + 'GRP_ID' => new EE_Foreign_Key_Int_Field('GRP_ID', __('Message Template Group ID', 'event_espresso'), false, 0, 'Message_Template_Group'), |
|
41 | + 'MTP_template_field'=>new EE_Plain_Text_Field('MTP_template_field', __('Field Name for this Template', 'event_espresso'), false, 'default'), |
|
42 | + 'MTP_context'=>new EE_Plain_Text_Field('MTP_context', __('Message Type Context for this field', 'event_espresso'), false, 'admin'), |
|
43 | + 'MTP_content'=>new EE_Serialized_Text_Field('MTP_content', __('The field content for the template', 'event_espresso'), false, ''), |
|
44 | + ) |
|
45 | + ); |
|
46 | 46 | |
47 | - $this->_model_relations = array( |
|
48 | - 'Message_Template_Group' => new EE_Belongs_To_Relation() |
|
49 | - ); |
|
50 | - $this->_model_chain_to_wp_user = 'Message_Template_Group'; |
|
51 | - foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
52 | - $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global('Message_Template_Group.MTP_is_global'); |
|
53 | - } |
|
54 | - $this->_caps_slug = 'messages'; |
|
55 | - parent::__construct($timezone); |
|
56 | - } |
|
47 | + $this->_model_relations = array( |
|
48 | + 'Message_Template_Group' => new EE_Belongs_To_Relation() |
|
49 | + ); |
|
50 | + $this->_model_chain_to_wp_user = 'Message_Template_Group'; |
|
51 | + foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
52 | + $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global('Message_Template_Group.MTP_is_global'); |
|
53 | + } |
|
54 | + $this->_caps_slug = 'messages'; |
|
55 | + parent::__construct($timezone); |
|
56 | + } |
|
57 | 57 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | ); |
50 | 50 | $this->_model_chain_to_wp_user = 'Message_Template_Group'; |
51 | 51 | foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
52 | - $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global('Message_Template_Group.MTP_is_global'); |
|
52 | + $this->_cap_restriction_generators[$context] = new EE_Restriction_Generator_Global('Message_Template_Group.MTP_is_global'); |
|
53 | 53 | } |
54 | 54 | $this->_caps_slug = 'messages'; |
55 | 55 | parent::__construct($timezone); |
@@ -11,232 +11,232 @@ |
||
11 | 11 | class EEM_Payment extends EEM_Base implements EEMI_Payment |
12 | 12 | { |
13 | 13 | |
14 | - // private instance of the Payment object |
|
15 | - protected static $_instance = null; |
|
14 | + // private instance of the Payment object |
|
15 | + protected static $_instance = null; |
|
16 | 16 | |
17 | 17 | |
18 | 18 | |
19 | 19 | /** |
20 | - * Status id in esp_status table that represents an approved payment |
|
21 | - */ |
|
22 | - const status_id_approved = 'PAP'; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * Status id in esp_status table that represents a pending payment |
|
27 | - */ |
|
28 | - const status_id_pending = 'PPN'; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * Status id in esp_status table that represents a cancelled payment (eg, the |
|
33 | - * user went to PayPal, but on the paypal site decided to cancel the payment) |
|
34 | - */ |
|
35 | - const status_id_cancelled = 'PCN'; |
|
36 | - |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * Status id in esp_status table that represents a payment that was declined by |
|
41 | - * the gateway. (eg, the user's card had no funds, or it was a fraudulent card) |
|
42 | - */ |
|
43 | - const status_id_declined = 'PDC'; |
|
44 | - |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * Status id in esp_status table that represents a payment that failed for technical reasons. |
|
49 | - * (Eg, there was some error in communicating with the payment gateway.) |
|
50 | - */ |
|
51 | - const status_id_failed = 'PFL'; |
|
52 | - |
|
53 | - /** |
|
54 | - * private constructor to prevent direct creation |
|
55 | - * @Constructor |
|
56 | - * @access protected |
|
57 | - * @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) |
|
58 | - * @return EEM_Payment |
|
59 | - */ |
|
60 | - protected function __construct($timezone) |
|
61 | - { |
|
62 | - |
|
63 | - $this->singular_item = __('Payment', 'event_espresso'); |
|
64 | - $this->plural_item = __('Payments', 'event_espresso'); |
|
65 | - |
|
66 | - $this->_tables = array( |
|
67 | - 'Payment'=>new EE_Primary_Table('esp_payment', 'PAY_ID') |
|
68 | - ); |
|
69 | - $this->_fields = array( |
|
70 | - 'Payment'=>array( |
|
71 | - 'PAY_ID'=>new EE_Primary_Key_Int_Field('PAY_ID', __('Payment ID', 'event_espresso')), |
|
72 | - 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'), |
|
73 | - 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Payment::status_id_failed, 'Status'), |
|
74 | - 'PAY_timestamp'=> new EE_Datetime_Field('PAY_timestamp', __('Timestamp of when payment was attempted', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
75 | - 'PAY_source'=>new EE_All_Caps_Text_Field('PAY_source', __('User-friendly description of payment', 'event_espresso'), false, 'CART'), |
|
76 | - 'PAY_amount'=>new EE_Money_Field('PAY_amount', __('Amount Payment should be for', 'event_espresso'), false, 0), |
|
77 | - 'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __("Payment Method ID", 'event_espresso'), false, null, 'Payment_Method'), |
|
78 | - 'PAY_gateway_response'=>new EE_Plain_Text_Field('PAY_gateway_response', __('Response from Gateway about the payment', 'event_espresso'), false, ''), |
|
79 | - 'PAY_txn_id_chq_nmbr'=>new EE_Plain_Text_Field('PAY_txn_id_chq_nmbr', __('Gateway Transaction ID or Cheque Number', 'event_espresso'), true, ''), |
|
80 | - 'PAY_po_number'=>new EE_Plain_Text_Field('PAY_po_number', __('Purchase or Sales Number', 'event_espresso'), true, ''), |
|
81 | - 'PAY_extra_accntng'=>new EE_Simple_HTML_Field('PAY_extra_accntng', __('Extra Account Info', 'event_espresso'), true, ''), |
|
82 | - 'PAY_details'=>new EE_Serialized_Text_Field('PAY_details', __('Full Gateway response about payment', 'event_espresso'), true, ''), |
|
83 | - 'PAY_redirect_url'=>new EE_Plain_Text_Field('PAY_redirect_url', __("Redirect URL", 'event_espresso'), true), |
|
84 | - 'PAY_redirect_args'=>new EE_Serialized_Text_Field('PAY_redirect_args', __("Key-Value POST vars to send along with redirect", 'event_espresso'), true) |
|
85 | - ) |
|
86 | - ); |
|
87 | - $this->_model_relations = array( |
|
88 | - 'Transaction'=> new EE_Belongs_To_Relation(), |
|
89 | - 'Status'=> new EE_Belongs_To_Relation(), |
|
90 | - 'Payment_Method'=>new EE_Belongs_To_Relation(), |
|
91 | - 'Registration_Payment' => new EE_Has_Many_Relation(), |
|
92 | - 'Registration' => new EE_HABTM_Relation('Registration_Payment'), |
|
93 | - ); |
|
94 | - $this->_model_chain_to_wp_user = 'Payment_Method'; |
|
95 | - $this->_caps_slug = 'transactions'; |
|
96 | - parent::__construct($timezone); |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * Gets the payment by the gateway server's unique ID. Eg, the unique ID PayPal assigned |
|
104 | - * to the payment. This is handy for verifying an IPN hasn't already been processed. |
|
105 | - * @param string $PAY_txn_id_chq_nmbr |
|
106 | - * @return EE_Payment |
|
107 | - */ |
|
108 | - public function get_payment_by_txn_id_chq_nmbr($PAY_txn_id_chq_nmbr) |
|
109 | - { |
|
110 | - return $this->get_one(array(array('PAY_txn_id_chq_nmbr'=>$PAY_txn_id_chq_nmbr))); |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * retrieve all payments from db for a particular transaction, optionally with |
|
118 | - * a particular status |
|
119 | - * |
|
120 | - * @access public |
|
121 | - * @param $TXN_ID |
|
122 | - * @param string $status_of_payment one of EEM_Payment::status_id_*, like 'PAP','PCN',etc. If none is provided, gets payments with any status |
|
123 | - * @return EE_Payment[] |
|
124 | - */ |
|
125 | - public function get_payments_for_transaction($TXN_ID = false, $status_of_payment = null) |
|
126 | - { |
|
127 | - // all payments for a TXN ordered chronologically |
|
128 | - $query_params = array( array( 'TXN_ID' => $TXN_ID ), 'order_by' => array( 'PAY_timestamp' => 'ASC' )); |
|
129 | - // if provided with a status, search specifically for that status. Otherwise get them all |
|
130 | - if ($status_of_payment) { |
|
131 | - $query_params[0]['STS_ID'] = $status_of_payment; |
|
132 | - } |
|
133 | - // retrieve payments |
|
134 | - return $this->get_all($query_params); |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * Only gets payments which have been approved |
|
141 | - * @param int $TXN_ID |
|
142 | - * @return EE_Payment[] |
|
143 | - */ |
|
144 | - public function get_approved_payments_for_transaction($TXN_ID = 0) |
|
145 | - { |
|
146 | - return $this->get_payments_for_transaction($TXN_ID, EEM_Payment::status_id_approved); |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * retrieve all payments from db between two dates, |
|
155 | - * |
|
156 | - * @param string $start_date incoming start date. If empty the beginning of today is used. |
|
157 | - * @param string $end_date incoming end date. If empty the end of today is used. |
|
158 | - * @param string $format If you include $start_date or $end_date then you must include the format string |
|
159 | - * for the format your date is in. |
|
160 | - * @param string $timezone If your range is in a different timezone then the current setting on this |
|
161 | - * WordPress install, then include it here. |
|
162 | - * @throws EE_Error |
|
163 | - * |
|
164 | - * @return EE_Payment[] |
|
165 | - */ |
|
166 | - public function get_payments_made_between_dates($start_date = '', $end_date = '', $format = '', $timezone = '') |
|
167 | - { |
|
168 | - $timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone; |
|
169 | - // if $start_date or $end date, verify $format is included. |
|
170 | - if (( ! empty($start_date) || ! empty($end_date) ) && empty($format)) { |
|
171 | - throw new EE_Error(__('You included a start date and/or a end date for this method but did not include a format string. The format string is needed for setting up the query', 'event_espresso')); |
|
172 | - } |
|
173 | - $now = new DateTime('now'); |
|
174 | - // setup timezone objects once |
|
175 | - $modelDateTimeZone = new DateTimeZone($this->_timezone); |
|
176 | - $passedDateTimeZone = new DateTimeZone($timezone); |
|
177 | - // setup start date |
|
178 | - $start_date = ! empty($start_date) ? date_create_from_format($format, $start_date, $passedDateTimeZone) : $now; |
|
179 | - EEH_DTT_Helper::setTimezone($start_date, $modelDateTimeZone); |
|
180 | - $start_date = $start_date->format('Y-m-d') . ' 00:00:00'; |
|
181 | - $start_date = strtotime($start_date); |
|
182 | - // setup end date |
|
183 | - $end_date = ! empty($end_date) ? date_create_from_format($format, $end_date, $passedDateTimeZone) : $now; |
|
184 | - EEH_DTT_Helper::setTimezone($end_date, $modelDateTimeZone); |
|
185 | - $end_date = $end_date->format('Y-m-d') . ' 23:59:59'; |
|
186 | - $end_date = strtotime($end_date); |
|
187 | - |
|
188 | - // make sure our start date is the lowest value and vice versa |
|
189 | - $start = min($start_date, $end_date); |
|
190 | - $end = max($start_date, $end_date); |
|
191 | - |
|
192 | - // yes we generated the date and time string in utc but we WANT this start date and time used in the set timezone on the model. |
|
193 | - $start_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $start) . ' 00:00:00', 'Y-m-d H:i:s', $this->get_timezone()); |
|
194 | - $end_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $end) . ' 23:59:59', 'Y-m-d H:i:s', $this->get_timezone()); |
|
195 | - |
|
196 | - return $this->get_all(array(array('PAY_timestamp'=>array('>=',$start_date),'PAY_timestamp*'=>array('<=',$end_date)))); |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * methods for EEMI_Payment |
|
201 | - */ |
|
202 | - /** |
|
203 | - * returns a string for the approved status |
|
204 | - * @return string |
|
205 | - */ |
|
206 | - public function approved_status() |
|
207 | - { |
|
208 | - return self::status_id_approved; |
|
209 | - } |
|
210 | - /** |
|
211 | - * returns a string for the pending status |
|
212 | - * @return string |
|
213 | - */ |
|
214 | - public function pending_status() |
|
215 | - { |
|
216 | - return self::status_id_pending; |
|
217 | - } |
|
218 | - /** |
|
219 | - * returns a string for the cancelled status |
|
220 | - * @return string |
|
221 | - */ |
|
222 | - public function cancelled_status() |
|
223 | - { |
|
224 | - return self::status_id_cancelled; |
|
225 | - } |
|
226 | - /** |
|
227 | - * returns a string for the failed status |
|
228 | - * @return string |
|
229 | - */ |
|
230 | - public function failed_status() |
|
231 | - { |
|
232 | - return self::status_id_failed; |
|
233 | - } |
|
234 | - /** |
|
235 | - * returns a string for the declined status |
|
236 | - * @return string |
|
237 | - */ |
|
238 | - public function declined_status() |
|
239 | - { |
|
240 | - return self::status_id_declined; |
|
241 | - } |
|
20 | + * Status id in esp_status table that represents an approved payment |
|
21 | + */ |
|
22 | + const status_id_approved = 'PAP'; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * Status id in esp_status table that represents a pending payment |
|
27 | + */ |
|
28 | + const status_id_pending = 'PPN'; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * Status id in esp_status table that represents a cancelled payment (eg, the |
|
33 | + * user went to PayPal, but on the paypal site decided to cancel the payment) |
|
34 | + */ |
|
35 | + const status_id_cancelled = 'PCN'; |
|
36 | + |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * Status id in esp_status table that represents a payment that was declined by |
|
41 | + * the gateway. (eg, the user's card had no funds, or it was a fraudulent card) |
|
42 | + */ |
|
43 | + const status_id_declined = 'PDC'; |
|
44 | + |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * Status id in esp_status table that represents a payment that failed for technical reasons. |
|
49 | + * (Eg, there was some error in communicating with the payment gateway.) |
|
50 | + */ |
|
51 | + const status_id_failed = 'PFL'; |
|
52 | + |
|
53 | + /** |
|
54 | + * private constructor to prevent direct creation |
|
55 | + * @Constructor |
|
56 | + * @access protected |
|
57 | + * @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) |
|
58 | + * @return EEM_Payment |
|
59 | + */ |
|
60 | + protected function __construct($timezone) |
|
61 | + { |
|
62 | + |
|
63 | + $this->singular_item = __('Payment', 'event_espresso'); |
|
64 | + $this->plural_item = __('Payments', 'event_espresso'); |
|
65 | + |
|
66 | + $this->_tables = array( |
|
67 | + 'Payment'=>new EE_Primary_Table('esp_payment', 'PAY_ID') |
|
68 | + ); |
|
69 | + $this->_fields = array( |
|
70 | + 'Payment'=>array( |
|
71 | + 'PAY_ID'=>new EE_Primary_Key_Int_Field('PAY_ID', __('Payment ID', 'event_espresso')), |
|
72 | + 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'), |
|
73 | + 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Payment::status_id_failed, 'Status'), |
|
74 | + 'PAY_timestamp'=> new EE_Datetime_Field('PAY_timestamp', __('Timestamp of when payment was attempted', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
75 | + 'PAY_source'=>new EE_All_Caps_Text_Field('PAY_source', __('User-friendly description of payment', 'event_espresso'), false, 'CART'), |
|
76 | + 'PAY_amount'=>new EE_Money_Field('PAY_amount', __('Amount Payment should be for', 'event_espresso'), false, 0), |
|
77 | + 'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __("Payment Method ID", 'event_espresso'), false, null, 'Payment_Method'), |
|
78 | + 'PAY_gateway_response'=>new EE_Plain_Text_Field('PAY_gateway_response', __('Response from Gateway about the payment', 'event_espresso'), false, ''), |
|
79 | + 'PAY_txn_id_chq_nmbr'=>new EE_Plain_Text_Field('PAY_txn_id_chq_nmbr', __('Gateway Transaction ID or Cheque Number', 'event_espresso'), true, ''), |
|
80 | + 'PAY_po_number'=>new EE_Plain_Text_Field('PAY_po_number', __('Purchase or Sales Number', 'event_espresso'), true, ''), |
|
81 | + 'PAY_extra_accntng'=>new EE_Simple_HTML_Field('PAY_extra_accntng', __('Extra Account Info', 'event_espresso'), true, ''), |
|
82 | + 'PAY_details'=>new EE_Serialized_Text_Field('PAY_details', __('Full Gateway response about payment', 'event_espresso'), true, ''), |
|
83 | + 'PAY_redirect_url'=>new EE_Plain_Text_Field('PAY_redirect_url', __("Redirect URL", 'event_espresso'), true), |
|
84 | + 'PAY_redirect_args'=>new EE_Serialized_Text_Field('PAY_redirect_args', __("Key-Value POST vars to send along with redirect", 'event_espresso'), true) |
|
85 | + ) |
|
86 | + ); |
|
87 | + $this->_model_relations = array( |
|
88 | + 'Transaction'=> new EE_Belongs_To_Relation(), |
|
89 | + 'Status'=> new EE_Belongs_To_Relation(), |
|
90 | + 'Payment_Method'=>new EE_Belongs_To_Relation(), |
|
91 | + 'Registration_Payment' => new EE_Has_Many_Relation(), |
|
92 | + 'Registration' => new EE_HABTM_Relation('Registration_Payment'), |
|
93 | + ); |
|
94 | + $this->_model_chain_to_wp_user = 'Payment_Method'; |
|
95 | + $this->_caps_slug = 'transactions'; |
|
96 | + parent::__construct($timezone); |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * Gets the payment by the gateway server's unique ID. Eg, the unique ID PayPal assigned |
|
104 | + * to the payment. This is handy for verifying an IPN hasn't already been processed. |
|
105 | + * @param string $PAY_txn_id_chq_nmbr |
|
106 | + * @return EE_Payment |
|
107 | + */ |
|
108 | + public function get_payment_by_txn_id_chq_nmbr($PAY_txn_id_chq_nmbr) |
|
109 | + { |
|
110 | + return $this->get_one(array(array('PAY_txn_id_chq_nmbr'=>$PAY_txn_id_chq_nmbr))); |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * retrieve all payments from db for a particular transaction, optionally with |
|
118 | + * a particular status |
|
119 | + * |
|
120 | + * @access public |
|
121 | + * @param $TXN_ID |
|
122 | + * @param string $status_of_payment one of EEM_Payment::status_id_*, like 'PAP','PCN',etc. If none is provided, gets payments with any status |
|
123 | + * @return EE_Payment[] |
|
124 | + */ |
|
125 | + public function get_payments_for_transaction($TXN_ID = false, $status_of_payment = null) |
|
126 | + { |
|
127 | + // all payments for a TXN ordered chronologically |
|
128 | + $query_params = array( array( 'TXN_ID' => $TXN_ID ), 'order_by' => array( 'PAY_timestamp' => 'ASC' )); |
|
129 | + // if provided with a status, search specifically for that status. Otherwise get them all |
|
130 | + if ($status_of_payment) { |
|
131 | + $query_params[0]['STS_ID'] = $status_of_payment; |
|
132 | + } |
|
133 | + // retrieve payments |
|
134 | + return $this->get_all($query_params); |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * Only gets payments which have been approved |
|
141 | + * @param int $TXN_ID |
|
142 | + * @return EE_Payment[] |
|
143 | + */ |
|
144 | + public function get_approved_payments_for_transaction($TXN_ID = 0) |
|
145 | + { |
|
146 | + return $this->get_payments_for_transaction($TXN_ID, EEM_Payment::status_id_approved); |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * retrieve all payments from db between two dates, |
|
155 | + * |
|
156 | + * @param string $start_date incoming start date. If empty the beginning of today is used. |
|
157 | + * @param string $end_date incoming end date. If empty the end of today is used. |
|
158 | + * @param string $format If you include $start_date or $end_date then you must include the format string |
|
159 | + * for the format your date is in. |
|
160 | + * @param string $timezone If your range is in a different timezone then the current setting on this |
|
161 | + * WordPress install, then include it here. |
|
162 | + * @throws EE_Error |
|
163 | + * |
|
164 | + * @return EE_Payment[] |
|
165 | + */ |
|
166 | + public function get_payments_made_between_dates($start_date = '', $end_date = '', $format = '', $timezone = '') |
|
167 | + { |
|
168 | + $timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone; |
|
169 | + // if $start_date or $end date, verify $format is included. |
|
170 | + if (( ! empty($start_date) || ! empty($end_date) ) && empty($format)) { |
|
171 | + throw new EE_Error(__('You included a start date and/or a end date for this method but did not include a format string. The format string is needed for setting up the query', 'event_espresso')); |
|
172 | + } |
|
173 | + $now = new DateTime('now'); |
|
174 | + // setup timezone objects once |
|
175 | + $modelDateTimeZone = new DateTimeZone($this->_timezone); |
|
176 | + $passedDateTimeZone = new DateTimeZone($timezone); |
|
177 | + // setup start date |
|
178 | + $start_date = ! empty($start_date) ? date_create_from_format($format, $start_date, $passedDateTimeZone) : $now; |
|
179 | + EEH_DTT_Helper::setTimezone($start_date, $modelDateTimeZone); |
|
180 | + $start_date = $start_date->format('Y-m-d') . ' 00:00:00'; |
|
181 | + $start_date = strtotime($start_date); |
|
182 | + // setup end date |
|
183 | + $end_date = ! empty($end_date) ? date_create_from_format($format, $end_date, $passedDateTimeZone) : $now; |
|
184 | + EEH_DTT_Helper::setTimezone($end_date, $modelDateTimeZone); |
|
185 | + $end_date = $end_date->format('Y-m-d') . ' 23:59:59'; |
|
186 | + $end_date = strtotime($end_date); |
|
187 | + |
|
188 | + // make sure our start date is the lowest value and vice versa |
|
189 | + $start = min($start_date, $end_date); |
|
190 | + $end = max($start_date, $end_date); |
|
191 | + |
|
192 | + // yes we generated the date and time string in utc but we WANT this start date and time used in the set timezone on the model. |
|
193 | + $start_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $start) . ' 00:00:00', 'Y-m-d H:i:s', $this->get_timezone()); |
|
194 | + $end_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $end) . ' 23:59:59', 'Y-m-d H:i:s', $this->get_timezone()); |
|
195 | + |
|
196 | + return $this->get_all(array(array('PAY_timestamp'=>array('>=',$start_date),'PAY_timestamp*'=>array('<=',$end_date)))); |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * methods for EEMI_Payment |
|
201 | + */ |
|
202 | + /** |
|
203 | + * returns a string for the approved status |
|
204 | + * @return string |
|
205 | + */ |
|
206 | + public function approved_status() |
|
207 | + { |
|
208 | + return self::status_id_approved; |
|
209 | + } |
|
210 | + /** |
|
211 | + * returns a string for the pending status |
|
212 | + * @return string |
|
213 | + */ |
|
214 | + public function pending_status() |
|
215 | + { |
|
216 | + return self::status_id_pending; |
|
217 | + } |
|
218 | + /** |
|
219 | + * returns a string for the cancelled status |
|
220 | + * @return string |
|
221 | + */ |
|
222 | + public function cancelled_status() |
|
223 | + { |
|
224 | + return self::status_id_cancelled; |
|
225 | + } |
|
226 | + /** |
|
227 | + * returns a string for the failed status |
|
228 | + * @return string |
|
229 | + */ |
|
230 | + public function failed_status() |
|
231 | + { |
|
232 | + return self::status_id_failed; |
|
233 | + } |
|
234 | + /** |
|
235 | + * returns a string for the declined status |
|
236 | + * @return string |
|
237 | + */ |
|
238 | + public function declined_status() |
|
239 | + { |
|
240 | + return self::status_id_declined; |
|
241 | + } |
|
242 | 242 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | public function get_payments_for_transaction($TXN_ID = false, $status_of_payment = null) |
126 | 126 | { |
127 | 127 | // all payments for a TXN ordered chronologically |
128 | - $query_params = array( array( 'TXN_ID' => $TXN_ID ), 'order_by' => array( 'PAY_timestamp' => 'ASC' )); |
|
128 | + $query_params = array(array('TXN_ID' => $TXN_ID), 'order_by' => array('PAY_timestamp' => 'ASC')); |
|
129 | 129 | // if provided with a status, search specifically for that status. Otherwise get them all |
130 | 130 | if ($status_of_payment) { |
131 | 131 | $query_params[0]['STS_ID'] = $status_of_payment; |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | { |
168 | 168 | $timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone; |
169 | 169 | // if $start_date or $end date, verify $format is included. |
170 | - if (( ! empty($start_date) || ! empty($end_date) ) && empty($format)) { |
|
170 | + if (( ! empty($start_date) || ! empty($end_date)) && empty($format)) { |
|
171 | 171 | throw new EE_Error(__('You included a start date and/or a end date for this method but did not include a format string. The format string is needed for setting up the query', 'event_espresso')); |
172 | 172 | } |
173 | 173 | $now = new DateTime('now'); |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | // setup start date |
178 | 178 | $start_date = ! empty($start_date) ? date_create_from_format($format, $start_date, $passedDateTimeZone) : $now; |
179 | 179 | EEH_DTT_Helper::setTimezone($start_date, $modelDateTimeZone); |
180 | - $start_date = $start_date->format('Y-m-d') . ' 00:00:00'; |
|
180 | + $start_date = $start_date->format('Y-m-d').' 00:00:00'; |
|
181 | 181 | $start_date = strtotime($start_date); |
182 | 182 | // setup end date |
183 | 183 | $end_date = ! empty($end_date) ? date_create_from_format($format, $end_date, $passedDateTimeZone) : $now; |
184 | 184 | EEH_DTT_Helper::setTimezone($end_date, $modelDateTimeZone); |
185 | - $end_date = $end_date->format('Y-m-d') . ' 23:59:59'; |
|
185 | + $end_date = $end_date->format('Y-m-d').' 23:59:59'; |
|
186 | 186 | $end_date = strtotime($end_date); |
187 | 187 | |
188 | 188 | // make sure our start date is the lowest value and vice versa |
@@ -190,10 +190,10 @@ discard block |
||
190 | 190 | $end = max($start_date, $end_date); |
191 | 191 | |
192 | 192 | // yes we generated the date and time string in utc but we WANT this start date and time used in the set timezone on the model. |
193 | - $start_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $start) . ' 00:00:00', 'Y-m-d H:i:s', $this->get_timezone()); |
|
194 | - $end_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $end) . ' 23:59:59', 'Y-m-d H:i:s', $this->get_timezone()); |
|
193 | + $start_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $start).' 00:00:00', 'Y-m-d H:i:s', $this->get_timezone()); |
|
194 | + $end_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $end).' 23:59:59', 'Y-m-d H:i:s', $this->get_timezone()); |
|
195 | 195 | |
196 | - return $this->get_all(array(array('PAY_timestamp'=>array('>=',$start_date),'PAY_timestamp*'=>array('<=',$end_date)))); |
|
196 | + return $this->get_all(array(array('PAY_timestamp'=>array('>=', $start_date), 'PAY_timestamp*'=>array('<=', $end_date)))); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -16,38 +16,38 @@ |
||
16 | 16 | class EEM_Question_Group_Question extends EEM_Base |
17 | 17 | { |
18 | 18 | |
19 | - // private instance of the Attendee object |
|
20 | - protected static $_instance = null; |
|
19 | + // private instance of the Attendee object |
|
20 | + protected static $_instance = null; |
|
21 | 21 | |
22 | 22 | |
23 | - protected function __construct($timezone = null) |
|
24 | - { |
|
25 | - $this->singular_item = __('Question Group to Question Link', 'event_espresso'); |
|
26 | - $this->plural_item = __('Question Group to Question Links', 'event_espresso'); |
|
27 | - $this->_tables = array( |
|
28 | - 'Question_Group_Question'=>new EE_Primary_Table('esp_question_group_question', 'QGQ_ID') |
|
29 | - ); |
|
30 | - $this->_fields = array( |
|
31 | - 'Question_Group_Question'=>array( |
|
32 | - 'QGQ_ID'=>new EE_Primary_Key_Int_Field('QGQ_ID', __('Question Group to Question Link ID', 'event_espresso')), |
|
33 | - 'QSG_ID'=>new EE_Foreign_Key_Int_Field('QSG_ID', __('Question Group ID', 'event_espresso'), false, 0, 'Question_Group'), |
|
34 | - 'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question Id', 'event_espresso'), false, 0, 'Question'), |
|
35 | - 'QGQ_order' => new EE_Integer_Field('QGQ_order', __('Question Group Question Order', 'event_espresso'), false, 0) |
|
36 | - ) |
|
37 | - ); |
|
38 | - $this->_model_relations = array( |
|
39 | - 'Question_Group'=>new EE_Belongs_To_Relation(), |
|
40 | - 'Question'=>new EE_Belongs_To_Relation() |
|
41 | - ); |
|
23 | + protected function __construct($timezone = null) |
|
24 | + { |
|
25 | + $this->singular_item = __('Question Group to Question Link', 'event_espresso'); |
|
26 | + $this->plural_item = __('Question Group to Question Links', 'event_espresso'); |
|
27 | + $this->_tables = array( |
|
28 | + 'Question_Group_Question'=>new EE_Primary_Table('esp_question_group_question', 'QGQ_ID') |
|
29 | + ); |
|
30 | + $this->_fields = array( |
|
31 | + 'Question_Group_Question'=>array( |
|
32 | + 'QGQ_ID'=>new EE_Primary_Key_Int_Field('QGQ_ID', __('Question Group to Question Link ID', 'event_espresso')), |
|
33 | + 'QSG_ID'=>new EE_Foreign_Key_Int_Field('QSG_ID', __('Question Group ID', 'event_espresso'), false, 0, 'Question_Group'), |
|
34 | + 'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question Id', 'event_espresso'), false, 0, 'Question'), |
|
35 | + 'QGQ_order' => new EE_Integer_Field('QGQ_order', __('Question Group Question Order', 'event_espresso'), false, 0) |
|
36 | + ) |
|
37 | + ); |
|
38 | + $this->_model_relations = array( |
|
39 | + 'Question_Group'=>new EE_Belongs_To_Relation(), |
|
40 | + 'Question'=>new EE_Belongs_To_Relation() |
|
41 | + ); |
|
42 | 42 | |
43 | - $this->_model_chain_to_wp_user = 'Question_Group'; |
|
44 | - // this model is generally available for reading |
|
45 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
46 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system'); |
|
47 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system'); |
|
48 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system'); |
|
49 | - // use the caps for question groups |
|
50 | - $this->_caps_slug = 'question_groups'; |
|
51 | - parent::__construct($timezone); |
|
52 | - } |
|
43 | + $this->_model_chain_to_wp_user = 'Question_Group'; |
|
44 | + // this model is generally available for reading |
|
45 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
46 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system'); |
|
47 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system'); |
|
48 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system'); |
|
49 | + // use the caps for question groups |
|
50 | + $this->_caps_slug = 'question_groups'; |
|
51 | + parent::__construct($timezone); |
|
52 | + } |
|
53 | 53 | } |
@@ -42,10 +42,10 @@ |
||
42 | 42 | |
43 | 43 | $this->_model_chain_to_wp_user = 'Question_Group'; |
44 | 44 | // this model is generally available for reading |
45 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
46 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system'); |
|
47 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system'); |
|
48 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system'); |
|
45 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
46 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system'); |
|
47 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system'); |
|
48 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('Question_Group.QSG_system'); |
|
49 | 49 | // use the caps for question groups |
50 | 50 | $this->_caps_slug = 'question_groups'; |
51 | 51 | parent::__construct($timezone); |
@@ -12,34 +12,34 @@ |
||
12 | 12 | class EEM_Registration_Payment extends EEM_Base |
13 | 13 | { |
14 | 14 | |
15 | - // private instance |
|
16 | - protected static $_instance = null; |
|
15 | + // private instance |
|
16 | + protected static $_instance = null; |
|
17 | 17 | |
18 | 18 | |
19 | - protected function __construct($timezone = null) |
|
20 | - { |
|
19 | + protected function __construct($timezone = null) |
|
20 | + { |
|
21 | 21 | |
22 | - $this->singular_item = __('Registration Payment', 'event_espresso'); |
|
23 | - $this->plural_item = __('Registration Payments', 'event_espresso'); |
|
22 | + $this->singular_item = __('Registration Payment', 'event_espresso'); |
|
23 | + $this->plural_item = __('Registration Payments', 'event_espresso'); |
|
24 | 24 | |
25 | - $this->_tables = array( |
|
26 | - 'Registration_Payment' => new EE_Primary_Table('esp_registration_payment', 'RPY_ID') |
|
27 | - ); |
|
25 | + $this->_tables = array( |
|
26 | + 'Registration_Payment' => new EE_Primary_Table('esp_registration_payment', 'RPY_ID') |
|
27 | + ); |
|
28 | 28 | |
29 | - $this->_fields = array( |
|
30 | - 'Registration_Payment'=>array( |
|
31 | - 'RPY_ID' => new EE_Primary_Key_Int_Field('RPY_ID', __('Registration Payment ID', 'event_espresso')), |
|
32 | - 'REG_ID' => new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'), |
|
33 | - 'PAY_ID' => new EE_Foreign_Key_Int_Field('PAY_ID', __('Payment ID', 'event_espresso'), true, null, 'Payment'), |
|
34 | - 'RPY_amount' => new EE_Money_Field('RPY_amount', __('Amount attributed to the registration', 'event_espresso'), false, 0), |
|
35 | - ) |
|
36 | - ); |
|
29 | + $this->_fields = array( |
|
30 | + 'Registration_Payment'=>array( |
|
31 | + 'RPY_ID' => new EE_Primary_Key_Int_Field('RPY_ID', __('Registration Payment ID', 'event_espresso')), |
|
32 | + 'REG_ID' => new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'), |
|
33 | + 'PAY_ID' => new EE_Foreign_Key_Int_Field('PAY_ID', __('Payment ID', 'event_espresso'), true, null, 'Payment'), |
|
34 | + 'RPY_amount' => new EE_Money_Field('RPY_amount', __('Amount attributed to the registration', 'event_espresso'), false, 0), |
|
35 | + ) |
|
36 | + ); |
|
37 | 37 | |
38 | - $this->_model_relations = array( |
|
39 | - 'Registration' => new EE_Belongs_To_Relation(), |
|
40 | - 'Payment' => new EE_Belongs_To_Relation(), |
|
41 | - ); |
|
38 | + $this->_model_relations = array( |
|
39 | + 'Registration' => new EE_Belongs_To_Relation(), |
|
40 | + 'Payment' => new EE_Belongs_To_Relation(), |
|
41 | + ); |
|
42 | 42 | |
43 | - parent::__construct($timezone); |
|
44 | - } |
|
43 | + parent::__construct($timezone); |
|
44 | + } |
|
45 | 45 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | $this->singular_item = __('Registration Payment', 'event_espresso'); |
23 | - $this->plural_item = __('Registration Payments', 'event_espresso'); |
|
23 | + $this->plural_item = __('Registration Payments', 'event_espresso'); |
|
24 | 24 | |
25 | 25 | $this->_tables = array( |
26 | 26 | 'Registration_Payment' => new EE_Primary_Table('esp_registration_payment', 'RPY_ID') |
@@ -13,40 +13,40 @@ |
||
13 | 13 | class EEM_Checkin extends EEM_Base |
14 | 14 | { |
15 | 15 | |
16 | - // private instance of the EEM_Checkin object |
|
17 | - protected static $_instance = null; |
|
16 | + // private instance of the EEM_Checkin object |
|
17 | + protected static $_instance = null; |
|
18 | 18 | |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * private constructor to prevent direct creation |
|
23 | - * @Constructor |
|
24 | - * @access protected |
|
25 | - * @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) |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - protected function __construct($timezone = null) |
|
29 | - { |
|
30 | - $this->singular_item = __('Check-In', 'event_espresso'); |
|
31 | - $this->plural_item = __('Check-Ins', 'event_espresso'); |
|
21 | + /** |
|
22 | + * private constructor to prevent direct creation |
|
23 | + * @Constructor |
|
24 | + * @access protected |
|
25 | + * @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) |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + protected function __construct($timezone = null) |
|
29 | + { |
|
30 | + $this->singular_item = __('Check-In', 'event_espresso'); |
|
31 | + $this->plural_item = __('Check-Ins', 'event_espresso'); |
|
32 | 32 | |
33 | - $this->_tables = array( |
|
34 | - 'Checkin'=>new EE_Primary_Table('esp_checkin', 'CHK_ID') |
|
35 | - ); |
|
36 | - $this->_fields = array( |
|
37 | - 'Checkin'=> array( |
|
38 | - 'CHK_ID'=>new EE_Primary_Key_Int_Field('CHK_ID', 'Check-in ID'), |
|
39 | - 'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', 'Registration Id', false, 0, 'Registration'), |
|
40 | - 'DTT_ID'=>new EE_Foreign_Key_Int_Field('DTT_ID', 'Datetime Id', false, 0, 'Datetime'), |
|
41 | - 'CHK_in'=>new EE_Boolean_Field('CHK_in', 'Whether a person has checked in or checked out', false, true), |
|
42 | - 'CHK_timestamp'=>new EE_Datetime_Field('CHK_timestamp', __('When the row was modified', 'event_espresso'), false, EE_Datetime_Field::now, $timezone) |
|
43 | - ) |
|
44 | - ); |
|
45 | - $this->_model_relations = array( |
|
46 | - 'Registration'=>new EE_Belongs_To_Relation(), |
|
47 | - 'Datetime'=>new EE_Belongs_To_Relation() |
|
48 | - ); |
|
49 | - $this->_model_chain_to_wp_user = 'Registration.Event'; |
|
50 | - parent::__construct($timezone); |
|
51 | - } |
|
33 | + $this->_tables = array( |
|
34 | + 'Checkin'=>new EE_Primary_Table('esp_checkin', 'CHK_ID') |
|
35 | + ); |
|
36 | + $this->_fields = array( |
|
37 | + 'Checkin'=> array( |
|
38 | + 'CHK_ID'=>new EE_Primary_Key_Int_Field('CHK_ID', 'Check-in ID'), |
|
39 | + 'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', 'Registration Id', false, 0, 'Registration'), |
|
40 | + 'DTT_ID'=>new EE_Foreign_Key_Int_Field('DTT_ID', 'Datetime Id', false, 0, 'Datetime'), |
|
41 | + 'CHK_in'=>new EE_Boolean_Field('CHK_in', 'Whether a person has checked in or checked out', false, true), |
|
42 | + 'CHK_timestamp'=>new EE_Datetime_Field('CHK_timestamp', __('When the row was modified', 'event_espresso'), false, EE_Datetime_Field::now, $timezone) |
|
43 | + ) |
|
44 | + ); |
|
45 | + $this->_model_relations = array( |
|
46 | + 'Registration'=>new EE_Belongs_To_Relation(), |
|
47 | + 'Datetime'=>new EE_Belongs_To_Relation() |
|
48 | + ); |
|
49 | + $this->_model_chain_to_wp_user = 'Registration.Event'; |
|
50 | + parent::__construct($timezone); |
|
51 | + } |
|
52 | 52 | } |
@@ -16,94 +16,94 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * get_join_statement |
|
21 | - * |
|
22 | - * @param string $model_relation_chain |
|
23 | - * @return string |
|
24 | - * @throws \EE_Error |
|
25 | - */ |
|
26 | - public function get_join_statement($model_relation_chain) |
|
27 | - { |
|
28 | - // create the sql string like |
|
29 | - $this_table_fk_field = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
|
30 | - // ALSO, need to get the field with the model name |
|
31 | - $field_with_model_name = $this->get_this_model()->get_field_containing_related_model_name(); |
|
19 | + /** |
|
20 | + * get_join_statement |
|
21 | + * |
|
22 | + * @param string $model_relation_chain |
|
23 | + * @return string |
|
24 | + * @throws \EE_Error |
|
25 | + */ |
|
26 | + public function get_join_statement($model_relation_chain) |
|
27 | + { |
|
28 | + // create the sql string like |
|
29 | + $this_table_fk_field = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
|
30 | + // ALSO, need to get the field with the model name |
|
31 | + $field_with_model_name = $this->get_this_model()->get_field_containing_related_model_name(); |
|
32 | 32 | |
33 | 33 | |
34 | - $other_table_pk_field = $this->get_other_model()->get_primary_key_field(); |
|
35 | - $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
36 | - $model_relation_chain, |
|
37 | - $this->get_this_model()->get_this_model_name() |
|
38 | - ) . $this_table_fk_field->get_table_alias(); |
|
39 | - $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
40 | - $model_relation_chain, |
|
41 | - $this->get_other_model()->get_this_model_name() |
|
42 | - ) . $other_table_pk_field->get_table_alias(); |
|
43 | - $other_table = $this->get_other_model()->get_table_for_alias($other_table_alias); |
|
44 | - return $this->_left_join( |
|
45 | - $other_table, |
|
46 | - $other_table_alias, |
|
47 | - $other_table_pk_field->get_table_column(), |
|
48 | - $this_table_alias, |
|
49 | - $this_table_fk_field->get_table_column(), |
|
50 | - $field_with_model_name->get_qualified_column() . "='" . $this->get_other_model()->get_this_model_name() . "'" |
|
51 | - ) |
|
52 | - . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias); |
|
53 | - } |
|
34 | + $other_table_pk_field = $this->get_other_model()->get_primary_key_field(); |
|
35 | + $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
36 | + $model_relation_chain, |
|
37 | + $this->get_this_model()->get_this_model_name() |
|
38 | + ) . $this_table_fk_field->get_table_alias(); |
|
39 | + $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
40 | + $model_relation_chain, |
|
41 | + $this->get_other_model()->get_this_model_name() |
|
42 | + ) . $other_table_pk_field->get_table_alias(); |
|
43 | + $other_table = $this->get_other_model()->get_table_for_alias($other_table_alias); |
|
44 | + return $this->_left_join( |
|
45 | + $other_table, |
|
46 | + $other_table_alias, |
|
47 | + $other_table_pk_field->get_table_column(), |
|
48 | + $this_table_alias, |
|
49 | + $this_table_fk_field->get_table_column(), |
|
50 | + $field_with_model_name->get_qualified_column() . "='" . $this->get_other_model()->get_this_model_name() . "'" |
|
51 | + ) |
|
52 | + . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Sets this model object's foreign key to the other model object's primary key. Feel free to do this manually if |
|
58 | - * you like. |
|
59 | - * |
|
60 | - * @param EE_Base_Class|int $this_obj_or_id |
|
61 | - * @param EE_Base_Class|int $other_obj_or_id |
|
62 | - * @param array $extra_join_model_fields_n_values |
|
63 | - * @return \EE_Base_Class |
|
64 | - * @throws \EE_Error |
|
65 | - */ |
|
66 | - public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) |
|
67 | - { |
|
68 | - $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
69 | - $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
70 | - // find the field on THIS model which a foreign key to the other model |
|
71 | - $fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
|
72 | - // set that field on the other model to this model's ID |
|
73 | - $this_model_obj->set($fk_on_this_model->get_name(), $other_model_obj->ID()); |
|
74 | - // and make sure this model's field with the foreign model name is set to the correct value |
|
75 | - $this_model_obj->set( |
|
76 | - $this->get_this_model()->get_field_containing_related_model_name()->get_name(), |
|
77 | - $this->get_other_model()->get_this_model_name() |
|
78 | - ); |
|
79 | - $this_model_obj->save(); |
|
80 | - return $other_model_obj; |
|
81 | - } |
|
56 | + /** |
|
57 | + * Sets this model object's foreign key to the other model object's primary key. Feel free to do this manually if |
|
58 | + * you like. |
|
59 | + * |
|
60 | + * @param EE_Base_Class|int $this_obj_or_id |
|
61 | + * @param EE_Base_Class|int $other_obj_or_id |
|
62 | + * @param array $extra_join_model_fields_n_values |
|
63 | + * @return \EE_Base_Class |
|
64 | + * @throws \EE_Error |
|
65 | + */ |
|
66 | + public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) |
|
67 | + { |
|
68 | + $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
69 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
70 | + // find the field on THIS model which a foreign key to the other model |
|
71 | + $fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
|
72 | + // set that field on the other model to this model's ID |
|
73 | + $this_model_obj->set($fk_on_this_model->get_name(), $other_model_obj->ID()); |
|
74 | + // and make sure this model's field with the foreign model name is set to the correct value |
|
75 | + $this_model_obj->set( |
|
76 | + $this->get_this_model()->get_field_containing_related_model_name()->get_name(), |
|
77 | + $this->get_other_model()->get_this_model_name() |
|
78 | + ); |
|
79 | + $this_model_obj->save(); |
|
80 | + return $other_model_obj; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * Sets the this model object's foreign key to its default, instead of pointing to the other model object |
|
86 | - * |
|
87 | - * @param EE_Base_Class|int $this_obj_or_id |
|
88 | - * @param EE_Base_Class|int $other_obj_or_id |
|
89 | - * @param array $where_query |
|
90 | - * @return \EE_Base_Class |
|
91 | - * @throws \EE_Error |
|
92 | - */ |
|
93 | - public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) |
|
94 | - { |
|
95 | - $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
96 | - $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id); |
|
97 | - // find the field on the other model which is a foreign key to this model |
|
98 | - $fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
|
99 | - // set that field on the other model to this model's ID |
|
100 | - $this_model_obj->set($fk_on_this_model->get_name(), null, true); |
|
101 | - $this_model_obj->set( |
|
102 | - $this->get_this_model()->get_field_containing_related_model_name()->get_name(), |
|
103 | - null, |
|
104 | - true |
|
105 | - ); |
|
106 | - $this_model_obj->save(); |
|
107 | - return $other_model_obj; |
|
108 | - } |
|
84 | + /** |
|
85 | + * Sets the this model object's foreign key to its default, instead of pointing to the other model object |
|
86 | + * |
|
87 | + * @param EE_Base_Class|int $this_obj_or_id |
|
88 | + * @param EE_Base_Class|int $other_obj_or_id |
|
89 | + * @param array $where_query |
|
90 | + * @return \EE_Base_Class |
|
91 | + * @throws \EE_Error |
|
92 | + */ |
|
93 | + public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) |
|
94 | + { |
|
95 | + $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
96 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id); |
|
97 | + // find the field on the other model which is a foreign key to this model |
|
98 | + $fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
|
99 | + // set that field on the other model to this model's ID |
|
100 | + $this_model_obj->set($fk_on_this_model->get_name(), null, true); |
|
101 | + $this_model_obj->set( |
|
102 | + $this->get_this_model()->get_field_containing_related_model_name()->get_name(), |
|
103 | + null, |
|
104 | + true |
|
105 | + ); |
|
106 | + $this_model_obj->save(); |
|
107 | + return $other_model_obj; |
|
108 | + } |
|
109 | 109 | } |
@@ -35,19 +35,19 @@ |
||
35 | 35 | $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
36 | 36 | $model_relation_chain, |
37 | 37 | $this->get_this_model()->get_this_model_name() |
38 | - ) . $this_table_fk_field->get_table_alias(); |
|
39 | - $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
38 | + ).$this_table_fk_field->get_table_alias(); |
|
39 | + $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
40 | 40 | $model_relation_chain, |
41 | 41 | $this->get_other_model()->get_this_model_name() |
42 | - ) . $other_table_pk_field->get_table_alias(); |
|
43 | - $other_table = $this->get_other_model()->get_table_for_alias($other_table_alias); |
|
42 | + ).$other_table_pk_field->get_table_alias(); |
|
43 | + $other_table = $this->get_other_model()->get_table_for_alias($other_table_alias); |
|
44 | 44 | return $this->_left_join( |
45 | 45 | $other_table, |
46 | 46 | $other_table_alias, |
47 | 47 | $other_table_pk_field->get_table_column(), |
48 | 48 | $this_table_alias, |
49 | 49 | $this_table_fk_field->get_table_column(), |
50 | - $field_with_model_name->get_qualified_column() . "='" . $this->get_other_model()->get_this_model_name() . "'" |
|
50 | + $field_with_model_name->get_qualified_column()."='".$this->get_other_model()->get_this_model_name()."'" |
|
51 | 51 | ) |
52 | 52 | . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias); |
53 | 53 | } |
@@ -11,102 +11,102 @@ |
||
11 | 11 | class EE_Has_Many_Relation extends EE_Model_Relation_Base |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * Object representing the relationship between two models. Has_Many_Relations are where the OTHER model has the |
|
16 | - * foreign key this model. IE, there can be many other model objects related to one of this model's objects (but |
|
17 | - * NOT through a JOIN table, which is the case for EE_HABTM_Relations). This knows how to join the models, get |
|
18 | - * related models across the relation, and add-and-remove the relationships. |
|
19 | - * |
|
20 | - * @param boolean $block_deletes For this type of r elation, we block by default. If there are |
|
21 | - * related models across this relation, block (prevent and add an |
|
22 | - * error) the deletion of this model |
|
23 | - * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the |
|
24 | - * default |
|
25 | - */ |
|
26 | - public function __construct($block_deletes = true, $blocking_delete_error_message = null) |
|
27 | - { |
|
28 | - parent::__construct($block_deletes, $blocking_delete_error_message); |
|
29 | - } |
|
14 | + /** |
|
15 | + * Object representing the relationship between two models. Has_Many_Relations are where the OTHER model has the |
|
16 | + * foreign key this model. IE, there can be many other model objects related to one of this model's objects (but |
|
17 | + * NOT through a JOIN table, which is the case for EE_HABTM_Relations). This knows how to join the models, get |
|
18 | + * related models across the relation, and add-and-remove the relationships. |
|
19 | + * |
|
20 | + * @param boolean $block_deletes For this type of r elation, we block by default. If there are |
|
21 | + * related models across this relation, block (prevent and add an |
|
22 | + * error) the deletion of this model |
|
23 | + * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the |
|
24 | + * default |
|
25 | + */ |
|
26 | + public function __construct($block_deletes = true, $blocking_delete_error_message = null) |
|
27 | + { |
|
28 | + parent::__construct($block_deletes, $blocking_delete_error_message); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * Gets the SQL string for performing the join between this model and the other model. |
|
34 | - * |
|
35 | - * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
|
36 | - * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = |
|
37 | - * other_model_primary_table.fk" etc |
|
38 | - * @throws \EE_Error |
|
39 | - */ |
|
40 | - public function get_join_statement($model_relation_chain) |
|
41 | - { |
|
42 | - // create the sql string like |
|
43 | - // LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions |
|
44 | - $this_table_pk_field = $this->get_this_model()->get_primary_key_field(); |
|
45 | - $other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
46 | - $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
47 | - $model_relation_chain, |
|
48 | - $this->get_this_model()->get_this_model_name() |
|
49 | - ) . $this_table_pk_field->get_table_alias(); |
|
50 | - $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
51 | - $model_relation_chain, |
|
52 | - $this->get_other_model()->get_this_model_name() |
|
53 | - ) . $other_table_fk_field->get_table_alias(); |
|
54 | - $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
|
32 | + /** |
|
33 | + * Gets the SQL string for performing the join between this model and the other model. |
|
34 | + * |
|
35 | + * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
|
36 | + * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = |
|
37 | + * other_model_primary_table.fk" etc |
|
38 | + * @throws \EE_Error |
|
39 | + */ |
|
40 | + public function get_join_statement($model_relation_chain) |
|
41 | + { |
|
42 | + // create the sql string like |
|
43 | + // LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions |
|
44 | + $this_table_pk_field = $this->get_this_model()->get_primary_key_field(); |
|
45 | + $other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
46 | + $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
47 | + $model_relation_chain, |
|
48 | + $this->get_this_model()->get_this_model_name() |
|
49 | + ) . $this_table_pk_field->get_table_alias(); |
|
50 | + $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
51 | + $model_relation_chain, |
|
52 | + $this->get_other_model()->get_this_model_name() |
|
53 | + ) . $other_table_fk_field->get_table_alias(); |
|
54 | + $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
|
55 | 55 | |
56 | - return $this->_left_join( |
|
57 | - $fk_table, |
|
58 | - $fk_table_alias, |
|
59 | - $other_table_fk_field->get_table_column(), |
|
60 | - $pk_table_alias, |
|
61 | - $this_table_pk_field->get_table_column() |
|
62 | - ) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
|
63 | - } |
|
56 | + return $this->_left_join( |
|
57 | + $fk_table, |
|
58 | + $fk_table_alias, |
|
59 | + $other_table_fk_field->get_table_column(), |
|
60 | + $pk_table_alias, |
|
61 | + $this_table_pk_field->get_table_column() |
|
62 | + ) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * Sets the other model object's foreign key to this model object's primary key. Feel free to do this manually if |
|
68 | - * you like. |
|
69 | - * |
|
70 | - * @param EE_Base_Class|int $this_obj_or_id |
|
71 | - * @param EE_Base_Class|int $other_obj_or_id |
|
72 | - * @param array $extra_join_model_fields_n_values |
|
73 | - * @return \EE_Base_Class |
|
74 | - * @throws \EE_Error |
|
75 | - */ |
|
76 | - public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) |
|
77 | - { |
|
78 | - $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
79 | - $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
66 | + /** |
|
67 | + * Sets the other model object's foreign key to this model object's primary key. Feel free to do this manually if |
|
68 | + * you like. |
|
69 | + * |
|
70 | + * @param EE_Base_Class|int $this_obj_or_id |
|
71 | + * @param EE_Base_Class|int $other_obj_or_id |
|
72 | + * @param array $extra_join_model_fields_n_values |
|
73 | + * @return \EE_Base_Class |
|
74 | + * @throws \EE_Error |
|
75 | + */ |
|
76 | + public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) |
|
77 | + { |
|
78 | + $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
79 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
80 | 80 | |
81 | - // find the field on the other model which is a foreign key to this model |
|
82 | - $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
83 | - if ($other_model_obj->get($fk_field_on_other_model->get_name()) != $this_model_obj->ID()) { |
|
84 | - // set that field on the other model to this model's ID |
|
85 | - $other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID()); |
|
86 | - $other_model_obj->save(); |
|
87 | - } |
|
88 | - return $other_model_obj; |
|
89 | - } |
|
81 | + // find the field on the other model which is a foreign key to this model |
|
82 | + $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
83 | + if ($other_model_obj->get($fk_field_on_other_model->get_name()) != $this_model_obj->ID()) { |
|
84 | + // set that field on the other model to this model's ID |
|
85 | + $other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID()); |
|
86 | + $other_model_obj->save(); |
|
87 | + } |
|
88 | + return $other_model_obj; |
|
89 | + } |
|
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * Sets the other model object's foreign key to its default, instead of pointing to this model object. |
|
94 | - * If $other_obj_or_id doesn't have any other relations, this function is essentially orphaning it |
|
95 | - * |
|
96 | - * @param EE_Base_Class|int $this_obj_or_id |
|
97 | - * @param EE_Base_Class|int $other_obj_or_id |
|
98 | - * @param array $where_query |
|
99 | - * @return \EE_Base_Class |
|
100 | - * @throws \EE_Error |
|
101 | - */ |
|
102 | - public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) |
|
103 | - { |
|
104 | - $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
105 | - // find the field on the other model which is a foreign key to this model |
|
106 | - $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
107 | - // set that field on the other model to this model's ID |
|
108 | - $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
109 | - $other_model_obj->save(); |
|
110 | - return $other_model_obj; |
|
111 | - } |
|
92 | + /** |
|
93 | + * Sets the other model object's foreign key to its default, instead of pointing to this model object. |
|
94 | + * If $other_obj_or_id doesn't have any other relations, this function is essentially orphaning it |
|
95 | + * |
|
96 | + * @param EE_Base_Class|int $this_obj_or_id |
|
97 | + * @param EE_Base_Class|int $other_obj_or_id |
|
98 | + * @param array $where_query |
|
99 | + * @return \EE_Base_Class |
|
100 | + * @throws \EE_Error |
|
101 | + */ |
|
102 | + public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) |
|
103 | + { |
|
104 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
105 | + // find the field on the other model which is a foreign key to this model |
|
106 | + $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
107 | + // set that field on the other model to this model's ID |
|
108 | + $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
109 | + $other_model_obj->save(); |
|
110 | + return $other_model_obj; |
|
111 | + } |
|
112 | 112 | } |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
47 | 47 | $model_relation_chain, |
48 | 48 | $this->get_this_model()->get_this_model_name() |
49 | - ) . $this_table_pk_field->get_table_alias(); |
|
50 | - $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
49 | + ).$this_table_pk_field->get_table_alias(); |
|
50 | + $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
51 | 51 | $model_relation_chain, |
52 | 52 | $this->get_other_model()->get_this_model_name() |
53 | - ) . $other_table_fk_field->get_table_alias(); |
|
54 | - $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
|
53 | + ).$other_table_fk_field->get_table_alias(); |
|
54 | + $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
|
55 | 55 | |
56 | 56 | return $this->_left_join( |
57 | 57 | $fk_table, |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $other_table_fk_field->get_table_column(), |
60 | 60 | $pk_table_alias, |
61 | 61 | $this_table_pk_field->get_table_column() |
62 | - ) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
|
62 | + ).$this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 |