@@ -15,94 +15,94 @@ |
||
15 | 15 | class EE_Has_Many_Any_Relation extends EE_Has_Many_Relation |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Gets the SQL string for performing the join between this model and the other model. |
|
20 | - * |
|
21 | - * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
|
22 | - * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = |
|
23 | - * other_model_primary_table.fk" etc |
|
24 | - * @throws \EE_Error |
|
25 | - */ |
|
26 | - public function get_join_statement($model_relation_chain) |
|
27 | - { |
|
28 | - // create the sql string like |
|
29 | - // LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions |
|
30 | - $this_table_pk_field = $this->get_this_model()->get_primary_key_field(); |
|
31 | - $other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
32 | - $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
33 | - $model_relation_chain, |
|
34 | - $this->get_this_model()->get_this_model_name() |
|
35 | - ) . $this_table_pk_field->get_table_alias(); |
|
36 | - $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
37 | - $model_relation_chain, |
|
38 | - $this->get_other_model()->get_this_model_name() |
|
39 | - ) . $other_table_fk_field->get_table_alias(); |
|
40 | - $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
|
41 | - $field_with_model_name = $this->get_other_model()->get_field_containing_related_model_name(); |
|
18 | + /** |
|
19 | + * Gets the SQL string for performing the join between this model and the other model. |
|
20 | + * |
|
21 | + * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
|
22 | + * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = |
|
23 | + * other_model_primary_table.fk" etc |
|
24 | + * @throws \EE_Error |
|
25 | + */ |
|
26 | + public function get_join_statement($model_relation_chain) |
|
27 | + { |
|
28 | + // create the sql string like |
|
29 | + // LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions |
|
30 | + $this_table_pk_field = $this->get_this_model()->get_primary_key_field(); |
|
31 | + $other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
32 | + $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
33 | + $model_relation_chain, |
|
34 | + $this->get_this_model()->get_this_model_name() |
|
35 | + ) . $this_table_pk_field->get_table_alias(); |
|
36 | + $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
37 | + $model_relation_chain, |
|
38 | + $this->get_other_model()->get_this_model_name() |
|
39 | + ) . $other_table_fk_field->get_table_alias(); |
|
40 | + $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
|
41 | + $field_with_model_name = $this->get_other_model()->get_field_containing_related_model_name(); |
|
42 | 42 | |
43 | - return $this->_left_join( |
|
44 | - $fk_table, |
|
45 | - $fk_table_alias, |
|
46 | - $other_table_fk_field->get_table_column(), |
|
47 | - $pk_table_alias, |
|
48 | - $this_table_pk_field->get_table_column(), |
|
49 | - $fk_table_alias . '.' . $field_with_model_name->get_table_column() . "='" . $this->get_this_model()->get_this_model_name() . "'" |
|
50 | - ) |
|
51 | - . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
|
52 | - } |
|
43 | + return $this->_left_join( |
|
44 | + $fk_table, |
|
45 | + $fk_table_alias, |
|
46 | + $other_table_fk_field->get_table_column(), |
|
47 | + $pk_table_alias, |
|
48 | + $this_table_pk_field->get_table_column(), |
|
49 | + $fk_table_alias . '.' . $field_with_model_name->get_table_column() . "='" . $this->get_this_model()->get_this_model_name() . "'" |
|
50 | + ) |
|
51 | + . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Sets the other model object's foreign key to this model object's primary key. Feel free to do this manually if |
|
57 | - * you like. |
|
58 | - * |
|
59 | - * @param EE_Base_Class|int $this_obj_or_id |
|
60 | - * @param EE_Base_Class|int $other_obj_or_id |
|
61 | - * @param array $extra_join_model_fields_n_values |
|
62 | - * @return \EE_Base_Class |
|
63 | - * @throws \EE_Error |
|
64 | - */ |
|
65 | - public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) |
|
66 | - { |
|
67 | - $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
68 | - $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
55 | + /** |
|
56 | + * Sets the other model object's foreign key to this model object's primary key. Feel free to do this manually if |
|
57 | + * you like. |
|
58 | + * |
|
59 | + * @param EE_Base_Class|int $this_obj_or_id |
|
60 | + * @param EE_Base_Class|int $other_obj_or_id |
|
61 | + * @param array $extra_join_model_fields_n_values |
|
62 | + * @return \EE_Base_Class |
|
63 | + * @throws \EE_Error |
|
64 | + */ |
|
65 | + public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) |
|
66 | + { |
|
67 | + $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
68 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
69 | 69 | |
70 | - // find the field on the other model which is a foreign key to this model |
|
71 | - $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
72 | - // set that field on the other model to this model's ID |
|
73 | - $other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID()); |
|
74 | - $other_model_obj->set( |
|
75 | - $this->get_other_model()->get_field_containing_related_model_name()->get_name(), |
|
76 | - $this->get_this_model()->get_this_model_name() |
|
77 | - ); |
|
78 | - $other_model_obj->save(); |
|
79 | - return $other_model_obj; |
|
80 | - } |
|
70 | + // find the field on the other model which is a foreign key to this model |
|
71 | + $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
72 | + // set that field on the other model to this model's ID |
|
73 | + $other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID()); |
|
74 | + $other_model_obj->set( |
|
75 | + $this->get_other_model()->get_field_containing_related_model_name()->get_name(), |
|
76 | + $this->get_this_model()->get_this_model_name() |
|
77 | + ); |
|
78 | + $other_model_obj->save(); |
|
79 | + return $other_model_obj; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * Sets the other model object's foreign key to its default, instead of pointing to this model object. |
|
85 | - * If $other_obj_or_id doesn't have any other relations, this function is essentially orphaning it |
|
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 | - $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
96 | - // find the field on the other model which is a foreign key to this model |
|
97 | - $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
98 | - // set that field on the other model to this model's ID |
|
99 | - $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
100 | - $other_model_obj->set( |
|
101 | - $this->get_other_model()->get_field_containing_related_model_name()->get_name(), |
|
102 | - null, |
|
103 | - true |
|
104 | - ); |
|
105 | - $other_model_obj->save(); |
|
106 | - return $other_model_obj; |
|
107 | - } |
|
83 | + /** |
|
84 | + * Sets the other model object's foreign key to its default, instead of pointing to this model object. |
|
85 | + * If $other_obj_or_id doesn't have any other relations, this function is essentially orphaning it |
|
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 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
96 | + // find the field on the other model which is a foreign key to this model |
|
97 | + $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
98 | + // set that field on the other model to this model's ID |
|
99 | + $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
100 | + $other_model_obj->set( |
|
101 | + $this->get_other_model()->get_field_containing_related_model_name()->get_name(), |
|
102 | + null, |
|
103 | + true |
|
104 | + ); |
|
105 | + $other_model_obj->save(); |
|
106 | + return $other_model_obj; |
|
107 | + } |
|
108 | 108 | } |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
33 | 33 | $model_relation_chain, |
34 | 34 | $this->get_this_model()->get_this_model_name() |
35 | - ) . $this_table_pk_field->get_table_alias(); |
|
36 | - $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
35 | + ).$this_table_pk_field->get_table_alias(); |
|
36 | + $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
37 | 37 | $model_relation_chain, |
38 | 38 | $this->get_other_model()->get_this_model_name() |
39 | - ) . $other_table_fk_field->get_table_alias(); |
|
39 | + ).$other_table_fk_field->get_table_alias(); |
|
40 | 40 | $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
41 | 41 | $field_with_model_name = $this->get_other_model()->get_field_containing_related_model_name(); |
42 | 42 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $other_table_fk_field->get_table_column(), |
47 | 47 | $pk_table_alias, |
48 | 48 | $this_table_pk_field->get_table_column(), |
49 | - $fk_table_alias . '.' . $field_with_model_name->get_table_column() . "='" . $this->get_this_model()->get_this_model_name() . "'" |
|
49 | + $fk_table_alias.'.'.$field_with_model_name->get_table_column()."='".$this->get_this_model()->get_this_model_name()."'" |
|
50 | 50 | ) |
51 | 51 | . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
52 | 52 | } |
@@ -11,292 +11,292 @@ |
||
11 | 11 | class EEM_Status extends EEM_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 | 17 | |
18 | - /** |
|
19 | - * @return EEM_Status |
|
20 | - */ |
|
21 | - protected function __construct($timezone = null) |
|
22 | - { |
|
23 | - $this->singular_item = __('Status', 'event_espresso'); |
|
24 | - $this->plural_item = __('Stati', 'event_espresso'); |
|
25 | - $this->_tables = array( |
|
26 | - 'StatusTable' => new EE_Primary_Table('esp_status', 'STS_ID'), |
|
27 | - ); |
|
28 | - $this->_fields = array( |
|
29 | - 'StatusTable' => array( |
|
30 | - 'STS_ID' => new EE_Primary_Key_String_Field('STS_ID', __('Status ID', 'event_espresso')), |
|
31 | - 'STS_code' => new EE_Plain_Text_Field('STS_code', __('Status Code', 'event_espresso'), false, ''), |
|
32 | - 'STS_type' => new EE_Enum_Text_Field( |
|
33 | - 'STS_type', |
|
34 | - __("Type", "event_espresso"), |
|
35 | - false, |
|
36 | - 'event', |
|
37 | - array( |
|
38 | - 'event' => __("Event", "event_espresso"),// deprecated |
|
39 | - 'registration' => __("Registration", "event_espresso"), |
|
40 | - 'transaction' => __("Transaction", "event_espresso"), |
|
41 | - 'payment' => __("Payment", "event_espresso"), |
|
42 | - 'email' => __("Email", "event_espresso"), |
|
43 | - 'message' => __("Message", "event_espresso"), |
|
44 | - ) |
|
45 | - ), |
|
46 | - 'STS_can_edit' => new EE_Boolean_Field('STS_can_edit', __('Editable?', 'event_espresso'), false, false), |
|
47 | - 'STS_desc' => new EE_Simple_HTML_Field('STS_desc', __("Description", "event_espresso"), false, ''), |
|
48 | - 'STS_open' => new EE_Boolean_Field('STS_open', __("Open?", "event_espresso"), false, false), |
|
49 | - ), |
|
50 | - ); |
|
51 | - $this->_model_relations = array( |
|
52 | - 'Registration' => new EE_Has_Many_Relation(), |
|
53 | - 'Transaction' => new EE_Has_Many_Relation(), |
|
54 | - 'Payment' => new EE_Has_Many_Relation(), |
|
55 | - ); |
|
56 | - // this model is generally available for reading |
|
57 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
18 | + /** |
|
19 | + * @return EEM_Status |
|
20 | + */ |
|
21 | + protected function __construct($timezone = null) |
|
22 | + { |
|
23 | + $this->singular_item = __('Status', 'event_espresso'); |
|
24 | + $this->plural_item = __('Stati', 'event_espresso'); |
|
25 | + $this->_tables = array( |
|
26 | + 'StatusTable' => new EE_Primary_Table('esp_status', 'STS_ID'), |
|
27 | + ); |
|
28 | + $this->_fields = array( |
|
29 | + 'StatusTable' => array( |
|
30 | + 'STS_ID' => new EE_Primary_Key_String_Field('STS_ID', __('Status ID', 'event_espresso')), |
|
31 | + 'STS_code' => new EE_Plain_Text_Field('STS_code', __('Status Code', 'event_espresso'), false, ''), |
|
32 | + 'STS_type' => new EE_Enum_Text_Field( |
|
33 | + 'STS_type', |
|
34 | + __("Type", "event_espresso"), |
|
35 | + false, |
|
36 | + 'event', |
|
37 | + array( |
|
38 | + 'event' => __("Event", "event_espresso"),// deprecated |
|
39 | + 'registration' => __("Registration", "event_espresso"), |
|
40 | + 'transaction' => __("Transaction", "event_espresso"), |
|
41 | + 'payment' => __("Payment", "event_espresso"), |
|
42 | + 'email' => __("Email", "event_espresso"), |
|
43 | + 'message' => __("Message", "event_espresso"), |
|
44 | + ) |
|
45 | + ), |
|
46 | + 'STS_can_edit' => new EE_Boolean_Field('STS_can_edit', __('Editable?', 'event_espresso'), false, false), |
|
47 | + 'STS_desc' => new EE_Simple_HTML_Field('STS_desc', __("Description", "event_espresso"), false, ''), |
|
48 | + 'STS_open' => new EE_Boolean_Field('STS_open', __("Open?", "event_espresso"), false, false), |
|
49 | + ), |
|
50 | + ); |
|
51 | + $this->_model_relations = array( |
|
52 | + 'Registration' => new EE_Has_Many_Relation(), |
|
53 | + 'Transaction' => new EE_Has_Many_Relation(), |
|
54 | + 'Payment' => new EE_Has_Many_Relation(), |
|
55 | + ); |
|
56 | + // this model is generally available for reading |
|
57 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
58 | 58 | |
59 | - parent::__construct($timezone); |
|
60 | - } |
|
59 | + parent::__construct($timezone); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * This method provides the localized singular or plural string for a given status id |
|
65 | - * |
|
66 | - * @param array $statuses This should be an array of statuses in the format array( $status_id, $status_code ). |
|
67 | - * That way if there isn't a translation in the index we'll return the default code. |
|
68 | - * @param boolean $plural Whether to return plural string or not. Note, nearly all of the plural strings are the |
|
69 | - * same as the singular (in English), however, this may NOT be the case with other |
|
70 | - * languages |
|
71 | - * @param string $schema This can be either 'upper', 'lower', or 'sentence'. Basically indicates how we want |
|
72 | - * the status string returned ( UPPER, lower, Sentence) |
|
73 | - * @throws EE_Error |
|
74 | - * @return array an array of translated strings for the incoming status id. |
|
75 | - */ |
|
76 | - public function localized_status($statuses, $plural = false, $schema = 'upper') |
|
77 | - { |
|
78 | - // note these are all in lower case because ucwords() on upper case will NOT convert. |
|
79 | - $translation_array = array( |
|
80 | - EEM_Registration::status_id_pending_payment => array( |
|
81 | - __('pending payment', 'event_espresso'), // singular |
|
82 | - __('pending payments', 'event_espresso') // plural |
|
83 | - ), |
|
84 | - EEM_Registration::status_id_approved => array( |
|
85 | - __('approved', 'event_espresso'), // singular |
|
86 | - __('approved', 'event_espresso') // plural |
|
87 | - ), |
|
88 | - EEM_Registration::status_id_not_approved => array( |
|
89 | - __('not approved', 'event_espresso'), |
|
90 | - __('not approved', 'event_espresso'), |
|
91 | - ), |
|
92 | - EEM_Registration::status_id_cancelled => array( |
|
93 | - __('cancelled', 'event_espresso'), |
|
94 | - __('cancelled', 'event_espresso'), |
|
95 | - ), |
|
96 | - EEM_Registration::status_id_incomplete => array( |
|
97 | - __('incomplete', 'event_espresso'), |
|
98 | - __('incomplete', 'event_espresso'), |
|
99 | - ), |
|
100 | - EEM_Registration::status_id_declined => array( |
|
101 | - __('declined', 'event_espresso'), |
|
102 | - __('declined', 'event_espresso'), |
|
103 | - ), |
|
104 | - EEM_Registration::status_id_wait_list => array( |
|
105 | - __('wait list', 'event_espresso'), |
|
106 | - __('wait list', 'event_espresso'), |
|
107 | - ), |
|
108 | - EEM_Transaction::overpaid_status_code => array( |
|
109 | - __('overpaid', 'event_espresso'), |
|
110 | - __('overpaid', 'event_espresso'), |
|
111 | - ), |
|
112 | - EEM_Transaction::complete_status_code => array( |
|
113 | - __('complete', 'event_espresso'), |
|
114 | - __('complete', 'event_espresso'), |
|
115 | - ), |
|
116 | - EEM_Transaction::incomplete_status_code => array( |
|
117 | - __('incomplete', 'event_espresso'), |
|
118 | - __('incomplete', 'event_espresso'), |
|
119 | - ), |
|
120 | - EEM_Transaction::failed_status_code => array( |
|
121 | - __('failed', 'event_espresso'), |
|
122 | - __('failed', 'event_espresso'), |
|
123 | - ), |
|
124 | - EEM_Transaction::abandoned_status_code => array( |
|
125 | - __('abandoned', 'event_espresso'), |
|
126 | - __('abandoned', 'event_espresso'), |
|
127 | - ), |
|
128 | - EEM_Payment::status_id_approved => array( |
|
129 | - __('accepted', 'event_espresso'), |
|
130 | - __('accepted', 'event_espresso'), |
|
131 | - ), |
|
132 | - EEM_Payment::status_id_pending => array( |
|
133 | - __('pending', 'event_espresso'), |
|
134 | - __('pending', 'event_espresso'), |
|
135 | - ), |
|
136 | - EEM_Payment::status_id_cancelled => array( |
|
137 | - __('cancelled', 'event_espresso'), |
|
138 | - __('cancelled', 'event_espresso'), |
|
139 | - ), |
|
140 | - EEM_Payment::status_id_declined => array( |
|
141 | - __('declined', 'event_espresso'), |
|
142 | - __('declined', 'event_espresso'), |
|
143 | - ), |
|
144 | - EEM_Payment::status_id_failed => array( |
|
145 | - __('failed', 'event_espresso'), |
|
146 | - __('failed', 'event_espresso'), |
|
147 | - ), |
|
148 | - // following statuses are NOT part of the EEM_Status but to keep things centralized we include in here. |
|
149 | - EEM_Event::sold_out => array( |
|
150 | - __('sold out', 'event_espresso'), |
|
151 | - __('sold out', 'event_espresso'), |
|
152 | - ), |
|
153 | - EEM_Event::postponed => array( |
|
154 | - __('postponed', 'event_espresso'), |
|
155 | - __('Postponed', 'event_espresso'), |
|
156 | - ), |
|
157 | - EEM_Event::cancelled => array( |
|
158 | - __('cancelled', 'event_espresso'), |
|
159 | - __('cancelled', 'event_espresso'), |
|
160 | - ), |
|
161 | - EE_Ticket::archived => array( |
|
162 | - __('archived', 'event_espresso'), |
|
163 | - __('archived', 'event_espresso'), |
|
164 | - ), |
|
165 | - EE_Ticket::expired => array( |
|
166 | - __('expired', 'event_espresso'), |
|
167 | - __('expired', 'event_espresso'), |
|
168 | - ), |
|
169 | - EE_Ticket::sold_out => array( |
|
170 | - __('sold out', 'event_espresso'), |
|
171 | - __('sold out', 'event_espresso'), |
|
172 | - ), |
|
173 | - EE_Ticket::pending => array( |
|
174 | - __('upcoming', 'event_espresso'), |
|
175 | - __('upcoming', 'event_espresso'), |
|
176 | - ), |
|
177 | - EE_Ticket::onsale => array( |
|
178 | - __('on sale', 'event_espresso'), |
|
179 | - __('on sale', 'event_espresso'), |
|
180 | - ), |
|
181 | - EE_Datetime::cancelled => array( |
|
182 | - __('cancelled', 'event_espresso'), |
|
183 | - __('cancelled', 'event_espresso'), |
|
184 | - ), |
|
185 | - EE_Datetime::sold_out => array( |
|
186 | - __('sold out', 'event_espresso'), |
|
187 | - __('sold out', 'event_espresso'), |
|
188 | - ), |
|
189 | - EE_Datetime::expired => array( |
|
190 | - __('expired', 'event_espresso'), |
|
191 | - __('expired', 'event_espresso'), |
|
192 | - ), |
|
193 | - EE_Datetime::inactive => array( |
|
194 | - __('inactive', 'event_espresso'), |
|
195 | - __('inactive', 'event_espresso'), |
|
196 | - ), |
|
197 | - EE_Datetime::upcoming => array( |
|
198 | - __('upcoming', 'event_espresso'), |
|
199 | - __('upcoming', 'event_espresso'), |
|
200 | - ), |
|
201 | - EE_Datetime::active => array( |
|
202 | - __('active', 'event_espresso'), |
|
203 | - __('active', 'event_espresso'), |
|
204 | - ), |
|
205 | - EE_Datetime::postponed => array( |
|
206 | - __('postponed', 'event_espresso'), |
|
207 | - __('postponed', 'event_espresso'), |
|
208 | - ), |
|
209 | - // messages related |
|
210 | - EEM_Message::status_sent => array( |
|
211 | - __('sent', 'event_espresso'), |
|
212 | - __('sent', 'event_espresso'), |
|
213 | - ), |
|
214 | - EEM_Message::status_idle => array( |
|
215 | - __('queued for sending', 'event_espresso'), |
|
216 | - __('queued for sending', 'event_espresso'), |
|
217 | - ), |
|
218 | - EEM_Message::status_failed => array( |
|
219 | - __('failed', 'event_espresso'), |
|
220 | - __('failed', 'event_espresso'), |
|
221 | - ), |
|
222 | - EEM_Message::status_debug_only => array( |
|
223 | - __('debug only', 'event_espresso'), |
|
224 | - __('debug only', 'event_espresso'), |
|
225 | - ), |
|
226 | - EEM_Message::status_messenger_executing => array( |
|
227 | - __('messenger is executing', 'event_espresso'), |
|
228 | - __('messenger is executing', 'event_espresso'), |
|
229 | - ), |
|
230 | - EEM_Message::status_resend => array( |
|
231 | - __('queued for resending', 'event_espresso'), |
|
232 | - __('queued for resending', 'event_espresso'), |
|
233 | - ), |
|
234 | - EEM_Message::status_incomplete => array( |
|
235 | - __('queued for generating', 'event_espresso'), |
|
236 | - __('queued for generating', 'event_espresso'), |
|
237 | - ), |
|
238 | - EEM_Message::status_retry => array( |
|
239 | - __('failed sending, can be retried', 'event_espresso'), |
|
240 | - __('failed sending, can be retried', 'event_espresso'), |
|
241 | - ), |
|
242 | - EEM_CPT_Base::post_status_publish => array( |
|
243 | - __('published', 'event_espresso'), |
|
244 | - __('published', 'event_espresso'), |
|
245 | - ), |
|
246 | - EEM_CPT_Base::post_status_future => array( |
|
247 | - __('scheduled', 'event_espresso'), |
|
248 | - __('scheduled', 'event_espresso'), |
|
249 | - ), |
|
250 | - EEM_CPT_Base::post_status_draft => array( |
|
251 | - __('draft', 'event_espresso'), |
|
252 | - __('draft', 'event_espresso'), |
|
253 | - ), |
|
254 | - EEM_CPT_Base::post_status_pending => array( |
|
255 | - __('pending', 'event_espresso'), |
|
256 | - __('pending', 'event_espresso'), |
|
257 | - ), |
|
258 | - EEM_CPT_Base::post_status_private => array( |
|
259 | - __('private', 'event_espresso'), |
|
260 | - __('private', 'event_espresso'), |
|
261 | - ), |
|
262 | - EEM_CPT_Base::post_status_trashed => array( |
|
263 | - __('trashed', 'event_espresso'), |
|
264 | - __('trashed', 'event_espresso'), |
|
265 | - ), |
|
266 | - ); |
|
63 | + /** |
|
64 | + * This method provides the localized singular or plural string for a given status id |
|
65 | + * |
|
66 | + * @param array $statuses This should be an array of statuses in the format array( $status_id, $status_code ). |
|
67 | + * That way if there isn't a translation in the index we'll return the default code. |
|
68 | + * @param boolean $plural Whether to return plural string or not. Note, nearly all of the plural strings are the |
|
69 | + * same as the singular (in English), however, this may NOT be the case with other |
|
70 | + * languages |
|
71 | + * @param string $schema This can be either 'upper', 'lower', or 'sentence'. Basically indicates how we want |
|
72 | + * the status string returned ( UPPER, lower, Sentence) |
|
73 | + * @throws EE_Error |
|
74 | + * @return array an array of translated strings for the incoming status id. |
|
75 | + */ |
|
76 | + public function localized_status($statuses, $plural = false, $schema = 'upper') |
|
77 | + { |
|
78 | + // note these are all in lower case because ucwords() on upper case will NOT convert. |
|
79 | + $translation_array = array( |
|
80 | + EEM_Registration::status_id_pending_payment => array( |
|
81 | + __('pending payment', 'event_espresso'), // singular |
|
82 | + __('pending payments', 'event_espresso') // plural |
|
83 | + ), |
|
84 | + EEM_Registration::status_id_approved => array( |
|
85 | + __('approved', 'event_espresso'), // singular |
|
86 | + __('approved', 'event_espresso') // plural |
|
87 | + ), |
|
88 | + EEM_Registration::status_id_not_approved => array( |
|
89 | + __('not approved', 'event_espresso'), |
|
90 | + __('not approved', 'event_espresso'), |
|
91 | + ), |
|
92 | + EEM_Registration::status_id_cancelled => array( |
|
93 | + __('cancelled', 'event_espresso'), |
|
94 | + __('cancelled', 'event_espresso'), |
|
95 | + ), |
|
96 | + EEM_Registration::status_id_incomplete => array( |
|
97 | + __('incomplete', 'event_espresso'), |
|
98 | + __('incomplete', 'event_espresso'), |
|
99 | + ), |
|
100 | + EEM_Registration::status_id_declined => array( |
|
101 | + __('declined', 'event_espresso'), |
|
102 | + __('declined', 'event_espresso'), |
|
103 | + ), |
|
104 | + EEM_Registration::status_id_wait_list => array( |
|
105 | + __('wait list', 'event_espresso'), |
|
106 | + __('wait list', 'event_espresso'), |
|
107 | + ), |
|
108 | + EEM_Transaction::overpaid_status_code => array( |
|
109 | + __('overpaid', 'event_espresso'), |
|
110 | + __('overpaid', 'event_espresso'), |
|
111 | + ), |
|
112 | + EEM_Transaction::complete_status_code => array( |
|
113 | + __('complete', 'event_espresso'), |
|
114 | + __('complete', 'event_espresso'), |
|
115 | + ), |
|
116 | + EEM_Transaction::incomplete_status_code => array( |
|
117 | + __('incomplete', 'event_espresso'), |
|
118 | + __('incomplete', 'event_espresso'), |
|
119 | + ), |
|
120 | + EEM_Transaction::failed_status_code => array( |
|
121 | + __('failed', 'event_espresso'), |
|
122 | + __('failed', 'event_espresso'), |
|
123 | + ), |
|
124 | + EEM_Transaction::abandoned_status_code => array( |
|
125 | + __('abandoned', 'event_espresso'), |
|
126 | + __('abandoned', 'event_espresso'), |
|
127 | + ), |
|
128 | + EEM_Payment::status_id_approved => array( |
|
129 | + __('accepted', 'event_espresso'), |
|
130 | + __('accepted', 'event_espresso'), |
|
131 | + ), |
|
132 | + EEM_Payment::status_id_pending => array( |
|
133 | + __('pending', 'event_espresso'), |
|
134 | + __('pending', 'event_espresso'), |
|
135 | + ), |
|
136 | + EEM_Payment::status_id_cancelled => array( |
|
137 | + __('cancelled', 'event_espresso'), |
|
138 | + __('cancelled', 'event_espresso'), |
|
139 | + ), |
|
140 | + EEM_Payment::status_id_declined => array( |
|
141 | + __('declined', 'event_espresso'), |
|
142 | + __('declined', 'event_espresso'), |
|
143 | + ), |
|
144 | + EEM_Payment::status_id_failed => array( |
|
145 | + __('failed', 'event_espresso'), |
|
146 | + __('failed', 'event_espresso'), |
|
147 | + ), |
|
148 | + // following statuses are NOT part of the EEM_Status but to keep things centralized we include in here. |
|
149 | + EEM_Event::sold_out => array( |
|
150 | + __('sold out', 'event_espresso'), |
|
151 | + __('sold out', 'event_espresso'), |
|
152 | + ), |
|
153 | + EEM_Event::postponed => array( |
|
154 | + __('postponed', 'event_espresso'), |
|
155 | + __('Postponed', 'event_espresso'), |
|
156 | + ), |
|
157 | + EEM_Event::cancelled => array( |
|
158 | + __('cancelled', 'event_espresso'), |
|
159 | + __('cancelled', 'event_espresso'), |
|
160 | + ), |
|
161 | + EE_Ticket::archived => array( |
|
162 | + __('archived', 'event_espresso'), |
|
163 | + __('archived', 'event_espresso'), |
|
164 | + ), |
|
165 | + EE_Ticket::expired => array( |
|
166 | + __('expired', 'event_espresso'), |
|
167 | + __('expired', 'event_espresso'), |
|
168 | + ), |
|
169 | + EE_Ticket::sold_out => array( |
|
170 | + __('sold out', 'event_espresso'), |
|
171 | + __('sold out', 'event_espresso'), |
|
172 | + ), |
|
173 | + EE_Ticket::pending => array( |
|
174 | + __('upcoming', 'event_espresso'), |
|
175 | + __('upcoming', 'event_espresso'), |
|
176 | + ), |
|
177 | + EE_Ticket::onsale => array( |
|
178 | + __('on sale', 'event_espresso'), |
|
179 | + __('on sale', 'event_espresso'), |
|
180 | + ), |
|
181 | + EE_Datetime::cancelled => array( |
|
182 | + __('cancelled', 'event_espresso'), |
|
183 | + __('cancelled', 'event_espresso'), |
|
184 | + ), |
|
185 | + EE_Datetime::sold_out => array( |
|
186 | + __('sold out', 'event_espresso'), |
|
187 | + __('sold out', 'event_espresso'), |
|
188 | + ), |
|
189 | + EE_Datetime::expired => array( |
|
190 | + __('expired', 'event_espresso'), |
|
191 | + __('expired', 'event_espresso'), |
|
192 | + ), |
|
193 | + EE_Datetime::inactive => array( |
|
194 | + __('inactive', 'event_espresso'), |
|
195 | + __('inactive', 'event_espresso'), |
|
196 | + ), |
|
197 | + EE_Datetime::upcoming => array( |
|
198 | + __('upcoming', 'event_espresso'), |
|
199 | + __('upcoming', 'event_espresso'), |
|
200 | + ), |
|
201 | + EE_Datetime::active => array( |
|
202 | + __('active', 'event_espresso'), |
|
203 | + __('active', 'event_espresso'), |
|
204 | + ), |
|
205 | + EE_Datetime::postponed => array( |
|
206 | + __('postponed', 'event_espresso'), |
|
207 | + __('postponed', 'event_espresso'), |
|
208 | + ), |
|
209 | + // messages related |
|
210 | + EEM_Message::status_sent => array( |
|
211 | + __('sent', 'event_espresso'), |
|
212 | + __('sent', 'event_espresso'), |
|
213 | + ), |
|
214 | + EEM_Message::status_idle => array( |
|
215 | + __('queued for sending', 'event_espresso'), |
|
216 | + __('queued for sending', 'event_espresso'), |
|
217 | + ), |
|
218 | + EEM_Message::status_failed => array( |
|
219 | + __('failed', 'event_espresso'), |
|
220 | + __('failed', 'event_espresso'), |
|
221 | + ), |
|
222 | + EEM_Message::status_debug_only => array( |
|
223 | + __('debug only', 'event_espresso'), |
|
224 | + __('debug only', 'event_espresso'), |
|
225 | + ), |
|
226 | + EEM_Message::status_messenger_executing => array( |
|
227 | + __('messenger is executing', 'event_espresso'), |
|
228 | + __('messenger is executing', 'event_espresso'), |
|
229 | + ), |
|
230 | + EEM_Message::status_resend => array( |
|
231 | + __('queued for resending', 'event_espresso'), |
|
232 | + __('queued for resending', 'event_espresso'), |
|
233 | + ), |
|
234 | + EEM_Message::status_incomplete => array( |
|
235 | + __('queued for generating', 'event_espresso'), |
|
236 | + __('queued for generating', 'event_espresso'), |
|
237 | + ), |
|
238 | + EEM_Message::status_retry => array( |
|
239 | + __('failed sending, can be retried', 'event_espresso'), |
|
240 | + __('failed sending, can be retried', 'event_espresso'), |
|
241 | + ), |
|
242 | + EEM_CPT_Base::post_status_publish => array( |
|
243 | + __('published', 'event_espresso'), |
|
244 | + __('published', 'event_espresso'), |
|
245 | + ), |
|
246 | + EEM_CPT_Base::post_status_future => array( |
|
247 | + __('scheduled', 'event_espresso'), |
|
248 | + __('scheduled', 'event_espresso'), |
|
249 | + ), |
|
250 | + EEM_CPT_Base::post_status_draft => array( |
|
251 | + __('draft', 'event_espresso'), |
|
252 | + __('draft', 'event_espresso'), |
|
253 | + ), |
|
254 | + EEM_CPT_Base::post_status_pending => array( |
|
255 | + __('pending', 'event_espresso'), |
|
256 | + __('pending', 'event_espresso'), |
|
257 | + ), |
|
258 | + EEM_CPT_Base::post_status_private => array( |
|
259 | + __('private', 'event_espresso'), |
|
260 | + __('private', 'event_espresso'), |
|
261 | + ), |
|
262 | + EEM_CPT_Base::post_status_trashed => array( |
|
263 | + __('trashed', 'event_espresso'), |
|
264 | + __('trashed', 'event_espresso'), |
|
265 | + ), |
|
266 | + ); |
|
267 | 267 | |
268 | - $translation_array = apply_filters('FHEE__EEM_Status__localized_status__translation_array', $translation_array); |
|
268 | + $translation_array = apply_filters('FHEE__EEM_Status__localized_status__translation_array', $translation_array); |
|
269 | 269 | |
270 | - if (! is_array($statuses)) { |
|
271 | - throw new EE_Error(__( |
|
272 | - 'The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code', |
|
273 | - 'event_espresso' |
|
274 | - )); |
|
275 | - } |
|
270 | + if (! is_array($statuses)) { |
|
271 | + throw new EE_Error(__( |
|
272 | + 'The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code', |
|
273 | + 'event_espresso' |
|
274 | + )); |
|
275 | + } |
|
276 | 276 | |
277 | - $translation = array(); |
|
277 | + $translation = array(); |
|
278 | 278 | |
279 | - foreach ($statuses as $id => $code) { |
|
280 | - if (isset($translation_array[ $id ])) { |
|
281 | - $translation[ $id ] = $plural ? $translation_array[ $id ][1] : $translation_array[ $id ][0]; |
|
282 | - } else { |
|
283 | - $translation[ $id ] = $code; |
|
284 | - } |
|
279 | + foreach ($statuses as $id => $code) { |
|
280 | + if (isset($translation_array[ $id ])) { |
|
281 | + $translation[ $id ] = $plural ? $translation_array[ $id ][1] : $translation_array[ $id ][0]; |
|
282 | + } else { |
|
283 | + $translation[ $id ] = $code; |
|
284 | + } |
|
285 | 285 | |
286 | - // schema |
|
287 | - switch ($schema) { |
|
288 | - case 'lower': |
|
289 | - $translation[ $id ] = strtolower($translation[ $id ]); // even though these start in lower case, this will catch any statuses added via filter. |
|
290 | - break; |
|
291 | - case 'sentence': |
|
292 | - $translation[ $id ] = ucwords($translation[ $id ]); |
|
293 | - break; |
|
294 | - case 'upper': |
|
295 | - $translation[ $id ] = strtoupper($translation[ $id ]); |
|
296 | - break; |
|
297 | - } |
|
298 | - } |
|
286 | + // schema |
|
287 | + switch ($schema) { |
|
288 | + case 'lower': |
|
289 | + $translation[ $id ] = strtolower($translation[ $id ]); // even though these start in lower case, this will catch any statuses added via filter. |
|
290 | + break; |
|
291 | + case 'sentence': |
|
292 | + $translation[ $id ] = ucwords($translation[ $id ]); |
|
293 | + break; |
|
294 | + case 'upper': |
|
295 | + $translation[ $id ] = strtoupper($translation[ $id ]); |
|
296 | + break; |
|
297 | + } |
|
298 | + } |
|
299 | 299 | |
300 | - return $translation; |
|
301 | - } |
|
300 | + return $translation; |
|
301 | + } |
|
302 | 302 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | false, |
36 | 36 | 'event', |
37 | 37 | array( |
38 | - 'event' => __("Event", "event_espresso"),// deprecated |
|
38 | + 'event' => __("Event", "event_espresso"), // deprecated |
|
39 | 39 | 'registration' => __("Registration", "event_espresso"), |
40 | 40 | 'transaction' => __("Transaction", "event_espresso"), |
41 | 41 | 'payment' => __("Payment", "event_espresso"), |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'Payment' => new EE_Has_Many_Relation(), |
55 | 55 | ); |
56 | 56 | // this model is generally available for reading |
57 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
57 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
58 | 58 | |
59 | 59 | parent::__construct($timezone); |
60 | 60 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | |
268 | 268 | $translation_array = apply_filters('FHEE__EEM_Status__localized_status__translation_array', $translation_array); |
269 | 269 | |
270 | - if (! is_array($statuses)) { |
|
270 | + if ( ! is_array($statuses)) { |
|
271 | 271 | throw new EE_Error(__( |
272 | 272 | 'The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code', |
273 | 273 | 'event_espresso' |
@@ -277,22 +277,22 @@ discard block |
||
277 | 277 | $translation = array(); |
278 | 278 | |
279 | 279 | foreach ($statuses as $id => $code) { |
280 | - if (isset($translation_array[ $id ])) { |
|
281 | - $translation[ $id ] = $plural ? $translation_array[ $id ][1] : $translation_array[ $id ][0]; |
|
280 | + if (isset($translation_array[$id])) { |
|
281 | + $translation[$id] = $plural ? $translation_array[$id][1] : $translation_array[$id][0]; |
|
282 | 282 | } else { |
283 | - $translation[ $id ] = $code; |
|
283 | + $translation[$id] = $code; |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | // schema |
287 | 287 | switch ($schema) { |
288 | 288 | case 'lower': |
289 | - $translation[ $id ] = strtolower($translation[ $id ]); // even though these start in lower case, this will catch any statuses added via filter. |
|
289 | + $translation[$id] = strtolower($translation[$id]); // even though these start in lower case, this will catch any statuses added via filter. |
|
290 | 290 | break; |
291 | 291 | case 'sentence': |
292 | - $translation[ $id ] = ucwords($translation[ $id ]); |
|
292 | + $translation[$id] = ucwords($translation[$id]); |
|
293 | 293 | break; |
294 | 294 | case 'upper': |
295 | - $translation[ $id ] = strtoupper($translation[ $id ]); |
|
295 | + $translation[$id] = strtoupper($translation[$id]); |
|
296 | 296 | break; |
297 | 297 | } |
298 | 298 | } |
@@ -7,33 +7,33 @@ |
||
7 | 7 | */ |
8 | 8 | class EEM_Event_Question_Group extends EEM_Base |
9 | 9 | { |
10 | - // private instance of the Attendee object |
|
11 | - protected static $_instance = null; |
|
10 | + // private instance of the Attendee object |
|
11 | + protected static $_instance = null; |
|
12 | 12 | |
13 | - protected function __construct($timezone = null) |
|
14 | - { |
|
15 | - $this->singular_item = __('Event to Question Group Link', 'event_espresso'); |
|
16 | - $this->plural_item = __('Event to Question Group Links', 'event_espresso'); |
|
17 | - $this->_tables = array( |
|
18 | - 'Event_Question_Group'=>new EE_Primary_Table('esp_event_question_group', 'EQG_ID') |
|
19 | - ); |
|
20 | - $this->_fields = array( |
|
21 | - 'Event_Question_Group'=>array( |
|
22 | - 'EQG_ID'=>new EE_Primary_Key_Int_Field('EQG_ID', __('Event to Question Group Link ID', 'event_espresso')), |
|
23 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
24 | - 'QSG_ID'=>new EE_Foreign_Key_Int_Field('QSG_ID', __('Question Group Id', 'event_espresso'), false, 0, 'Question_Group'), |
|
25 | - 'EQG_primary'=>new EE_Boolean_Field('EQG_primary', __('Flag indicating question is only for primary attendees', 'event_espresso'), false, false) |
|
26 | - ) |
|
27 | - ); |
|
28 | - $this->_model_relations = array( |
|
29 | - 'Event'=>new EE_Belongs_To_Relation(), |
|
30 | - 'Question_Group'=>new EE_Belongs_To_Relation() |
|
31 | - ); |
|
32 | - // this model is generally available for reading |
|
33 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public('Event'); |
|
34 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
35 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
36 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit); |
|
37 | - parent::__construct($timezone); |
|
38 | - } |
|
13 | + protected function __construct($timezone = null) |
|
14 | + { |
|
15 | + $this->singular_item = __('Event to Question Group Link', 'event_espresso'); |
|
16 | + $this->plural_item = __('Event to Question Group Links', 'event_espresso'); |
|
17 | + $this->_tables = array( |
|
18 | + 'Event_Question_Group'=>new EE_Primary_Table('esp_event_question_group', 'EQG_ID') |
|
19 | + ); |
|
20 | + $this->_fields = array( |
|
21 | + 'Event_Question_Group'=>array( |
|
22 | + 'EQG_ID'=>new EE_Primary_Key_Int_Field('EQG_ID', __('Event to Question Group Link ID', 'event_espresso')), |
|
23 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
24 | + 'QSG_ID'=>new EE_Foreign_Key_Int_Field('QSG_ID', __('Question Group Id', 'event_espresso'), false, 0, 'Question_Group'), |
|
25 | + 'EQG_primary'=>new EE_Boolean_Field('EQG_primary', __('Flag indicating question is only for primary attendees', 'event_espresso'), false, false) |
|
26 | + ) |
|
27 | + ); |
|
28 | + $this->_model_relations = array( |
|
29 | + 'Event'=>new EE_Belongs_To_Relation(), |
|
30 | + 'Question_Group'=>new EE_Belongs_To_Relation() |
|
31 | + ); |
|
32 | + // this model is generally available for reading |
|
33 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public('Event'); |
|
34 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
35 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
36 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit); |
|
37 | + parent::__construct($timezone); |
|
38 | + } |
|
39 | 39 | } |
@@ -30,10 +30,10 @@ |
||
30 | 30 | 'Question_Group'=>new EE_Belongs_To_Relation() |
31 | 31 | ); |
32 | 32 | // this model is generally available for reading |
33 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public('Event'); |
|
34 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
35 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
36 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit); |
|
33 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event'); |
|
34 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
35 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
36 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit); |
|
37 | 37 | parent::__construct($timezone); |
38 | 38 | } |
39 | 39 | } |
@@ -11,43 +11,43 @@ |
||
11 | 11 | class EEM_Ticket_Price extends EEM_Base |
12 | 12 | { |
13 | 13 | |
14 | - // private instance of the EEM_Ticket_Price object |
|
15 | - protected static $_instance = null; |
|
14 | + // private instance of the EEM_Ticket_Price object |
|
15 | + protected static $_instance = null; |
|
16 | 16 | |
17 | - /** |
|
18 | - * private constructor to prevent direct creation |
|
19 | - * @Constructor |
|
20 | - * @access protected |
|
21 | - * @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) |
|
22 | - * @return void |
|
23 | - */ |
|
24 | - protected function __construct($timezone) |
|
25 | - { |
|
26 | - $this->singular_item = __('Ticket Price', 'event_espresso'); |
|
27 | - $this->plural_item = __('Ticket Prices', 'event_espresso'); |
|
17 | + /** |
|
18 | + * private constructor to prevent direct creation |
|
19 | + * @Constructor |
|
20 | + * @access protected |
|
21 | + * @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) |
|
22 | + * @return void |
|
23 | + */ |
|
24 | + protected function __construct($timezone) |
|
25 | + { |
|
26 | + $this->singular_item = __('Ticket Price', 'event_espresso'); |
|
27 | + $this->plural_item = __('Ticket Prices', 'event_espresso'); |
|
28 | 28 | |
29 | - $this->_tables = array( |
|
30 | - 'Ticket_Price'=>new EE_Primary_Table('esp_ticket_price', 'TKP_ID') |
|
31 | - ); |
|
32 | - $this->_fields = array( |
|
33 | - 'Ticket_Price'=> array( |
|
34 | - 'TKP_ID'=>new EE_Primary_Key_Int_Field('TKP_ID', 'Ticket Price ID'), |
|
35 | - 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', 'Ticket Id', false, 0, 'Ticket'), |
|
36 | - 'PRC_ID'=>new EE_Foreign_Key_Int_Field('PRC_ID', 'Price ID', false, 0, 'Price'), |
|
37 | - ) |
|
38 | - ); |
|
39 | - $this->_model_relations = array( |
|
40 | - 'Ticket'=>new EE_Belongs_To_Relation(), |
|
41 | - 'Price'=>new EE_Belongs_To_Relation() |
|
42 | - ); |
|
43 | - $this->_model_chain_to_wp_user = 'Ticket'; |
|
44 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
45 | - // account for default tickets in the caps |
|
46 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
47 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
48 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
49 | - // follow the caps of the ticket |
|
50 | - $this->_caps_slug = 'tickets'; |
|
51 | - parent::__construct($timezone); |
|
52 | - } |
|
29 | + $this->_tables = array( |
|
30 | + 'Ticket_Price'=>new EE_Primary_Table('esp_ticket_price', 'TKP_ID') |
|
31 | + ); |
|
32 | + $this->_fields = array( |
|
33 | + 'Ticket_Price'=> array( |
|
34 | + 'TKP_ID'=>new EE_Primary_Key_Int_Field('TKP_ID', 'Ticket Price ID'), |
|
35 | + 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', 'Ticket Id', false, 0, 'Ticket'), |
|
36 | + 'PRC_ID'=>new EE_Foreign_Key_Int_Field('PRC_ID', 'Price ID', false, 0, 'Price'), |
|
37 | + ) |
|
38 | + ); |
|
39 | + $this->_model_relations = array( |
|
40 | + 'Ticket'=>new EE_Belongs_To_Relation(), |
|
41 | + 'Price'=>new EE_Belongs_To_Relation() |
|
42 | + ); |
|
43 | + $this->_model_chain_to_wp_user = 'Ticket'; |
|
44 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
45 | + // account for default tickets in the caps |
|
46 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
47 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
48 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
49 | + // follow the caps of the ticket |
|
50 | + $this->_caps_slug = 'tickets'; |
|
51 | + parent::__construct($timezone); |
|
52 | + } |
|
53 | 53 | } |
@@ -41,11 +41,11 @@ |
||
41 | 41 | 'Price'=>new EE_Belongs_To_Relation() |
42 | 42 | ); |
43 | 43 | $this->_model_chain_to_wp_user = 'Ticket'; |
44 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
44 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
45 | 45 | // account for default tickets in the caps |
46 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
47 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
48 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
46 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
47 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
48 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
49 | 49 | // follow the caps of the ticket |
50 | 50 | $this->_caps_slug = 'tickets'; |
51 | 51 | parent::__construct($timezone); |
@@ -6,45 +6,45 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_Index |
8 | 8 | { |
9 | - protected $_name; |
|
10 | - protected $_field_names; |
|
11 | - protected $_model_name; |
|
12 | - public function __construct($fields) |
|
13 | - { |
|
14 | - $this->_field_names = $fields; |
|
15 | - } |
|
16 | - public function _construct_finalize($name, $model_name) |
|
17 | - { |
|
18 | - $this->_name = $name; |
|
19 | - $this->_model_name = $model_name; |
|
20 | - } |
|
21 | - public function field_names() |
|
22 | - { |
|
23 | - return $this->_field_names; |
|
24 | - } |
|
25 | - /** |
|
26 | - * Internally used by get_this_model() and get_other_model() |
|
27 | - * @param string $model_name like Event, Question_Group, etc. omit the EEM_ |
|
28 | - * @return EEM_Base |
|
29 | - */ |
|
30 | - protected function _get_model($model_name) |
|
31 | - { |
|
32 | - $modelInstance=call_user_func("EEM_".$model_name."::instance"); |
|
33 | - return $modelInstance; |
|
34 | - } |
|
35 | - /** |
|
36 | - * Gets all the fields for this index |
|
37 | - * @return EE_Model_Field_Base[] |
|
38 | - */ |
|
39 | - public function fields() |
|
40 | - { |
|
41 | - $fields = array(); |
|
42 | - $model = $this->_get_model($this->_model_name); |
|
43 | - foreach ($model->field_settings() as $field_name => $field_obj) { |
|
44 | - if (in_array($field_name, $this->field_names())) { |
|
45 | - $fields[ $field_name ] = $field_obj; |
|
46 | - } |
|
47 | - } |
|
48 | - return $fields; |
|
49 | - } |
|
9 | + protected $_name; |
|
10 | + protected $_field_names; |
|
11 | + protected $_model_name; |
|
12 | + public function __construct($fields) |
|
13 | + { |
|
14 | + $this->_field_names = $fields; |
|
15 | + } |
|
16 | + public function _construct_finalize($name, $model_name) |
|
17 | + { |
|
18 | + $this->_name = $name; |
|
19 | + $this->_model_name = $model_name; |
|
20 | + } |
|
21 | + public function field_names() |
|
22 | + { |
|
23 | + return $this->_field_names; |
|
24 | + } |
|
25 | + /** |
|
26 | + * Internally used by get_this_model() and get_other_model() |
|
27 | + * @param string $model_name like Event, Question_Group, etc. omit the EEM_ |
|
28 | + * @return EEM_Base |
|
29 | + */ |
|
30 | + protected function _get_model($model_name) |
|
31 | + { |
|
32 | + $modelInstance=call_user_func("EEM_".$model_name."::instance"); |
|
33 | + return $modelInstance; |
|
34 | + } |
|
35 | + /** |
|
36 | + * Gets all the fields for this index |
|
37 | + * @return EE_Model_Field_Base[] |
|
38 | + */ |
|
39 | + public function fields() |
|
40 | + { |
|
41 | + $fields = array(); |
|
42 | + $model = $this->_get_model($this->_model_name); |
|
43 | + foreach ($model->field_settings() as $field_name => $field_obj) { |
|
44 | + if (in_array($field_name, $this->field_names())) { |
|
45 | + $fields[ $field_name ] = $field_obj; |
|
46 | + } |
|
47 | + } |
|
48 | + return $fields; |
|
49 | + } |
|
50 | 50 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | protected function _get_model($model_name) |
31 | 31 | { |
32 | - $modelInstance=call_user_func("EEM_".$model_name."::instance"); |
|
32 | + $modelInstance = call_user_func("EEM_".$model_name."::instance"); |
|
33 | 33 | return $modelInstance; |
34 | 34 | } |
35 | 35 | /** |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $model = $this->_get_model($this->_model_name); |
43 | 43 | foreach ($model->field_settings() as $field_name => $field_obj) { |
44 | 44 | if (in_array($field_name, $this->field_names())) { |
45 | - $fields[ $field_name ] = $field_obj; |
|
45 | + $fields[$field_name] = $field_obj; |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | return $fields; |
@@ -9,164 +9,164 @@ |
||
9 | 9 | abstract class EE_Table_Base |
10 | 10 | { |
11 | 11 | |
12 | - /** |
|
13 | - * This holds the table_name without the table prefix. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - public $_table_name; |
|
18 | - |
|
19 | - |
|
20 | - /** |
|
21 | - * This holds what is used as the alias for the table in queries. |
|
22 | - * |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - public $_table_alias; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * Table's private key column |
|
30 | - * |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - protected $_pk_column; |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * Whether this table is a global table (in multisite) or specific to site. |
|
38 | - * |
|
39 | - * @var bool |
|
40 | - */ |
|
41 | - protected $_global; |
|
42 | - |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * @global wpdb $wpdb |
|
47 | - * @param string $table_name with or without wpdb prefix |
|
48 | - * @param string $pk_column |
|
49 | - * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite |
|
50 | - * install, or whether each site on a multisite install has a copy of this table |
|
51 | - */ |
|
52 | - public function __construct($table_name, $pk_column, $global = false) |
|
53 | - { |
|
54 | - $this->_global = $global; |
|
55 | - $prefix = $this->get_table_prefix(); |
|
56 | - // if they added the prefix, let's remove it because we delay adding the prefix until right when its needed. |
|
57 | - if (strpos($table_name, $prefix) === 0) { |
|
58 | - $table_name = ltrim($table_name, $prefix); |
|
59 | - } |
|
60 | - $this->_table_name = $table_name; |
|
61 | - $this->_pk_column = $pk_column; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * This returns the table prefix for the current model state. |
|
68 | - * |
|
69 | - * @global wpdb $wpdb |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - public function get_table_prefix() |
|
73 | - { |
|
74 | - global $wpdb; |
|
75 | - if ($this->_global) { |
|
76 | - $prefix = $wpdb->base_prefix; |
|
77 | - } else { |
|
78 | - $prefix = $wpdb->get_blog_prefix(EEM_Base::get_model_query_blog_id()); |
|
79 | - } |
|
80 | - return $prefix; |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * Used to set the table_alias property |
|
87 | - * |
|
88 | - * @param string $table_alias |
|
89 | - */ |
|
90 | - public function _construct_finalize_with_alias($table_alias) |
|
91 | - { |
|
92 | - $this->_table_alias = $table_alias; |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * Returns the fully qualified table name for the database (includes the table prefix current for the blog). |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - public function get_table_name() |
|
103 | - { |
|
104 | - return $this->get_table_prefix() . $this->_table_name; |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * Provides what is currently set as the alias for the table to be used in queries. |
|
111 | - * |
|
112 | - * @return string |
|
113 | - * @throws EE_Error |
|
114 | - */ |
|
115 | - public function get_table_alias() |
|
116 | - { |
|
117 | - if (! $this->_table_alias) { |
|
118 | - throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?"); |
|
119 | - } |
|
120 | - return $this->_table_alias; |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * @return string name of column of PK |
|
127 | - */ |
|
128 | - public function get_pk_column() |
|
129 | - { |
|
130 | - return $this->_pk_column; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * returns a string with the table alias, a period, and the private key's column. |
|
137 | - * |
|
138 | - * @return string |
|
139 | - */ |
|
140 | - public function get_fully_qualified_pk_column() |
|
141 | - { |
|
142 | - $sql = $this->get_table_alias() . "." . $this->get_pk_column(); |
|
143 | - return $sql; |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * returns the special sql for a inner select with a limit. |
|
150 | - * |
|
151 | - * @return string SQL select |
|
152 | - */ |
|
153 | - public function get_select_join_limit($limit) |
|
154 | - { |
|
155 | - $limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int) $limit; |
|
156 | - $SQL = SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias; |
|
157 | - return $SQL; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * Returns whether or not htis is a global table (ie, on multisite there's |
|
164 | - * only one of these tables, on the main blog) |
|
165 | - * |
|
166 | - * @return boolean |
|
167 | - */ |
|
168 | - public function is_global() |
|
169 | - { |
|
170 | - return $this->_global; |
|
171 | - } |
|
12 | + /** |
|
13 | + * This holds the table_name without the table prefix. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + public $_table_name; |
|
18 | + |
|
19 | + |
|
20 | + /** |
|
21 | + * This holds what is used as the alias for the table in queries. |
|
22 | + * |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + public $_table_alias; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * Table's private key column |
|
30 | + * |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + protected $_pk_column; |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * Whether this table is a global table (in multisite) or specific to site. |
|
38 | + * |
|
39 | + * @var bool |
|
40 | + */ |
|
41 | + protected $_global; |
|
42 | + |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * @global wpdb $wpdb |
|
47 | + * @param string $table_name with or without wpdb prefix |
|
48 | + * @param string $pk_column |
|
49 | + * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite |
|
50 | + * install, or whether each site on a multisite install has a copy of this table |
|
51 | + */ |
|
52 | + public function __construct($table_name, $pk_column, $global = false) |
|
53 | + { |
|
54 | + $this->_global = $global; |
|
55 | + $prefix = $this->get_table_prefix(); |
|
56 | + // if they added the prefix, let's remove it because we delay adding the prefix until right when its needed. |
|
57 | + if (strpos($table_name, $prefix) === 0) { |
|
58 | + $table_name = ltrim($table_name, $prefix); |
|
59 | + } |
|
60 | + $this->_table_name = $table_name; |
|
61 | + $this->_pk_column = $pk_column; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * This returns the table prefix for the current model state. |
|
68 | + * |
|
69 | + * @global wpdb $wpdb |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + public function get_table_prefix() |
|
73 | + { |
|
74 | + global $wpdb; |
|
75 | + if ($this->_global) { |
|
76 | + $prefix = $wpdb->base_prefix; |
|
77 | + } else { |
|
78 | + $prefix = $wpdb->get_blog_prefix(EEM_Base::get_model_query_blog_id()); |
|
79 | + } |
|
80 | + return $prefix; |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * Used to set the table_alias property |
|
87 | + * |
|
88 | + * @param string $table_alias |
|
89 | + */ |
|
90 | + public function _construct_finalize_with_alias($table_alias) |
|
91 | + { |
|
92 | + $this->_table_alias = $table_alias; |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * Returns the fully qualified table name for the database (includes the table prefix current for the blog). |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + public function get_table_name() |
|
103 | + { |
|
104 | + return $this->get_table_prefix() . $this->_table_name; |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * Provides what is currently set as the alias for the table to be used in queries. |
|
111 | + * |
|
112 | + * @return string |
|
113 | + * @throws EE_Error |
|
114 | + */ |
|
115 | + public function get_table_alias() |
|
116 | + { |
|
117 | + if (! $this->_table_alias) { |
|
118 | + throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?"); |
|
119 | + } |
|
120 | + return $this->_table_alias; |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * @return string name of column of PK |
|
127 | + */ |
|
128 | + public function get_pk_column() |
|
129 | + { |
|
130 | + return $this->_pk_column; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * returns a string with the table alias, a period, and the private key's column. |
|
137 | + * |
|
138 | + * @return string |
|
139 | + */ |
|
140 | + public function get_fully_qualified_pk_column() |
|
141 | + { |
|
142 | + $sql = $this->get_table_alias() . "." . $this->get_pk_column(); |
|
143 | + return $sql; |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * returns the special sql for a inner select with a limit. |
|
150 | + * |
|
151 | + * @return string SQL select |
|
152 | + */ |
|
153 | + public function get_select_join_limit($limit) |
|
154 | + { |
|
155 | + $limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int) $limit; |
|
156 | + $SQL = SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias; |
|
157 | + return $SQL; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * Returns whether or not htis is a global table (ie, on multisite there's |
|
164 | + * only one of these tables, on the main blog) |
|
165 | + * |
|
166 | + * @return boolean |
|
167 | + */ |
|
168 | + public function is_global() |
|
169 | + { |
|
170 | + return $this->_global; |
|
171 | + } |
|
172 | 172 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function get_table_name() |
103 | 103 | { |
104 | - return $this->get_table_prefix() . $this->_table_name; |
|
104 | + return $this->get_table_prefix().$this->_table_name; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function get_table_alias() |
116 | 116 | { |
117 | - if (! $this->_table_alias) { |
|
117 | + if ( ! $this->_table_alias) { |
|
118 | 118 | throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?"); |
119 | 119 | } |
120 | 120 | return $this->_table_alias; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function get_fully_qualified_pk_column() |
141 | 141 | { |
142 | - $sql = $this->get_table_alias() . "." . $this->get_pk_column(); |
|
142 | + $sql = $this->get_table_alias().".".$this->get_pk_column(); |
|
143 | 143 | return $sql; |
144 | 144 | } |
145 | 145 | |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function get_select_join_limit($limit) |
154 | 154 | { |
155 | - $limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int) $limit; |
|
156 | - $SQL = SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias; |
|
155 | + $limit = is_array($limit) ? 'LIMIT '.implode(',', array_map('intval', $limit)) : 'LIMIT '.(int) $limit; |
|
156 | + $SQL = SP.'(SELECT * FROM '.$this->_table_name.SP.$limit.') AS '.$this->_table_alias; |
|
157 | 157 | return $SQL; |
158 | 158 | } |
159 | 159 |
@@ -6,5 +6,5 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_Unique_Index extends EE_Index |
8 | 8 | { |
9 | - // yep, actually the same as index right now |
|
9 | + // yep, actually the same as index right now |
|
10 | 10 | } |
@@ -7,24 +7,24 @@ |
||
7 | 7 | class EE_Primary_Table extends EE_Table_Base |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * |
|
12 | - * @global type $wpdb |
|
13 | - * @param string $table_name with or without wpdb prefix |
|
14 | - * @param string $pk_column name of primary key column |
|
15 | - * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite install, |
|
16 | - * or whether each site on a multisite install has a copy of this table |
|
17 | - */ |
|
18 | - public function __construct($table_name, $pk_column = null, $global = false) |
|
19 | - { |
|
20 | - parent::__construct($table_name, $pk_column, $global); |
|
21 | - } |
|
22 | - /** |
|
23 | - * Gets SQL for this table and assigning it an alias. Eg " wp_esp_attendee AS Attendee " |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function get_table_sql() |
|
27 | - { |
|
28 | - return " ".$this->get_table_name()." AS ".$this->get_table_alias()." "; |
|
29 | - } |
|
10 | + /** |
|
11 | + * |
|
12 | + * @global type $wpdb |
|
13 | + * @param string $table_name with or without wpdb prefix |
|
14 | + * @param string $pk_column name of primary key column |
|
15 | + * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite install, |
|
16 | + * or whether each site on a multisite install has a copy of this table |
|
17 | + */ |
|
18 | + public function __construct($table_name, $pk_column = null, $global = false) |
|
19 | + { |
|
20 | + parent::__construct($table_name, $pk_column, $global); |
|
21 | + } |
|
22 | + /** |
|
23 | + * Gets SQL for this table and assigning it an alias. Eg " wp_esp_attendee AS Attendee " |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function get_table_sql() |
|
27 | + { |
|
28 | + return " ".$this->get_table_name()." AS ".$this->get_table_alias()." "; |
|
29 | + } |
|
30 | 30 | } |
@@ -8,153 +8,153 @@ |
||
8 | 8 | */ |
9 | 9 | class EE_Model_Parser |
10 | 10 | { |
11 | - const table_alias_model_relation_chain_separator = '__'; |
|
12 | - const table_alias_model_relation_chain_prefix_end = '___'; |
|
13 | - /** |
|
14 | - * Adds a period onto the front and end of the string. This often helps in searching. |
|
15 | - * For example, if we want to find the model name "Event", it can be tricky when the following are possible |
|
16 | - * "","Event.EVT_ID","Event","Event_Venue.Venue.VNU_ID",etc. It's easier to look for ".Event." in |
|
17 | - * "..",".Event.EVT_ID.", ".Event.", and ".Event_Venue.Venue.VNU_ID", especially when the last example should NOT |
|
18 | - * be found because the "Event" model isn't mentioned- it's just a string that has a model name that coincidentally |
|
19 | - * has it as a substring |
|
20 | - * @param string $string_to_pad |
|
21 | - * @return string |
|
22 | - */ |
|
23 | - public static function pad_with_periods($string_to_pad) |
|
24 | - { |
|
25 | - return ".".$string_to_pad."."; |
|
26 | - } |
|
27 | - /** |
|
28 | - * Basically undoes _pad_with_periods |
|
29 | - * @param string $string_to_trim |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public static function trim_periods($string_to_trim) |
|
33 | - { |
|
34 | - return trim($string_to_trim, '.'); |
|
35 | - } |
|
11 | + const table_alias_model_relation_chain_separator = '__'; |
|
12 | + const table_alias_model_relation_chain_prefix_end = '___'; |
|
13 | + /** |
|
14 | + * Adds a period onto the front and end of the string. This often helps in searching. |
|
15 | + * For example, if we want to find the model name "Event", it can be tricky when the following are possible |
|
16 | + * "","Event.EVT_ID","Event","Event_Venue.Venue.VNU_ID",etc. It's easier to look for ".Event." in |
|
17 | + * "..",".Event.EVT_ID.", ".Event.", and ".Event_Venue.Venue.VNU_ID", especially when the last example should NOT |
|
18 | + * be found because the "Event" model isn't mentioned- it's just a string that has a model name that coincidentally |
|
19 | + * has it as a substring |
|
20 | + * @param string $string_to_pad |
|
21 | + * @return string |
|
22 | + */ |
|
23 | + public static function pad_with_periods($string_to_pad) |
|
24 | + { |
|
25 | + return ".".$string_to_pad."."; |
|
26 | + } |
|
27 | + /** |
|
28 | + * Basically undoes _pad_with_periods |
|
29 | + * @param string $string_to_trim |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public static function trim_periods($string_to_trim) |
|
33 | + { |
|
34 | + return trim($string_to_trim, '.'); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Gets the calculated table's alias |
|
41 | - * @param string $model_relation_chain or query param |
|
42 | - * @param $this_model_name |
|
43 | - * @return string which can be added onto table aliases to make them unique |
|
44 | - */ |
|
45 | - public static function extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this_model_name) |
|
46 | - { |
|
47 | - // eg $model_relation_chain = 'Venue.Event_Venue.Event.Registration", and $this_model_name = 'Event' |
|
48 | - $model_relation_chain = self::pad_with_periods($model_relation_chain); |
|
49 | - $this_model_name = self::pad_with_periods($this_model_name); |
|
50 | - // eg '.Venue.Event_Venue.Event.Registration." and '.Event.' |
|
51 | - // remove this model name and everything afterwards |
|
52 | - $pos_of_model_name = strpos($model_relation_chain, $this_model_name); |
|
53 | - $model_relation_chain = substr($model_relation_chain, 0, $pos_of_model_name); |
|
54 | - // eg '.Venue.Event_Venue.' |
|
55 | - // trim periods |
|
56 | - $model_relation_chain = self::trim_periods($model_relation_chain); |
|
57 | - // eg 'Venue.Event_Venue' |
|
58 | - // replace periods with double-underscores |
|
59 | - $model_relation_chain = str_replace(".", self::table_alias_model_relation_chain_separator, $model_relation_chain); |
|
60 | - // eg 'Venue__Event_Venue' |
|
61 | - if ($model_relation_chain !='') { |
|
62 | - $model_relation_chain = $model_relation_chain.self::table_alias_model_relation_chain_prefix_end; |
|
63 | - } |
|
64 | - // eg 'Venue_Event_Venue___' |
|
65 | - return $model_relation_chain; |
|
66 | - } |
|
67 | - /** |
|
68 | - * Gets the table's alias (without prefix or anything) |
|
69 | - * @param string $table_alias_with_model_relation_chain_prefix which CAN have a table alias model relation chain prefix (or not) |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - public static function remove_table_alias_model_relation_chain_prefix($table_alias_with_model_relation_chain_prefix) |
|
73 | - { |
|
74 | - // does this actually have a table alias model relation chain prefix? |
|
75 | - $pos = strpos($table_alias_with_model_relation_chain_prefix, self::table_alias_model_relation_chain_prefix_end); |
|
76 | - if ($pos !== false) { |
|
77 | - // yes |
|
78 | - // find that triple underscore and remove it and everything before it |
|
79 | - $table_alias = substr($table_alias_with_model_relation_chain_prefix, $pos + strlen(self::table_alias_model_relation_chain_prefix_end)); |
|
80 | - } else { |
|
81 | - $table_alias = $table_alias_with_model_relation_chain_prefix; |
|
82 | - } |
|
83 | - return $table_alias; |
|
84 | - } |
|
85 | - /** |
|
86 | - * Gets the table alias model relation chain prefix from the table alias already containing it |
|
87 | - * @param string $table_alias_with_model_relation_chain_prefix |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public static function get_prefix_from_table_alias_with_model_relation_chain_prefix($table_alias_with_model_relation_chain_prefix) |
|
91 | - { |
|
92 | - // does this actually have a table alias model relation chain prefix? |
|
93 | - $pos = strpos($table_alias_with_model_relation_chain_prefix, self::table_alias_model_relation_chain_prefix_end); |
|
94 | - if ($pos !== false) { |
|
95 | - // yes |
|
96 | - // find that triple underscore and remove it and everything before it |
|
97 | - $prefix = substr($table_alias_with_model_relation_chain_prefix, 0, $pos + strlen(self::table_alias_model_relation_chain_prefix_end)); |
|
98 | - } else { |
|
99 | - $prefix = ''; |
|
100 | - } |
|
101 | - return $prefix; |
|
102 | - } |
|
39 | + /** |
|
40 | + * Gets the calculated table's alias |
|
41 | + * @param string $model_relation_chain or query param |
|
42 | + * @param $this_model_name |
|
43 | + * @return string which can be added onto table aliases to make them unique |
|
44 | + */ |
|
45 | + public static function extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this_model_name) |
|
46 | + { |
|
47 | + // eg $model_relation_chain = 'Venue.Event_Venue.Event.Registration", and $this_model_name = 'Event' |
|
48 | + $model_relation_chain = self::pad_with_periods($model_relation_chain); |
|
49 | + $this_model_name = self::pad_with_periods($this_model_name); |
|
50 | + // eg '.Venue.Event_Venue.Event.Registration." and '.Event.' |
|
51 | + // remove this model name and everything afterwards |
|
52 | + $pos_of_model_name = strpos($model_relation_chain, $this_model_name); |
|
53 | + $model_relation_chain = substr($model_relation_chain, 0, $pos_of_model_name); |
|
54 | + // eg '.Venue.Event_Venue.' |
|
55 | + // trim periods |
|
56 | + $model_relation_chain = self::trim_periods($model_relation_chain); |
|
57 | + // eg 'Venue.Event_Venue' |
|
58 | + // replace periods with double-underscores |
|
59 | + $model_relation_chain = str_replace(".", self::table_alias_model_relation_chain_separator, $model_relation_chain); |
|
60 | + // eg 'Venue__Event_Venue' |
|
61 | + if ($model_relation_chain !='') { |
|
62 | + $model_relation_chain = $model_relation_chain.self::table_alias_model_relation_chain_prefix_end; |
|
63 | + } |
|
64 | + // eg 'Venue_Event_Venue___' |
|
65 | + return $model_relation_chain; |
|
66 | + } |
|
67 | + /** |
|
68 | + * Gets the table's alias (without prefix or anything) |
|
69 | + * @param string $table_alias_with_model_relation_chain_prefix which CAN have a table alias model relation chain prefix (or not) |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + public static function remove_table_alias_model_relation_chain_prefix($table_alias_with_model_relation_chain_prefix) |
|
73 | + { |
|
74 | + // does this actually have a table alias model relation chain prefix? |
|
75 | + $pos = strpos($table_alias_with_model_relation_chain_prefix, self::table_alias_model_relation_chain_prefix_end); |
|
76 | + if ($pos !== false) { |
|
77 | + // yes |
|
78 | + // find that triple underscore and remove it and everything before it |
|
79 | + $table_alias = substr($table_alias_with_model_relation_chain_prefix, $pos + strlen(self::table_alias_model_relation_chain_prefix_end)); |
|
80 | + } else { |
|
81 | + $table_alias = $table_alias_with_model_relation_chain_prefix; |
|
82 | + } |
|
83 | + return $table_alias; |
|
84 | + } |
|
85 | + /** |
|
86 | + * Gets the table alias model relation chain prefix from the table alias already containing it |
|
87 | + * @param string $table_alias_with_model_relation_chain_prefix |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public static function get_prefix_from_table_alias_with_model_relation_chain_prefix($table_alias_with_model_relation_chain_prefix) |
|
91 | + { |
|
92 | + // does this actually have a table alias model relation chain prefix? |
|
93 | + $pos = strpos($table_alias_with_model_relation_chain_prefix, self::table_alias_model_relation_chain_prefix_end); |
|
94 | + if ($pos !== false) { |
|
95 | + // yes |
|
96 | + // find that triple underscore and remove it and everything before it |
|
97 | + $prefix = substr($table_alias_with_model_relation_chain_prefix, 0, $pos + strlen(self::table_alias_model_relation_chain_prefix_end)); |
|
98 | + } else { |
|
99 | + $prefix = ''; |
|
100 | + } |
|
101 | + return $prefix; |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Gets the table alias model relation chain prefix (ie, what can be prepended onto |
|
106 | - * EE_Model_Field::get_qualified_column() to get the proper column name for that field |
|
107 | - * in a specific query) from teh query param (eg 'Registration.Event.EVT_ID'). |
|
108 | - * |
|
109 | - * @param string $model_name of the model on which the related query param was found to be belong |
|
110 | - * @param string $original_query_param |
|
111 | - * @return string |
|
112 | - */ |
|
113 | - public static function extract_table_alias_model_relation_chain_from_query_param($model_name, $original_query_param) |
|
114 | - { |
|
115 | - $relation_chain = self::extract_model_relation_chain($model_name, $original_query_param); |
|
116 | - $table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($relation_chain, $model_name); |
|
117 | - return $table_alias_with_model_relation_chain_prefix; |
|
118 | - } |
|
119 | - /** |
|
120 | - * Gets the model relation chain to $model_name from the $original_query_param. |
|
121 | - * Eg, if $model_name were 'Payment', and $original_query_param were 'Registration.Transaction.Payment.PAY_ID', |
|
122 | - * this would return 'Registration.Transaction.Payment'. Also if the query param were 'Registration.Transaction.Payment' |
|
123 | - * and $model_name were 'Payment', it should return 'Registration.Transaction.Payment' |
|
124 | - * @param string $model_name |
|
125 | - * @param string $original_query_param |
|
126 | - * @return string |
|
127 | - */ |
|
128 | - public static function extract_model_relation_chain($model_name, $original_query_param) |
|
129 | - { |
|
130 | - // prefix and postfix both with a period, as this facilitates searching |
|
131 | - $model_name = EE_Model_Parser::pad_with_periods($model_name); |
|
132 | - $original_query_param = EE_Model_Parser::pad_with_periods($original_query_param); |
|
133 | - $pos_of_model_string = strpos($original_query_param, $model_name); |
|
134 | - // eg, if we're looking for the model relation chain from Event to Payment, the original query param is probably something like |
|
135 | - // "Registration.Transaction.Payment.PAY_ID", $pos_of_model_string points to the 'P' or Payment. We want the string |
|
136 | - // "Registration.Transaction.Payment" |
|
137 | - $model_relation_chain = substr($original_query_param, 0, $pos_of_model_string+strlen($model_name)); |
|
138 | - return EE_Model_Parser::trim_periods($model_relation_chain); |
|
139 | - } |
|
104 | + /** |
|
105 | + * Gets the table alias model relation chain prefix (ie, what can be prepended onto |
|
106 | + * EE_Model_Field::get_qualified_column() to get the proper column name for that field |
|
107 | + * in a specific query) from teh query param (eg 'Registration.Event.EVT_ID'). |
|
108 | + * |
|
109 | + * @param string $model_name of the model on which the related query param was found to be belong |
|
110 | + * @param string $original_query_param |
|
111 | + * @return string |
|
112 | + */ |
|
113 | + public static function extract_table_alias_model_relation_chain_from_query_param($model_name, $original_query_param) |
|
114 | + { |
|
115 | + $relation_chain = self::extract_model_relation_chain($model_name, $original_query_param); |
|
116 | + $table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($relation_chain, $model_name); |
|
117 | + return $table_alias_with_model_relation_chain_prefix; |
|
118 | + } |
|
119 | + /** |
|
120 | + * Gets the model relation chain to $model_name from the $original_query_param. |
|
121 | + * Eg, if $model_name were 'Payment', and $original_query_param were 'Registration.Transaction.Payment.PAY_ID', |
|
122 | + * this would return 'Registration.Transaction.Payment'. Also if the query param were 'Registration.Transaction.Payment' |
|
123 | + * and $model_name were 'Payment', it should return 'Registration.Transaction.Payment' |
|
124 | + * @param string $model_name |
|
125 | + * @param string $original_query_param |
|
126 | + * @return string |
|
127 | + */ |
|
128 | + public static function extract_model_relation_chain($model_name, $original_query_param) |
|
129 | + { |
|
130 | + // prefix and postfix both with a period, as this facilitates searching |
|
131 | + $model_name = EE_Model_Parser::pad_with_periods($model_name); |
|
132 | + $original_query_param = EE_Model_Parser::pad_with_periods($original_query_param); |
|
133 | + $pos_of_model_string = strpos($original_query_param, $model_name); |
|
134 | + // eg, if we're looking for the model relation chain from Event to Payment, the original query param is probably something like |
|
135 | + // "Registration.Transaction.Payment.PAY_ID", $pos_of_model_string points to the 'P' or Payment. We want the string |
|
136 | + // "Registration.Transaction.Payment" |
|
137 | + $model_relation_chain = substr($original_query_param, 0, $pos_of_model_string+strlen($model_name)); |
|
138 | + return EE_Model_Parser::trim_periods($model_relation_chain); |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * Replaces the specified model in teh model relation chain with teh join model. |
|
143 | - * Eg EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain( |
|
144 | - * "Ticket", "Datetime_Ticket", "Datetime.Ticket" ) will return |
|
145 | - * "Datetime.Datetime_Ticket" which can be used to find the table alias model relation chain prefix |
|
146 | - * using EE_Model_Parser::extract_table_alias_model_relation_chain_prefix |
|
147 | - * @param string $model_name |
|
148 | - * @param string $join_model_name |
|
149 | - * @param string $model_relation_chain |
|
150 | - * @return string |
|
151 | - */ |
|
152 | - public static function replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_name, $model_relation_chain) |
|
153 | - { |
|
154 | - $model_name = EE_Model_Parser::pad_with_periods($model_name); |
|
155 | - $join_model_name = EE_Model_Parser::pad_with_periods($join_model_name); |
|
156 | - $model_relation_chain = EE_Model_Parser::pad_with_periods($model_relation_chain); |
|
157 | - $replaced_with_periods = str_replace($model_name, $join_model_name, $model_relation_chain); |
|
158 | - return EE_Model_Parser::trim_periods($replaced_with_periods); |
|
159 | - } |
|
141 | + /** |
|
142 | + * Replaces the specified model in teh model relation chain with teh join model. |
|
143 | + * Eg EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain( |
|
144 | + * "Ticket", "Datetime_Ticket", "Datetime.Ticket" ) will return |
|
145 | + * "Datetime.Datetime_Ticket" which can be used to find the table alias model relation chain prefix |
|
146 | + * using EE_Model_Parser::extract_table_alias_model_relation_chain_prefix |
|
147 | + * @param string $model_name |
|
148 | + * @param string $join_model_name |
|
149 | + * @param string $model_relation_chain |
|
150 | + * @return string |
|
151 | + */ |
|
152 | + public static function replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_name, $model_relation_chain) |
|
153 | + { |
|
154 | + $model_name = EE_Model_Parser::pad_with_periods($model_name); |
|
155 | + $join_model_name = EE_Model_Parser::pad_with_periods($join_model_name); |
|
156 | + $model_relation_chain = EE_Model_Parser::pad_with_periods($model_relation_chain); |
|
157 | + $replaced_with_periods = str_replace($model_name, $join_model_name, $model_relation_chain); |
|
158 | + return EE_Model_Parser::trim_periods($replaced_with_periods); |
|
159 | + } |
|
160 | 160 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | // replace periods with double-underscores |
59 | 59 | $model_relation_chain = str_replace(".", self::table_alias_model_relation_chain_separator, $model_relation_chain); |
60 | 60 | // eg 'Venue__Event_Venue' |
61 | - if ($model_relation_chain !='') { |
|
61 | + if ($model_relation_chain != '') { |
|
62 | 62 | $model_relation_chain = $model_relation_chain.self::table_alias_model_relation_chain_prefix_end; |
63 | 63 | } |
64 | 64 | // eg 'Venue_Event_Venue___' |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | // eg, if we're looking for the model relation chain from Event to Payment, the original query param is probably something like |
135 | 135 | // "Registration.Transaction.Payment.PAY_ID", $pos_of_model_string points to the 'P' or Payment. We want the string |
136 | 136 | // "Registration.Transaction.Payment" |
137 | - $model_relation_chain = substr($original_query_param, 0, $pos_of_model_string+strlen($model_name)); |
|
137 | + $model_relation_chain = substr($original_query_param, 0, $pos_of_model_string + strlen($model_name)); |
|
138 | 138 | return EE_Model_Parser::trim_periods($model_relation_chain); |
139 | 139 | } |
140 | 140 |