@@ -32,7 +32,6 @@ |
||
32 | 32 | /** |
33 | 33 | * |
34 | 34 | * @param string $model_name |
35 | - * @param string $comparison_model_name |
|
36 | 35 | * @param string $id_or_name_field should be the string 'ID' or 'name' only |
37 | 36 | * @return EE_Model_Field_Base |
38 | 37 | */ |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Joins any two models together via a has-and-belongs-to-many relation, using |
4 | 4 | * the esp_extra_join table. |
5 | 5 | */ |
6 | -class EE_HABTM_Any_Relation extends EE_HABTM_Relation{ |
|
6 | +class EE_HABTM_Any_Relation extends EE_HABTM_Relation { |
|
7 | 7 | /** |
8 | 8 | * |
9 | 9 | * @var string |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | * @param boolean $block_deletes for this type of relation, we block by default for now. if there are related models across this relation, block (prevent and add an error) the deletion of this model |
18 | 18 | * @param type $blocking_delete_error_message a customized error message on blocking deletes instead of the default |
19 | 19 | */ |
20 | - function __construct( $block_deletes = true, $blocking_delete_error_message =''){ |
|
21 | - parent::__construct( 'Extra_Join', $block_deletes, $blocking_delete_error_message); |
|
20 | + function __construct($block_deletes = true, $blocking_delete_error_message = '') { |
|
21 | + parent::__construct('Extra_Join', $block_deletes, $blocking_delete_error_message); |
|
22 | 22 | } |
23 | - function _construct_finalize_set_models($this_model_name, $other_model_name){ |
|
24 | - if( $this_model_name < $other_model_name ) { |
|
23 | + function _construct_finalize_set_models($this_model_name, $other_model_name) { |
|
24 | + if ($this_model_name < $other_model_name) { |
|
25 | 25 | $this->_alphabetically_first_model_name = $this_model_name; |
26 | - } else{ |
|
26 | + } else { |
|
27 | 27 | $this->_alphabetically_first_model_name = $other_model_name; |
28 | 28 | } |
29 | - return parent::_construct_finalize_set_models( $this_model_name, $other_model_name ); |
|
29 | + return parent::_construct_finalize_set_models($this_model_name, $other_model_name); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -36,21 +36,21 @@ discard block |
||
36 | 36 | * @param string $id_or_name_field should be the string 'ID' or 'name' only |
37 | 37 | * @return EE_Model_Field_Base |
38 | 38 | */ |
39 | - function get_join_table_fk_field_to( $model_name, $id_or_name_field ) { |
|
39 | + function get_join_table_fk_field_to($model_name, $id_or_name_field) { |
|
40 | 40 | $order = null; |
41 | - if( $model_name === $this->_alphabetically_first_model_name ) { |
|
41 | + if ($model_name === $this->_alphabetically_first_model_name) { |
|
42 | 42 | $order = 'first'; |
43 | 43 | } else { |
44 | 44 | $order = 'second'; |
45 | 45 | } |
46 | - return $this->get_join_model()->field_settings_for( 'EXJ_' . $order . '_model_' . $id_or_name_field ); |
|
46 | + return $this->get_join_model()->field_settings_for('EXJ_'.$order.'_model_'.$id_or_name_field); |
|
47 | 47 | } |
48 | 48 | /** |
49 | 49 | * Gets the SQL string for joining the main model's table containing the pk to the join table. Eg "LEFT JOIN real_join_table AS join_table_alias ON this_table_alias.pk = join_table_alias.fk_to_this_table" |
50 | 50 | * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
51 | 51 | * @return string of SQL |
52 | 52 | */ |
53 | - function get_join_to_intermediate_model_statement($model_relation_chain){ |
|
53 | + function get_join_to_intermediate_model_statement($model_relation_chain) { |
|
54 | 54 | //create sql like |
55 | 55 | //LEFT JOIN join_table AS join_table_alias ON this_table_alias.this_table_pk = join_table_alias.join_table_fk_to_this |
56 | 56 | //LEFT JOIN other_table AS other_table_alias ON join_table_alias.join_table_fk_to_other = other_table_alias.other_table_pk |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | $field_with_model_name = $this->get_join_table_fk_field_to( |
65 | 65 | $this->get_this_model()->get_this_model_name(), |
66 | 66 | 'name' ); |
67 | - $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias(); |
|
68 | - $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias(); |
|
67 | + $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_pk_field->get_table_alias(); |
|
68 | + $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias(); |
|
69 | 69 | $join_table = $this->get_join_model()->get_table_for_alias($join_table_alias); |
70 | 70 | //phew! ok, we have all the info we need, now we can create the SQL join string |
71 | 71 | $SQL = $this->_left_join( |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $join_table_fk_field_to_this_table->get_table_column(), |
75 | 75 | $this_table_alias, |
76 | 76 | $this_table_pk_field->get_table_column(), |
77 | - $field_with_model_name->get_qualified_column()."='".$this->get_this_model()->get_this_model_name()."'" ) . |
|
77 | + $field_with_model_name->get_qualified_column()."='".$this->get_this_model()->get_this_model_name()."'" ). |
|
78 | 78 | $this->get_join_model()->_construct_internal_join_to_table_with_alias($join_table_alias); |
79 | 79 | |
80 | 80 | return $SQL; |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
88 | 88 | * @return string of SQL |
89 | 89 | */ |
90 | - function get_join_statement($model_relation_chain){ |
|
91 | - if( $this->_model_relation_chain_to_join_model === NULL ){ |
|
92 | - throw new EE_Error( sprintf( __( 'When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso' ))); |
|
90 | + function get_join_statement($model_relation_chain) { |
|
91 | + if ($this->_model_relation_chain_to_join_model === NULL) { |
|
92 | + throw new EE_Error(sprintf(__('When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso'))); |
|
93 | 93 | } |
94 | 94 | $join_table_fk_field_to_this_table = $this->get_join_table_fk_field_to( |
95 | 95 | $this->get_this_model()->get_this_model_name(), |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | $this->get_other_model()->get_this_model_name(), |
102 | 102 | 'name' ); |
103 | 103 | |
104 | - $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias(); |
|
104 | + $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias(); |
|
105 | 105 | |
106 | 106 | $other_table_pk_field = $this->get_other_model()->get_primary_key_field(); |
107 | - $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias(); |
|
107 | + $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_pk_field->get_table_alias(); |
|
108 | 108 | $other_table = $this->get_other_model()->get_table_for_alias($other_table_alias); |
109 | 109 | |
110 | 110 | $SQL = $this->_left_join( |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $join_table_alias, |
115 | 115 | $join_table_fk_field_to_other_table->get_table_column(), |
116 | 116 | $field_with_other_model_name->get_qualified_column()."='".$this->get_other_model()->get_this_model_name()."'" |
117 | - ) . |
|
117 | + ). |
|
118 | 118 | $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias); |
119 | 119 | return $SQL; |
120 | 120 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param array $extra_join_model_fields_n_values col=>val pairs that are used as extra conditions for checking existing values and for setting new rows if no exact matches. |
127 | 127 | * @return EE_Base_Class |
128 | 128 | */ |
129 | - function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){ |
|
129 | + function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) { |
|
130 | 130 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
131 | 131 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
132 | 132 | //check if such a relationship already exists |
@@ -143,31 +143,31 @@ discard block |
||
143 | 143 | $this->get_other_model()->get_this_model_name(), |
144 | 144 | 'name' ); |
145 | 145 | |
146 | - $cols_n_values = array( |
|
146 | + $cols_n_values = array( |
|
147 | 147 | $join_model_fk_to_this_model->get_name() => $this_model_obj->ID(), |
148 | 148 | $join_model_name_field_to_this_model->get_name() => $this_model_obj->get_model()->get_this_model_name(), |
149 | 149 | $join_model_fk_to_other_model->get_name() => $other_model_obj->ID(), |
150 | 150 | $join_model_name_field_to_other_model->get_name() => $other_model_obj->get_model()->get_this_model_name() ); |
151 | 151 | |
152 | 152 | //if $where_query exists lets add them to the query_params. |
153 | - if ( !empty( $extra_join_model_fields_n_values ) ) { |
|
153 | + if ( ! empty($extra_join_model_fields_n_values)) { |
|
154 | 154 | //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name) |
155 | 155 | //make sure we strip THIS models name from the query param |
156 | - foreach ( $extra_join_model_fields_n_values as $query_param => $val ) { |
|
157 | - $query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param); |
|
156 | + foreach ($extra_join_model_fields_n_values as $query_param => $val) { |
|
157 | + $query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param); |
|
158 | 158 | $parsed_query[$query_param] = $val; |
159 | 159 | } |
160 | - $cols_n_values = array_merge( $cols_n_values, $parsed_query ); |
|
160 | + $cols_n_values = array_merge($cols_n_values, $parsed_query); |
|
161 | 161 | } |
162 | 162 | |
163 | - $query_params = array( $cols_n_values ); |
|
163 | + $query_params = array($cols_n_values); |
|
164 | 164 | |
165 | 165 | |
166 | 166 | $existing_entry_in_join_table = $this->get_join_model()->get_one($query_params); |
167 | 167 | //if there is already an entry in the join table, indicating a relationship, we're done |
168 | 168 | //again, if you want more sophisticated logic or insertions (handling more columns than just 2 foreign keys to |
169 | 169 | //the other tables, use the joining model directly! |
170 | - if( ! $existing_entry_in_join_table ){ |
|
170 | + if ( ! $existing_entry_in_join_table) { |
|
171 | 171 | $this->get_join_model()->insert($cols_n_values); |
172 | 172 | } |
173 | 173 | return $other_model_obj; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * * @param array $where_query col=>val pairs that are used as extra conditions for checking existing values and for removing existing rows if exact matches exist. |
180 | 180 | * @return EE_Base_Class |
181 | 181 | */ |
182 | - function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array() ){ |
|
182 | + function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) { |
|
183 | 183 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
184 | 184 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
185 | 185 | //check if such a relationship already exists |
@@ -196,24 +196,24 @@ discard block |
||
196 | 196 | $this->get_other_model()->get_this_model_name(), |
197 | 197 | 'name' ); |
198 | 198 | |
199 | - $cols_n_values = array( |
|
199 | + $cols_n_values = array( |
|
200 | 200 | $join_model_fk_to_this_model->get_name() => $this_model_obj->ID(), |
201 | 201 | $join_model_name_field_to_this_model->get_name() => $this_model_obj->get_model()->get_this_model_name(), |
202 | 202 | $join_model_fk_to_other_model->get_name() => $other_model_obj->ID(), |
203 | 203 | $join_model_name_field_to_other_model->get_name() => $other_model_obj->get_model()->get_this_model_name() ); |
204 | 204 | |
205 | 205 | //if $where_query exists lets add them to the query_params. |
206 | - if ( !empty( $where_query ) ) { |
|
206 | + if ( ! empty($where_query)) { |
|
207 | 207 | //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name) |
208 | 208 | //make sure we strip THIS models name from the query param |
209 | - foreach ( $where_query as $query_param => $val ) { |
|
210 | - $query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param); |
|
209 | + foreach ($where_query as $query_param => $val) { |
|
210 | + $query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param); |
|
211 | 211 | $parsed_query[$query_param] = $val; |
212 | 212 | } |
213 | - $cols_n_values = array_merge( $cols_n_values, $parsed_query ); |
|
213 | + $cols_n_values = array_merge($cols_n_values, $parsed_query); |
|
214 | 214 | } |
215 | 215 | |
216 | - $existing_entry_in_join_table = $this->get_join_model()->delete( array($cols_n_values) ); |
|
216 | + $existing_entry_in_join_table = $this->get_join_model()->delete(array($cols_n_values)); |
|
217 | 217 | return $other_model_obj; |
218 | 218 | } |
219 | 219 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Gets the model where this relation is defined. |
70 | - * @return EEM_Base |
|
70 | + * @return boolean |
|
71 | 71 | */ |
72 | 72 | function get_this_model(){ |
73 | 73 | return $this->_get_model($this->_this_model_name); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | /** |
79 | 79 | * Gets the model which this relation establishes the relation TO (ie, |
80 | 80 | * this relation object was defined on get_this_model(), get_other_model() is the other one) |
81 | - * @return EEM_Base |
|
81 | + * @return boolean |
|
82 | 82 | */ |
83 | 83 | function get_other_model(){ |
84 | 84 | return $this->_get_model($this->_other_model_name); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | /** |
90 | 90 | * Internally used by get_this_model() and get_other_model() |
91 | 91 | * @param string $model_name like Event, Question_Group, etc. omit the EEM_ |
92 | - * @return EEM_Base |
|
92 | + * @return boolean |
|
93 | 93 | */ |
94 | 94 | protected function _get_model($model_name){ |
95 | 95 | $modelInstance = EE_Registry::instance()->load_model( $model_name ); |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | |
113 | 113 | /** |
114 | 114 | * @param $other_table |
115 | - * @param $other_table_alias |
|
115 | + * @param string $other_table_alias |
|
116 | 116 | * @param $other_table_column |
117 | - * @param $this_table_alias |
|
117 | + * @param string $this_table_alias |
|
118 | 118 | * @param $this_table_join_column |
119 | 119 | * @param string $extra_join_sql |
120 | 120 | * @return string |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * parameters are specified, then all related model objects will be deleted. |
169 | 169 | * Note: If the related model is extends EEM_Soft_Delete_Base, then the related |
170 | 170 | * model objects will only be soft-deleted. |
171 | - * @param EE_Base_Class|int|string $model_object_or_id |
|
171 | + * @param EE_Base_Class $model_object_or_id |
|
172 | 172 | * @param array $query_params |
173 | 173 | * @return int of how many related models got deleted |
174 | 174 | */ |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * parameters are specified, then all related model objects will be deleted. |
197 | 197 | * Note: If the related model is extends EEM_Soft_Delete_Base, then the related |
198 | 198 | * model objects will only be soft-deleted. |
199 | - * @param EE_Base_Class|int|string $model_object_or_id |
|
199 | + * @param EE_Base_Class $model_object_or_id |
|
200 | 200 | * @param array $query_params |
201 | 201 | * @return int of how many related models got deleted |
202 | 202 | */ |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | * @param null $timezone |
23 | 23 | * @return EE_Event_Message_Template|mixed |
24 | 24 | */ |
25 | - public static function new_instance( $props_n_values = array(), $timezone = NULL ) { |
|
26 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone ); |
|
27 | - return $has_object ? $has_object : new self( $props_n_values, FALSE, $timezone ); |
|
25 | + public static function new_instance($props_n_values = array(), $timezone = NULL) { |
|
26 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
27 | + return $has_object ? $has_object : new self($props_n_values, FALSE, $timezone); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @param null $timezone |
35 | 35 | * @return EE_Event_Message_Template |
36 | 36 | */ |
37 | - public static function new_instance_from_db ( $props_n_values = array(), $timezone = NULL ) { |
|
38 | - return new self( $props_n_values, TRUE, $timezone ); |
|
37 | + public static function new_instance_from_db($props_n_values = array(), $timezone = NULL) { |
|
38 | + return new self($props_n_values, TRUE, $timezone); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | } |
@@ -1,26 +1,26 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * Event Espresso |
|
4 | - * |
|
5 | - * Event Registration and Management Plugin for WordPress |
|
6 | - * |
|
7 | - * @ package Event Espresso |
|
8 | - * @ author Seth Shoultes |
|
9 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | - * @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
|
11 | - * @ link {@link http://www.eventespresso.com} |
|
12 | - * @ since 4.0 |
|
13 | - * |
|
14 | - * ------------------------------------------------------------------------ |
|
15 | - * |
|
16 | - * Transactions Table class |
|
17 | - * |
|
18 | - * @package Event Espresso |
|
19 | - * @subpackage includes/admin_screens/Transactions_List_Table.class.php |
|
20 | - * @author Brent Christensen |
|
21 | - * |
|
22 | - * ------------------------------------------------------------------------ |
|
23 | - */ |
|
3 | + * Event Espresso |
|
4 | + * |
|
5 | + * Event Registration and Management Plugin for WordPress |
|
6 | + * |
|
7 | + * @ package Event Espresso |
|
8 | + * @ author Seth Shoultes |
|
9 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | + * @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
|
11 | + * @ link {@link http://www.eventespresso.com} |
|
12 | + * @ since 4.0 |
|
13 | + * |
|
14 | + * ------------------------------------------------------------------------ |
|
15 | + * |
|
16 | + * Transactions Table class |
|
17 | + * |
|
18 | + * @package Event Espresso |
|
19 | + * @subpackage includes/admin_screens/Transactions_List_Table.class.php |
|
20 | + * @author Brent Christensen |
|
21 | + * |
|
22 | + * ------------------------------------------------------------------------ |
|
23 | + */ |
|
24 | 24 | |
25 | 25 | |
26 | 26 | class EE_Admin_Transactions_List_Table extends EE_Admin_List_Table { |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @return string |
141 | 141 | */ |
142 | 142 | function column_TXN_ID( EE_Transaction $item ){ |
143 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
143 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
144 | 144 | $content = '<a href="' . $view_lnk_url . '" title="' . esc_attr__( 'Go to Transaction Details', 'event_espresso' ) . '">' . $item->ID() . '</a>'; |
145 | 145 | |
146 | 146 | //txn timestamp |
@@ -275,8 +275,8 @@ discard block |
||
275 | 275 | * @param \EE_Transaction $item |
276 | 276 | * @return string|void |
277 | 277 | */ |
278 | - function column_event_name( EE_Transaction $item ){ |
|
279 | - $actions = array(); |
|
278 | + function column_event_name( EE_Transaction $item ){ |
|
279 | + $actions = array(); |
|
280 | 280 | $event = $item->primary_registration()->get_first_related('Event'); |
281 | 281 | if ( !empty( $event ) ) { |
282 | 282 | $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$event->ID() ), EVENTS_ADMIN_URL ); |
@@ -300,21 +300,21 @@ discard block |
||
300 | 300 | * @param \EE_Transaction $item |
301 | 301 | * @return string |
302 | 302 | */ |
303 | - function column_actions( EE_Transaction $item ){ |
|
303 | + function column_actions( EE_Transaction $item ){ |
|
304 | 304 | |
305 | - $registration = $item->primary_registration(); |
|
306 | - $attendee = $registration->attendee(); |
|
305 | + $registration = $item->primary_registration(); |
|
306 | + $attendee = $registration->attendee(); |
|
307 | 307 | EE_Registry::instance()->load_helper( 'MSG_Template' ); |
308 | 308 | |
309 | - //Build row actions |
|
309 | + //Build row actions |
|
310 | 310 | $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
311 | 311 | $dl_invoice_lnk_url = $registration->invoice_url(); |
312 | 312 | $dl_receipt_lnk_url = $registration->receipt_url(); |
313 | 313 | $view_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$registration->ID() ), REG_ADMIN_URL ); |
314 | 314 | $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'send_payment_reminder', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
315 | - $related_messages_link = EEH_MSG_Template::get_message_action_link( 'see_notifications_for', null, array( |
|
316 | - 'TXN_ID' => $item->ID() |
|
317 | - )); |
|
315 | + $related_messages_link = EEH_MSG_Template::get_message_action_link( 'see_notifications_for', null, array( |
|
316 | + 'TXN_ID' => $item->ID() |
|
317 | + )); |
|
318 | 318 | |
319 | 319 | //Build row actions |
320 | 320 | $view_lnk = ' |
@@ -349,8 +349,8 @@ discard block |
||
349 | 349 | $dl_receipt_lnk = ''; |
350 | 350 | } |
351 | 351 | |
352 | - //only show payment reminder link if the message type is active. |
|
353 | - if ( EEH_MSG_Template::is_mt_active( 'payment_reminder' ) ) { |
|
352 | + //only show payment reminder link if the message type is active. |
|
353 | + if ( EEH_MSG_Template::is_mt_active( 'payment_reminder' ) ) { |
|
354 | 354 | $send_pay_lnk = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_transactions_send_payment_reminder' ) ? ' |
355 | 355 | <li> |
356 | 356 | <a href="'.$send_pay_lnk_url.'" title="' . esc_attr__( 'Send Payment Reminder', 'event_espresso' ) . '" class="tiny-text"> |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | } |
377 | 377 | |
378 | 378 | return $this->_action_string( $view_lnk . $dl_invoice_lnk . $dl_receipt_lnk . $view_reg_lnk . $send_pay_lnk . $view_related_messages_lnk, $item, 'ul', 'txn-overview-actions-ul' ); |
379 | - } |
|
379 | + } |
|
380 | 380 | |
381 | 381 | |
382 | 382 | } |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | * @param \EE_Admin_Page $admin_page |
34 | 34 | * @return EE_Admin_Transactions_List_Table |
35 | 35 | */ |
36 | - function __construct( EE_Admin_Page $admin_page ){ |
|
37 | - parent::__construct( $admin_page ); |
|
36 | + function __construct(EE_Admin_Page $admin_page) { |
|
37 | + parent::__construct($admin_page); |
|
38 | 38 | $this->_status = $this->_admin_page->get_transaction_status_array(); |
39 | 39 | |
40 | 40 | } |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | |
45 | 45 | |
46 | 46 | protected function _setup_data() { |
47 | - $this->_data = $this->_admin_page->get_transactions( $this->_per_page ); |
|
48 | - $status = ! empty( $this->_req_data['status'] )? $this->_req_data['status'] : 'all'; |
|
49 | - $this->_all_data_count = $this->_admin_page->get_transactions( $this->_per_page, TRUE, $status ); |
|
47 | + $this->_data = $this->_admin_page->get_transactions($this->_per_page); |
|
48 | + $status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all'; |
|
49 | + $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, TRUE, $status); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
@@ -65,20 +65,20 @@ discard block |
||
65 | 65 | ); |
66 | 66 | |
67 | 67 | $this->_columns = array( |
68 | - 'TXN_ID' => __( 'ID', 'event_espresso' ), |
|
69 | - 'TXN_timestamp' => __( 'Transaction Date', 'event_espresso' ), |
|
70 | - 'TXN_total' => __( 'Total', 'event_espresso' ), |
|
71 | - 'TXN_paid' => __( 'Paid', 'event_espresso' ), |
|
72 | - 'ATT_fname' => __( 'Primary Registrant', 'event_espresso' ), |
|
73 | - 'event_name' => __( 'Event', 'event_espresso' ), |
|
74 | - 'actions' => __( 'Actions', 'event_espresso' ) |
|
68 | + 'TXN_ID' => __('ID', 'event_espresso'), |
|
69 | + 'TXN_timestamp' => __('Transaction Date', 'event_espresso'), |
|
70 | + 'TXN_total' => __('Total', 'event_espresso'), |
|
71 | + 'TXN_paid' => __('Paid', 'event_espresso'), |
|
72 | + 'ATT_fname' => __('Primary Registrant', 'event_espresso'), |
|
73 | + 'event_name' => __('Event', 'event_espresso'), |
|
74 | + 'actions' => __('Actions', 'event_espresso') |
|
75 | 75 | ); |
76 | 76 | |
77 | 77 | $this->_sortable_columns = array( |
78 | - 'TXN_ID' => array( 'TXN_ID' => FALSE ), |
|
79 | - 'event_name' => array( 'event_name'=> FALSE ), |
|
80 | - 'ATT_fname' => array( 'ATT_fname'=> FALSE ), |
|
81 | - 'TXN_timestamp' => array( 'TXN_timestamp'=> TRUE ) //true means its already sorted |
|
78 | + 'TXN_ID' => array('TXN_ID' => FALSE), |
|
79 | + 'event_name' => array('event_name'=> FALSE), |
|
80 | + 'ATT_fname' => array('ATT_fname'=> FALSE), |
|
81 | + 'TXN_timestamp' => array('TXN_timestamp'=> TRUE) //true means its already sorted |
|
82 | 82 | ); |
83 | 83 | |
84 | 84 | $this->_primary_column = 'TXN_ID'; |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | |
89 | 89 | |
90 | 90 | |
91 | - protected function _get_row_class( $item ) { |
|
92 | - $class = parent::_get_row_class( $item ); |
|
91 | + protected function _get_row_class($item) { |
|
92 | + $class = parent::_get_row_class($item); |
|
93 | 93 | //add status class |
94 | - $class .= ' ee-status-strip txn-status-' . $item->status_ID(); |
|
95 | - if ( $this->_has_checkbox_column ) { |
|
94 | + $class .= ' ee-status-strip txn-status-'.$item->status_ID(); |
|
95 | + if ($this->_has_checkbox_column) { |
|
96 | 96 | $class .= ' has-checkbox-column'; |
97 | 97 | } |
98 | 98 | return $class; |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | */ |
110 | 110 | protected function _get_table_filters() { |
111 | 111 | $filters = array(); |
112 | - $start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' )); |
|
113 | - $end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y' ); |
|
112 | + $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', strtotime('-10 year')); |
|
113 | + $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y'); |
|
114 | 114 | ob_start(); |
115 | 115 | ?> |
116 | 116 | <label for="txn-filter-start-date">Display Transactions from </label> |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | |
129 | 129 | |
130 | 130 | protected function _add_view_counts() { |
131 | - $this->_views['all']['count'] = $this->_admin_page->get_transactions( $this->_per_page, TRUE, 'all' ); |
|
132 | - $this->_views['abandoned']['count'] = $this->_admin_page->get_transactions( $this->_per_page, TRUE, 'abandoned' ); |
|
133 | - $this->_views['failed']['count'] = $this->_admin_page->get_transactions( $this->_per_page, TRUE, 'failed' ); |
|
131 | + $this->_views['all']['count'] = $this->_admin_page->get_transactions($this->_per_page, TRUE, 'all'); |
|
132 | + $this->_views['abandoned']['count'] = $this->_admin_page->get_transactions($this->_per_page, TRUE, 'abandoned'); |
|
133 | + $this->_views['failed']['count'] = $this->_admin_page->get_transactions($this->_per_page, TRUE, 'failed'); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -139,29 +139,29 @@ discard block |
||
139 | 139 | * @param \EE_Transaction $item |
140 | 140 | * @return string |
141 | 141 | */ |
142 | - function column_TXN_ID( EE_Transaction $item ){ |
|
143 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
144 | - $content = '<a href="' . $view_lnk_url . '" title="' . esc_attr__( 'Go to Transaction Details', 'event_espresso' ) . '">' . $item->ID() . '</a>'; |
|
142 | + function column_TXN_ID(EE_Transaction $item) { |
|
143 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->ID()), TXN_ADMIN_URL); |
|
144 | + $content = '<a href="'.$view_lnk_url.'" title="'.esc_attr__('Go to Transaction Details', 'event_espresso').'">'.$item->ID().'</a>'; |
|
145 | 145 | |
146 | 146 | //txn timestamp |
147 | - $content .= ' <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp( $item ) . '</span>'; |
|
147 | + $content .= ' <span class="show-on-mobile-view-only">'.$this->_get_txn_timestamp($item).'</span>'; |
|
148 | 148 | return $content; |
149 | 149 | } |
150 | 150 | |
151 | 151 | |
152 | 152 | |
153 | - protected function _get_txn_timestamp( EE_Transaction $item ) { |
|
153 | + protected function _get_txn_timestamp(EE_Transaction $item) { |
|
154 | 154 | //txn timestamp |
155 | 155 | // is TXN less than 2 hours old ? |
156 | 156 | if ( |
157 | - ( ( time() - EE_Registry::instance()->SSN->lifespan() ) |
|
158 | - < $item->datetime( false, true ) |
|
157 | + ((time() - EE_Registry::instance()->SSN->lifespan()) |
|
158 | + < $item->datetime(false, true) |
|
159 | 159 | ) |
160 | - && ( $item->failed() || $item->is_abandoned() ) |
|
160 | + && ($item->failed() || $item->is_abandoned()) |
|
161 | 161 | ) { |
162 | - $timestamp = __( 'TXN in progress...', 'event_espresso' ); |
|
162 | + $timestamp = __('TXN in progress...', 'event_espresso'); |
|
163 | 163 | } else { |
164 | - $timestamp = $item->get_i18n_datetime( 'TXN_timestamp' ); |
|
164 | + $timestamp = $item->get_i18n_datetime('TXN_timestamp'); |
|
165 | 165 | } |
166 | 166 | return $timestamp; |
167 | 167 | } |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @param \EE_Transaction $item |
174 | 174 | * @return string |
175 | 175 | */ |
176 | - function column_cb($item ){ |
|
177 | - return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_wp_list_args['singular'], $item->ID()); |
|
176 | + function column_cb($item) { |
|
177 | + return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_wp_list_args['singular'], $item->ID()); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | * @param \EE_Transaction $item |
186 | 186 | * @return string |
187 | 187 | */ |
188 | - function column_TXN_timestamp( EE_Transaction $item ){ |
|
189 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
190 | - $txn_date = '<a href="'.$view_lnk_url.'" title="' . esc_attr__( 'View Transaction Details for TXN #', 'event_espresso' ) . $item->ID() . '">' . $this->_get_txn_timestamp( $item ) . '</a>'; |
|
188 | + function column_TXN_timestamp(EE_Transaction $item) { |
|
189 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->ID()), TXN_ADMIN_URL); |
|
190 | + $txn_date = '<a href="'.$view_lnk_url.'" title="'.esc_attr__('View Transaction Details for TXN #', 'event_espresso').$item->ID().'">'.$this->_get_txn_timestamp($item).'</a>'; |
|
191 | 191 | //status |
192 | - $txn_date .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ) . '</span>'; |
|
192 | + $txn_date .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->status_ID(), false, 'sentence').'</span>'; |
|
193 | 193 | return $txn_date; |
194 | 194 | } |
195 | 195 | |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * @param \EE_Transaction $item |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - function column_TXN_total( EE_Transaction $item ){ |
|
203 | - if ( $item->get('TXN_total') > 0 ) { |
|
204 | - return '<span class="txn-pad-rght">' . apply_filters( 'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', $item->get_pretty('TXN_total'), $item ) . '</span>'; |
|
202 | + function column_TXN_total(EE_Transaction $item) { |
|
203 | + if ($item->get('TXN_total') > 0) { |
|
204 | + return '<span class="txn-pad-rght">'.apply_filters('FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', $item->get_pretty('TXN_total'), $item).'</span>'; |
|
205 | 205 | } else { |
206 | - return '<span class="txn-overview-free-event-spn">' . __( 'free', 'event_espresso' ) . '</span>'; |
|
206 | + return '<span class="txn-overview-free-event-spn">'.__('free', 'event_espresso').'</span>'; |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -213,19 +213,19 @@ discard block |
||
213 | 213 | * @param \EE_Transaction $item |
214 | 214 | * @return mixed|string |
215 | 215 | */ |
216 | - function column_TXN_paid( EE_Transaction $item ){ |
|
216 | + function column_TXN_paid(EE_Transaction $item) { |
|
217 | 217 | $transaction_total = $item->get('TXN_total'); |
218 | 218 | $transaction_paid = $item->get('TXN_paid'); |
219 | 219 | |
220 | - if (( $transaction_total > 0 ) && ( $transaction_paid >= $transaction_total )) { |
|
220 | + if (($transaction_total > 0) && ($transaction_paid >= $transaction_total)) { |
|
221 | 221 | // paid in full |
222 | 222 | $span_class = 'txn-overview-full-payment-spn'; |
223 | 223 | |
224 | - } elseif (( $transaction_total > 0 ) && ( $transaction_paid > 0 )) { |
|
224 | + } elseif (($transaction_total > 0) && ($transaction_paid > 0)) { |
|
225 | 225 | // monies owing |
226 | 226 | $span_class = 'txn-overview-part-payment-spn'; |
227 | 227 | |
228 | - } elseif (( $transaction_total > 0 ) && ( $transaction_paid == 0 )) { |
|
228 | + } elseif (($transaction_total > 0) && ($transaction_paid == 0)) { |
|
229 | 229 | // no payments made |
230 | 230 | $span_class = 'txn-overview-no-payment-spn'; |
231 | 231 | |
@@ -235,11 +235,11 @@ discard block |
||
235 | 235 | } |
236 | 236 | |
237 | 237 | $payment_method = $item->payment_method(); |
238 | - $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __( 'Unknown', 'event_espresso' ); |
|
238 | + $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __('Unknown', 'event_espresso'); |
|
239 | 239 | |
240 | - $content = '<span class="' . $span_class . ' txn-pad-rght">' . $transaction_paid !== 0 ? $item->get_pretty('TXN_paid') : $transaction_paid . '</span>'; |
|
241 | - if ( $transaction_paid > 0 ) { |
|
242 | - $content .= '<br><span class="ee-status-text-small">' . sprintf( __( '...via %s', 'event_espresso' ), $payment_method_name ) . '</span>'; |
|
240 | + $content = '<span class="'.$span_class.' txn-pad-rght">'.$transaction_paid !== 0 ? $item->get_pretty('TXN_paid') : $transaction_paid.'</span>'; |
|
241 | + if ($transaction_paid > 0) { |
|
242 | + $content .= '<br><span class="ee-status-text-small">'.sprintf(__('...via %s', 'event_espresso'), $payment_method_name).'</span>'; |
|
243 | 243 | } |
244 | 244 | return $content; |
245 | 245 | } |
@@ -250,13 +250,13 @@ discard block |
||
250 | 250 | * @param \EE_Transaction $item |
251 | 251 | * @return string|void |
252 | 252 | */ |
253 | - function column_ATT_fname( EE_Transaction $item ){ |
|
253 | + function column_ATT_fname(EE_Transaction $item) { |
|
254 | 254 | $primary_reg = $item->primary_registration(); |
255 | 255 | $attendee = $primary_reg->get_first_related('Attendee'); |
256 | - if ( $attendee instanceof EE_Attendee ) { |
|
257 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$primary_reg->ID() ), REG_ADMIN_URL ); |
|
258 | - $content = EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $primary_reg->ID() ) ? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' . $attendee->full_name() . '</a>' : $attendee->full_name(); |
|
259 | - $content .= '<br>' . $attendee->email(); |
|
256 | + if ($attendee instanceof EE_Attendee) { |
|
257 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$primary_reg->ID()), REG_ADMIN_URL); |
|
258 | + $content = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $primary_reg->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'.$attendee->full_name().'</a>' : $attendee->full_name(); |
|
259 | + $content .= '<br>'.$attendee->email(); |
|
260 | 260 | return $content; |
261 | 261 | } |
262 | 262 | return $item->failed() || $item->is_abandoned() ? __('no contact record.', 'event_espresso') : __('No contact record, because the transaction was abandoned or the registration process failed.', 'event_espresso'); |
@@ -268,10 +268,10 @@ discard block |
||
268 | 268 | * @param \EE_Transaction $item |
269 | 269 | * @return string|void |
270 | 270 | */ |
271 | - function column_ATT_email( EE_Transaction $item ){ |
|
271 | + function column_ATT_email(EE_Transaction $item) { |
|
272 | 272 | $attendee = $item->primary_registration()->get_first_related('Attendee'); |
273 | - if ( !empty( $attendee ) ) |
|
274 | - return '<a href="mailto:' . $attendee->get('ATT_email') . '">' . $attendee->get('ATT_email') . '</a>'; |
|
273 | + if ( ! empty($attendee)) |
|
274 | + return '<a href="mailto:'.$attendee->get('ATT_email').'">'.$attendee->get('ATT_email').'</a>'; |
|
275 | 275 | else |
276 | 276 | return $item->failed() || $item->is_abandoned() ? __('no contact record.', 'event_espresso') : __('No contact record, because the transaction was abandoned or the registration process failed.', 'event_espresso'); |
277 | 277 | ; |
@@ -283,20 +283,20 @@ discard block |
||
283 | 283 | * @param \EE_Transaction $item |
284 | 284 | * @return string|void |
285 | 285 | */ |
286 | - function column_event_name( EE_Transaction $item ){ |
|
286 | + function column_event_name(EE_Transaction $item) { |
|
287 | 287 | $actions = array(); |
288 | 288 | $event = $item->primary_registration()->get_first_related('Event'); |
289 | - if ( !empty( $event ) ) { |
|
290 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$event->ID() ), EVENTS_ADMIN_URL ); |
|
289 | + if ( ! empty($event)) { |
|
290 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$event->ID()), EVENTS_ADMIN_URL); |
|
291 | 291 | $event_name = $event->get('EVT_name'); |
292 | 292 | |
293 | 293 | //filter this view by transactions for this event |
294 | - $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'EVT_ID' => $event->ID() ) ); |
|
295 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'espresso_events_edit', $event->ID() ) ) { |
|
296 | - $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '" title="' . esc_attr__('Filter transactions by this event', 'event_espresso') . '">' . __('View Transactions for this event', 'event_espresso') . '</a>'; |
|
294 | + $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'EVT_ID' => $event->ID())); |
|
295 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $event->ID())) { |
|
296 | + $actions['filter_by_event'] = '<a href="'.$txn_by_event_lnk.'" title="'.esc_attr__('Filter transactions by this event', 'event_espresso').'">'.__('View Transactions for this event', 'event_espresso').'</a>'; |
|
297 | 297 | } |
298 | 298 | |
299 | - return sprintf('%1$s %2$s', EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'espresso_events_edit', $event->ID() ) ? '<a href="' . $edit_event_url . '" title="' . sprintf( esc_attr__( 'Edit Event: %s', 'event_espresso' ), $event->get('EVT_name') ) .'">' . wp_trim_words( $event_name, 30, '...' ) . '</a>' : wp_trim_words( $event_name, 30, '...' ), $this->row_actions($actions) ); |
|
299 | + return sprintf('%1$s %2$s', EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $event->ID()) ? '<a href="'.$edit_event_url.'" title="'.sprintf(esc_attr__('Edit Event: %s', 'event_espresso'), $event->get('EVT_name')).'">'.wp_trim_words($event_name, 30, '...').'</a>' : wp_trim_words($event_name, 30, '...'), $this->row_actions($actions)); |
|
300 | 300 | } else { |
301 | 301 | return __('The event associated with this transaction via the primary registration cannot be retrieved.', 'event_espresso'); |
302 | 302 | } |
@@ -308,36 +308,36 @@ discard block |
||
308 | 308 | * @param \EE_Transaction $item |
309 | 309 | * @return string |
310 | 310 | */ |
311 | - function column_actions( EE_Transaction $item ){ |
|
311 | + function column_actions(EE_Transaction $item) { |
|
312 | 312 | |
313 | 313 | $registration = $item->primary_registration(); |
314 | 314 | $attendee = $registration->attendee(); |
315 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
315 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
316 | 316 | |
317 | 317 | //Build row actions |
318 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
318 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->ID()), TXN_ADMIN_URL); |
|
319 | 319 | $dl_invoice_lnk_url = $registration->invoice_url(); |
320 | 320 | $dl_receipt_lnk_url = $registration->receipt_url(); |
321 | - $view_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$registration->ID() ), REG_ADMIN_URL ); |
|
322 | - $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'send_payment_reminder', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
323 | - $related_messages_link = EEH_MSG_Template::get_message_action_link( 'see_notifications_for', null, array( |
|
321 | + $view_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$registration->ID()), REG_ADMIN_URL); |
|
322 | + $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'send_payment_reminder', 'TXN_ID'=>$item->ID()), TXN_ADMIN_URL); |
|
323 | + $related_messages_link = EEH_MSG_Template::get_message_action_link('see_notifications_for', null, array( |
|
324 | 324 | 'TXN_ID' => $item->ID() |
325 | 325 | )); |
326 | 326 | |
327 | 327 | //Build row actions |
328 | 328 | $view_lnk = ' |
329 | 329 | <li> |
330 | - <a href="'.$view_lnk_url.'" title="' . esc_attr__( 'View Transaction Details', 'event_espresso' ) . '" class="tiny-text"> |
|
330 | + <a href="'.$view_lnk_url.'" title="'.esc_attr__('View Transaction Details', 'event_espresso').'" class="tiny-text"> |
|
331 | 331 | <span class="dashicons dashicons-cart"></span> |
332 | 332 | </a> |
333 | 333 | </li>'; |
334 | 334 | |
335 | 335 | |
336 | 336 | //only show invoice link if message type is active. |
337 | - if ( $attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active( 'invoice' ) ) { |
|
337 | + if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('invoice')) { |
|
338 | 338 | $dl_invoice_lnk = ' |
339 | 339 | <li> |
340 | - <a title="' . esc_attr__( 'View Transaction Invoice', 'event_espresso' ) . '" target="_blank" href="'.$dl_invoice_lnk_url.'" class="tiny-text"> |
|
340 | + <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso').'" target="_blank" href="'.$dl_invoice_lnk_url.'" class="tiny-text"> |
|
341 | 341 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
342 | 342 | </a> |
343 | 343 | </li>'; |
@@ -346,10 +346,10 @@ discard block |
||
346 | 346 | } |
347 | 347 | |
348 | 348 | //only show receipt link if message type is active. |
349 | - if ( $attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active( 'receipt' ) ) { |
|
349 | + if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('receipt')) { |
|
350 | 350 | $dl_receipt_lnk = ' |
351 | 351 | <li> |
352 | - <a title="' . esc_attr__( 'View Transaction Receipt', 'event_espresso' ) . '" target="_blank" href="'.$dl_receipt_lnk_url.'" class="tiny-text"> |
|
352 | + <a title="' . esc_attr__('View Transaction Receipt', 'event_espresso').'" target="_blank" href="'.$dl_receipt_lnk_url.'" class="tiny-text"> |
|
353 | 353 | <span class="dashicons dashicons-media-default ee-icon-size-18"></span> |
354 | 354 | </a> |
355 | 355 | </li>'; |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | } |
359 | 359 | |
360 | 360 | //only show payment reminder link if the message type is active. |
361 | - if ( EEH_MSG_Template::is_mt_active( 'payment_reminder' ) ) { |
|
362 | - $send_pay_lnk = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_transactions_send_payment_reminder' ) ? ' |
|
361 | + if (EEH_MSG_Template::is_mt_active('payment_reminder')) { |
|
362 | + $send_pay_lnk = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_transactions_send_payment_reminder') ? ' |
|
363 | 363 | <li> |
364 | - <a href="'.$send_pay_lnk_url.'" title="' . esc_attr__( 'Send Payment Reminder', 'event_espresso' ) . '" class="tiny-text"> |
|
364 | + <a href="'.$send_pay_lnk_url.'" title="'.esc_attr__('Send Payment Reminder', 'event_espresso').'" class="tiny-text"> |
|
365 | 365 | <span class="dashicons dashicons-email-alt"></span> |
366 | 366 | </a> |
367 | 367 | </li>' : ''; |
@@ -370,20 +370,20 @@ discard block |
||
370 | 370 | $send_pay_lnk = ''; |
371 | 371 | } |
372 | 372 | |
373 | - $view_reg_lnk = EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $registration->ID() ) ? ' |
|
373 | + $view_reg_lnk = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $registration->ID()) ? ' |
|
374 | 374 | <li> |
375 | - <a href="'.$view_reg_lnk_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '" class="tiny-text"> |
|
375 | + <a href="'.$view_reg_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text"> |
|
376 | 376 | <span class="dashicons dashicons-clipboard"></span> |
377 | 377 | </a> |
378 | 378 | </li>' : ''; |
379 | 379 | |
380 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_messages', 'view_filtered_messages' ) ) { |
|
381 | - $view_related_messages_lnk = '<li>' . $related_messages_link . '</li>'; |
|
380 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_messages', 'view_filtered_messages')) { |
|
381 | + $view_related_messages_lnk = '<li>'.$related_messages_link.'</li>'; |
|
382 | 382 | } else { |
383 | 383 | $view_related_messages_lnk = ''; |
384 | 384 | } |
385 | 385 | |
386 | - return $this->_action_string( $view_lnk . $dl_invoice_lnk . $dl_receipt_lnk . $view_reg_lnk . $send_pay_lnk . $view_related_messages_lnk, $item, 'ul', 'txn-overview-actions-ul' ); |
|
386 | + return $this->_action_string($view_lnk.$dl_invoice_lnk.$dl_receipt_lnk.$view_reg_lnk.$send_pay_lnk.$view_related_messages_lnk, $item, 'ul', 'txn-overview-actions-ul'); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 |
@@ -8,36 +8,36 @@ |
||
8 | 8 | * @subpackage Expression package is undefined on line 19, column 19 in Templates/Scripting/PHPClass.php. |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -class EE_Max_Length_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
11 | +class EE_Max_Length_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
12 | 12 | |
13 | 13 | protected $_max_length; |
14 | 14 | |
15 | - public function __construct( $validation_error_message = NULL, $max_length = EE_INF ) { |
|
15 | + public function __construct($validation_error_message = NULL, $max_length = EE_INF) { |
|
16 | 16 | $this->_max_length = $max_length; |
17 | - if( $validation_error_message === null ) { |
|
18 | - $validation_error_message = sprintf( __( 'Input is too long. Maximum number of characters is %1$s', 'event_espresso' ), $max_length ); |
|
17 | + if ($validation_error_message === null) { |
|
18 | + $validation_error_message = sprintf(__('Input is too long. Maximum number of characters is %1$s', 'event_espresso'), $max_length); |
|
19 | 19 | } |
20 | - parent::__construct( $validation_error_message ); |
|
20 | + parent::__construct($validation_error_message); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @param $normalized_value |
25 | 25 | */ |
26 | 26 | public function validate($normalized_value) { |
27 | - if( $this->_max_length !== EE_INF && |
|
27 | + if ($this->_max_length !== EE_INF && |
|
28 | 28 | $normalized_value && |
29 | - is_string( $normalized_value ) && |
|
30 | - strlen( $normalized_value ) > $this->_max_length){ |
|
31 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'maxlength' ); |
|
29 | + is_string($normalized_value) && |
|
30 | + strlen($normalized_value) > $this->_max_length) { |
|
31 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'maxlength'); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @return array |
37 | 37 | */ |
38 | - function get_jquery_validation_rule_array(){ |
|
39 | - if( $this->_max_length !== EE_INF ) { |
|
40 | - return array( 'maxlength'=> $this->_max_length, 'messages' => array( 'maxlength' => $this->get_validation_error_message() ) ); |
|
38 | + function get_jquery_validation_rule_array() { |
|
39 | + if ($this->_max_length !== EE_INF) { |
|
40 | + return array('maxlength'=> $this->_max_length, 'messages' => array('maxlength' => $this->get_validation_error_message())); |
|
41 | 41 | } else { |
42 | 42 | return array(); |
43 | 43 | } |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * |
|
4 | - * Class JobHandler |
|
5 | - * |
|
6 | - * Base class for common implementations of JobHandlerInterface. |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage batch |
|
10 | - * @author Mike Nelson |
|
11 | - * @since 4.8.26 |
|
12 | - * |
|
13 | - */ |
|
3 | + * |
|
4 | + * Class JobHandler |
|
5 | + * |
|
6 | + * Base class for common implementations of JobHandlerInterface. |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage batch |
|
10 | + * @author Mike Nelson |
|
11 | + * @since 4.8.26 |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | namespace EventEspressoBatchRequest\JobHandlerBaseClasses; |
15 | 15 | |
16 | 16 | use EventEspressoBatchRequest\Helpers\BatchRequestException; |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Class EE_Line_Item_Filter_Collection |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * Specialized form for payment methods, allowing for easy setting and retrieving of meta fields. |
5 | 5 | * Uses EEM_Payment_Method as the model |
6 | 6 | */ |
7 | -class EE_Payment_Method_Form extends EE_Model_Form_Section{ |
|
7 | +class EE_Payment_Method_Form extends EE_Model_Form_Section { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * All the subsection inputs that correspond ot extra meta rows |
@@ -39,37 +39,37 @@ discard block |
||
39 | 39 | * @see EE_Model_Form_Section::__construct() for more |
40 | 40 | * } |
41 | 41 | */ |
42 | - public function __construct($options_array = array()){ |
|
42 | + public function __construct($options_array = array()) { |
|
43 | 43 | $this->_model = EEM_Payment_Method::instance(); |
44 | 44 | $this->_options_array = $options_array; |
45 | - if(isset($options_array['payment_method_type'])){ |
|
45 | + if (isset($options_array['payment_method_type'])) { |
|
46 | 46 | $this->_payment_method_type = $options_array['payment_method_type']; |
47 | 47 | } |
48 | 48 | $options_array = $this->_options_array; |
49 | - if(isset($options_array['extra_meta_inputs'])){ |
|
50 | - $this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs,$options_array['extra_meta_inputs']); |
|
49 | + if (isset($options_array['extra_meta_inputs'])) { |
|
50 | + $this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs, $options_array['extra_meta_inputs']); |
|
51 | 51 | } |
52 | - if($this->_extra_meta_inputs){ |
|
53 | - $this->_subsections = array_merge($this->_subsections,$this->_extra_meta_inputs); |
|
52 | + if ($this->_extra_meta_inputs) { |
|
53 | + $this->_subsections = array_merge($this->_subsections, $this->_extra_meta_inputs); |
|
54 | 54 | } |
55 | 55 | $this->_subsections['PMD_button_url'] = new EE_Admin_File_Uploader_Input( |
56 | - array( 'html_label_text'=> __( 'Button URL', 'event_espresso' )) |
|
56 | + array('html_label_text'=> __('Button URL', 'event_espresso')) |
|
57 | 57 | ); |
58 | 58 | $this->_subsections['PMD_scope'] = new EE_Checkbox_Multi_Input( |
59 | 59 | EEM_Payment_Method::instance()->scopes(), |
60 | - array( 'html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename() . EEH_Template::get_help_tab_link( 'payment_methods_overview' )) |
|
60 | + array('html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename().EEH_Template::get_help_tab_link('payment_methods_overview')) |
|
61 | 61 | ); |
62 | 62 | //setup the currency options |
63 | 63 | $this->_subsections['Currency'] = new EE_Select_Multi_Model_Input( |
64 | - EEM_Currency::instance()->get_all_currencies_usable_by( $this->_payment_method_type ), |
|
64 | + EEM_Currency::instance()->get_all_currencies_usable_by($this->_payment_method_type), |
|
65 | 65 | array( |
66 | - 'html_label_text'=> __( 'Currencies Supported', 'event_espresso' ), |
|
66 | + 'html_label_text'=> __('Currencies Supported', 'event_espresso'), |
|
67 | 67 | 'required'=>TRUE |
68 | 68 | ) |
69 | 69 | ); |
70 | - $this->_subsections['PMD_order'] = new EE_Text_Input( array( |
|
71 | - 'html_label_text' => __( 'Order', 'event_espresso' ), |
|
72 | - 'html_help_text' => __( 'Lowest numbers will be shown first', 'event_espresso' ), |
|
70 | + $this->_subsections['PMD_order'] = new EE_Text_Input(array( |
|
71 | + 'html_label_text' => __('Order', 'event_espresso'), |
|
72 | + 'html_help_text' => __('Lowest numbers will be shown first', 'event_espresso'), |
|
73 | 73 | 'normalization_strategy' => new EE_Int_Normalization(), |
74 | 74 | 'validation_strategies' => array( |
75 | 75 | new EE_Int_Validation_Strategy() |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | * @param string $name |
89 | 89 | * @throws EE_Error |
90 | 90 | */ |
91 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
92 | - if( ! $this->_payment_method_type instanceof EE_PMT_Base ){ |
|
93 | - throw new EE_Error( sprintf( __( 'Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', 'event_espresso' ))); |
|
91 | + public function _construct_finalize($parent_form_section, $name) { |
|
92 | + if ( ! $this->_payment_method_type instanceof EE_PMT_Base) { |
|
93 | + throw new EE_Error(sprintf(__('Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', 'event_espresso'))); |
|
94 | 94 | } |
95 | 95 | //set the name of this form based on the payment method type |
96 | - if( ! $this->_name && ! $name ){ |
|
97 | - $name = str_replace(" ","_",ucwords(str_replace("_"," ",($this->_payment_method_type->system_name()))))."_Settings_Form"; |
|
96 | + if ( ! $this->_name && ! $name) { |
|
97 | + $name = str_replace(" ", "_", ucwords(str_replace("_", " ", ($this->_payment_method_type->system_name()))))."_Settings_Form"; |
|
98 | 98 | } |
99 | - parent::_construct_finalize( $parent_form_section, $name ); |
|
99 | + parent::_construct_finalize($parent_form_section, $name); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * @param $payment_method_type |
106 | 106 | * @throws EE_Error |
107 | 107 | */ |
108 | - public function set_payment_method_type( $payment_method_type ){ |
|
109 | - if( ! $payment_method_type instanceof EE_PMT_Base){ |
|
108 | + public function set_payment_method_type($payment_method_type) { |
|
109 | + if ( ! $payment_method_type instanceof EE_PMT_Base) { |
|
110 | 110 | throw new EE_Error(sprintf(__("Payment Method forms MUST set a payment method type by using _set_payment_method_type", "event_espresso"))); |
111 | 111 | } |
112 | 112 | $this->_payment_method_type = $payment_method_type; |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | * extends the model form section's save method to also save the extra meta field values |
119 | 119 | * @return int ID of the payment method inserted, or true on update |
120 | 120 | */ |
121 | - public function save(){ |
|
121 | + public function save() { |
|
122 | 122 | $parent_save_val = parent::save(); |
123 | - if( $this->_model_object && $this->_model_object->ID()){ |
|
124 | - foreach($this->_extra_meta_inputs as $input_name => $input){ |
|
123 | + if ($this->_model_object && $this->_model_object->ID()) { |
|
124 | + foreach ($this->_extra_meta_inputs as $input_name => $input) { |
|
125 | 125 | $this->_model_object->update_extra_meta($input_name, $input->normalized_value()); |
126 | 126 | } |
127 | 127 | } |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | $model_obj = $this->_model->ensure_is_obj($model_obj); |
139 | 139 | parent::populate_model_obj($model_obj); |
140 | 140 | $extra_meta = $model_obj->all_extra_meta_array(); |
141 | - foreach($this->_extra_meta_inputs as $input_name => $extra_meta_input){ |
|
142 | - if(isset($extra_meta[$input_name])){ |
|
141 | + foreach ($this->_extra_meta_inputs as $input_name => $extra_meta_input) { |
|
142 | + if (isset($extra_meta[$input_name])) { |
|
143 | 143 | $extra_meta_input->set_default($extra_meta[$input_name]); |
144 | 144 | } |
145 | 145 | } |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | * gets the default name of this form section if none is specified |
152 | 152 | * @return string |
153 | 153 | */ |
154 | - protected function _set_default_name_if_empty(){ |
|
155 | - if( ! $this->_name ){ |
|
156 | - $default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form"; |
|
157 | - $this->_name = $default_name; |
|
154 | + protected function _set_default_name_if_empty() { |
|
155 | + if ( ! $this->_name) { |
|
156 | + $default_name = str_replace("EEM_", "", get_class($this->_model))."_Model_Form"; |
|
157 | + $this->_name = $default_name; |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * Gets all the extra meta inputs in this form |
165 | 165 | * @return EE_Form_Input_Base[] |
166 | 166 | */ |
167 | - public function extra_meta_inputs(){ |
|
167 | + public function extra_meta_inputs() { |
|
168 | 168 | return $this->_extra_meta_inputs; |
169 | 169 | } |
170 | 170 | } |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -330,14 +331,9 @@ discard block |
||
330 | 331 | else if ( $fieldName == 'QST_admin_label' && ( isset( $this->_req_data['QST_admin_label'] ) && empty( $this->_req_data['QST_admin_label'] ) )) { |
331 | 332 | $QST_text = isset( $this->_req_data['QST_display_text'] ) ? $this->_req_data['QST_display_text'] : '' ; |
332 | 333 | $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text,10)); |
333 | - } |
|
334 | - |
|
335 | - |
|
336 | - else if ( $fieldName == 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) { |
|
334 | + } else if ( $fieldName == 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) { |
|
337 | 335 | $set_column_values[$fieldName] = 0; |
338 | - } |
|
339 | - |
|
340 | - else if ( $fieldName == 'QST_max' ) { |
|
336 | + } else if ( $fieldName == 'QST_max' ) { |
|
341 | 337 | $qst_system = EEM_Question::instance()->get_var( |
342 | 338 | array( |
343 | 339 | array( |
@@ -390,7 +386,7 @@ discard block |
||
390 | 386 | $question=$this->_question_model->get_one_by_ID($ID); |
391 | 387 | $additional_hidden_fields=array('QST_ID'=>array('type'=>'hidden','value'=>$ID)); |
392 | 388 | $this->_set_add_edit_form_tags('update_question', $additional_hidden_fields); |
393 | - }else{ |
|
389 | + } else{ |
|
394 | 390 | $question= EE_Question::new_instance(); |
395 | 391 | $question->set_order_to_latest(); |
396 | 392 | $this->_set_add_edit_form_tags('insert_question'); |
@@ -421,7 +417,7 @@ discard block |
||
421 | 417 | $ID=$this->_question_model->insert($set_column_values); |
422 | 418 | $success = $ID ? true : false; |
423 | 419 | $action_desc = 'added'; |
424 | - }else{ |
|
420 | + } else{ |
|
425 | 421 | $ID=absint($this->_req_data['QST_ID']); |
426 | 422 | $pk=$this->_question_model->primary_key_name(); |
427 | 423 | $wheres=array($pk=>$ID); |
@@ -442,7 +438,7 @@ discard block |
||
442 | 438 | $option_req_index=$this->_get_option_req_data_index($option_ID); |
443 | 439 | if($option_req_index!==FALSE){ |
444 | 440 | $option->save($this->_req_data['question_options'][$option_req_index]); |
445 | - }else{ |
|
441 | + } else{ |
|
446 | 442 | //not found, remove it |
447 | 443 | $option->delete(); |
448 | 444 | } |
@@ -519,7 +515,7 @@ discard block |
||
519 | 515 | 'QSG_name'=>array('LIKE',"%$search_string%"), |
520 | 516 | 'QSG_desc'=>array('LIKE',"%$search_string%")) |
521 | 517 | ); |
522 | - }else{ |
|
518 | + } else{ |
|
523 | 519 | $query_params[0]=array( |
524 | 520 | 'QST_display_text'=>array('LIKE',"%$search_string%") |
525 | 521 | ); |
@@ -575,7 +571,7 @@ discard block |
||
575 | 571 | if ($count){ |
576 | 572 | $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
577 | 573 | $results = $QST->count($where); |
578 | - }else{ |
|
574 | + } else{ |
|
579 | 575 | $results = $QST->get_all($query_params); |
580 | 576 | } |
581 | 577 | return $results; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | |
59 | 59 | |
60 | 60 | |
61 | - public function __construct( $routing = TRUE ) { |
|
62 | - require_once( EE_MODELS . 'EEM_Question.model.php' ); |
|
63 | - require_once( EE_MODELS . 'EEM_Question_Group.model.php' ); |
|
64 | - $this->_question_model= EEM_Question::instance(); |
|
65 | - $this->_question_group_model=EEM_Question_Group::instance(); |
|
66 | - parent::__construct( $routing ); |
|
61 | + public function __construct($routing = TRUE) { |
|
62 | + require_once(EE_MODELS.'EEM_Question.model.php'); |
|
63 | + require_once(EE_MODELS.'EEM_Question_Group.model.php'); |
|
64 | + $this->_question_model = EEM_Question::instance(); |
|
65 | + $this->_question_group_model = EEM_Question_Group::instance(); |
|
66 | + parent::__construct($routing); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | |
99 | 99 | protected function _set_page_routes() { |
100 | - $qst_id = ! empty( $this->_req_data['QST_ID'] ) ? $this->_req_data['QST_ID'] : 0; |
|
100 | + $qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
101 | 101 | $this->_page_routes = array( |
102 | 102 | 'default' => array( |
103 | 103 | 'func' => '_questions_overview_list_table', |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | 'update_question' => array( |
120 | 120 | 'func' => '_insert_or_update_question', |
121 | - 'args' => array('new_question' => FALSE ), |
|
121 | + 'args' => array('new_question' => FALSE), |
|
122 | 122 | 'capability' => 'ee_edit_question', |
123 | 123 | 'obj_id' => $qst_id, |
124 | 124 | 'noheader' => TRUE, |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | 'filename' => 'registration_form_questions_overview_views_bulk_actions_search' |
154 | 154 | ) |
155 | 155 | ), |
156 | - 'help_tour' => array( 'Registration_Form_Questions_Overview_Help_Tour'), |
|
156 | + 'help_tour' => array('Registration_Form_Questions_Overview_Help_Tour'), |
|
157 | 157 | 'require_nonce' => FALSE, |
158 | 158 | 'qtips' => array( |
159 | 159 | 'EE_Registration_Form_Tips' |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | 'filename' => 'registration_form_question_groups' |
173 | 173 | ), |
174 | 174 | ), |
175 | - 'help_tour' => array( 'Registration_Form_Question_Groups_Help_Tour'), |
|
175 | + 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
176 | 176 | 'require_nonce' => FALSE |
177 | 177 | ), |
178 | 178 | |
@@ -181,16 +181,16 @@ discard block |
||
181 | 181 | 'label' => __('Edit Question', 'event_espresso'), |
182 | 182 | 'order' => 15, |
183 | 183 | 'persistent' => FALSE, |
184 | - 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
184 | + 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id']), $this->_current_page_view_url) : $this->_admin_base_url |
|
185 | 185 | ), |
186 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
186 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
187 | 187 | 'help_tabs' => array( |
188 | 188 | 'registration_form_edit_question_group_help_tab' => array( |
189 | 189 | 'title' => __('Edit Question', 'event_espresso'), |
190 | 190 | 'filename' => 'registration_form_edit_question' |
191 | 191 | ), |
192 | 192 | ), |
193 | - 'help_tour' => array( 'Registration_Form_Edit_Question_Help_Tour'), |
|
193 | + 'help_tour' => array('Registration_Form_Edit_Question_Help_Tour'), |
|
194 | 194 | 'require_nonce' => FALSE |
195 | 195 | ), |
196 | 196 | ); |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | //none of the below group are currently used for Event Categories |
219 | 219 | protected function _add_feature_pointers() {} |
220 | 220 | public function load_scripts_styles() { |
221 | - wp_register_style( 'espresso_registration', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
221 | + wp_register_style('espresso_registration', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
222 | 222 | wp_enqueue_style('espresso_registration'); |
223 | 223 | } |
224 | 224 | public function admin_init() {} |
@@ -234,20 +234,20 @@ discard block |
||
234 | 234 | |
235 | 235 | public function load_scripts_styles_add_question() { |
236 | 236 | $this->load_scripts_styles_forms(); |
237 | - wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
238 | - wp_enqueue_script( 'espresso_registration_form_single' ); |
|
237 | + wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
238 | + wp_enqueue_script('espresso_registration_form_single'); |
|
239 | 239 | } |
240 | 240 | public function load_scripts_styles_edit_question() { |
241 | 241 | $this->load_scripts_styles_forms(); |
242 | - wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
243 | - wp_enqueue_script( 'espresso_registration_form_single' ); |
|
242 | + wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
243 | + wp_enqueue_script('espresso_registration_form_single'); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | |
247 | 247 | |
248 | 248 | |
249 | 249 | public function recaptcha_info_help_tab() { |
250 | - $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php'; |
|
250 | + $template = REGISTRATION_FORM_TEMPLATE_PATH.'recaptcha_info_help_tab.template.php'; |
|
251 | 251 | EEH_Template::display_template($template, array()); |
252 | 252 | } |
253 | 253 | |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | ) |
280 | 280 | ); |
281 | 281 | |
282 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_questions', 'espresso_registration_form_trash_questions' ) ) { |
|
282 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions')) { |
|
283 | 283 | $this->_views['trash'] = array( |
284 | 284 | 'slug' => 'trash', |
285 | 285 | 'label' => __('Trash', 'event_espresso'), |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | */ |
298 | 298 | protected function _questions_groups_preview() { |
299 | 299 | $this->_admin_page_title = __('Question Groups (Preview)', 'event_espresso'); |
300 | - $this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="' . esc_attr__( 'Preview Question Groups Overview List Table screenshot', 'event_espresso' ) . '" />'; |
|
301 | - $this->_template_args['preview_text'] = '<strong>'.__( 'Question Groups is a feature that is only available in the Caffeinated version of Event Espresso. With the Question Groups feature you are able to: create new question groups, edit existing question groups, and also create and edit new questions and add them to question groups.', 'event_espresso' ).'</strong>'; |
|
302 | - $this->display_admin_caf_preview_page( 'question_groups_tab' ); |
|
300 | + $this->_template_args['preview_img'] = '<img src="'.REGISTRATION_FORM_ASSETS_URL.'caf_reg_form_preview.jpg" alt="'.esc_attr__('Preview Question Groups Overview List Table screenshot', 'event_espresso').'" />'; |
|
301 | + $this->_template_args['preview_text'] = '<strong>'.__('Question Groups is a feature that is only available in the Caffeinated version of Event Espresso. With the Question Groups feature you are able to: create new question groups, edit existing question groups, and also create and edit new questions and add them to question groups.', 'event_espresso').'</strong>'; |
|
302 | + $this->display_admin_caf_preview_page('question_groups_tab'); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
@@ -310,58 +310,58 @@ discard block |
||
310 | 310 | * @param \EEM_Base $model |
311 | 311 | * @return array where each key is the name of a model's field/db column, and each value is its value. |
312 | 312 | */ |
313 | - protected function _set_column_values_for(EEM_Base $model){ |
|
314 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
315 | - $set_column_values=array(); |
|
313 | + protected function _set_column_values_for(EEM_Base $model) { |
|
314 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
315 | + $set_column_values = array(); |
|
316 | 316 | |
317 | 317 | //some initial checks for proper values. |
318 | 318 | //if QST_admin_only, then no matter what QST_required is we disable. |
319 | - if ( !empty( $this->_req_data['QST_admin_only'] ) ) { |
|
319 | + if ( ! empty($this->_req_data['QST_admin_only'])) { |
|
320 | 320 | $this->_req_data['QST_required'] = 0; |
321 | 321 | } |
322 | - foreach($model->field_settings() as $fieldName=>$settings){ |
|
322 | + foreach ($model->field_settings() as $fieldName=>$settings) { |
|
323 | 323 | // basically if QSG_identifier is empty or not set |
324 | - if ( $fieldName == 'QSG_identifier' && ( isset( $this->_req_data['QSG_identifier'] ) && empty( $this->_req_data['QSG_identifier'] ) )) { |
|
325 | - $QSG_name = isset( $this->_req_data['QSG_name'] ) ? $this->_req_data['QSG_name'] : '' ; |
|
326 | - $set_column_values[$fieldName] = sanitize_title($QSG_name ) . '-' . uniqid(); |
|
324 | + if ($fieldName == 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) { |
|
325 | + $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : ''; |
|
326 | + $set_column_values[$fieldName] = sanitize_title($QSG_name).'-'.uniqid(); |
|
327 | 327 | // dd($set_column_values); |
328 | 328 | } |
329 | 329 | //if the admin label is blank, use a slug version of the question text |
330 | - else if ( $fieldName == 'QST_admin_label' && ( isset( $this->_req_data['QST_admin_label'] ) && empty( $this->_req_data['QST_admin_label'] ) )) { |
|
331 | - $QST_text = isset( $this->_req_data['QST_display_text'] ) ? $this->_req_data['QST_display_text'] : '' ; |
|
332 | - $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text,10)); |
|
330 | + else if ($fieldName == 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) { |
|
331 | + $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : ''; |
|
332 | + $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10)); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
336 | - else if ( $fieldName == 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) { |
|
336 | + else if ($fieldName == 'QST_admin_only' && ( ! isset($this->_req_data['QST_admin_only']))) { |
|
337 | 337 | $set_column_values[$fieldName] = 0; |
338 | 338 | } |
339 | 339 | |
340 | - else if ( $fieldName == 'QST_max' ) { |
|
340 | + else if ($fieldName == 'QST_max') { |
|
341 | 341 | $qst_system = EEM_Question::instance()->get_var( |
342 | 342 | array( |
343 | 343 | array( |
344 | - 'QST_ID' => isset( $this->_req_data[ 'QST_ID' ] ) ? $this->_req_data[ 'QST_ID' ] : 0 |
|
344 | + 'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0 |
|
345 | 345 | ) |
346 | 346 | ), |
347 | 347 | 'QST_system' ); |
348 | - $max_max = EEM_Question::instance()->absolute_max_for_system_question( $qst_system ); |
|
349 | - if( empty( $this->_req_data[ 'QST_max' ] ) || |
|
350 | - $this->_req_data[ 'QST_max' ] > $max_max ) { |
|
351 | - $set_column_values[ $fieldName ] = $max_max; |
|
348 | + $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
349 | + if (empty($this->_req_data['QST_max']) || |
|
350 | + $this->_req_data['QST_max'] > $max_max) { |
|
351 | + $set_column_values[$fieldName] = $max_max; |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
355 | 355 | |
356 | 356 | //only add a property to the array if it's not null (otherwise the model should just use the default value) |
357 | - if( |
|
358 | - ! isset( $set_column_values[ $fieldName ] ) && |
|
359 | - isset($this->_req_data[$fieldName] ) ){ |
|
360 | - $set_column_values[$fieldName]=$this->_req_data[$fieldName]; |
|
357 | + if ( |
|
358 | + ! isset($set_column_values[$fieldName]) && |
|
359 | + isset($this->_req_data[$fieldName]) ) { |
|
360 | + $set_column_values[$fieldName] = $this->_req_data[$fieldName]; |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | } |
364 | - return $set_column_values;//validation fo this data to be performed by the model before insertion. |
|
364 | + return $set_column_values; //validation fo this data to be performed by the model before insertion. |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | |
@@ -379,30 +379,30 @@ discard block |
||
379 | 379 | /** |
380 | 380 | * @param string $action |
381 | 381 | */ |
382 | - protected function _edit_question( $action= 'add' ) { |
|
383 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
384 | - $ID=isset( $this->_req_data['QST_ID'] ) && ! empty( $this->_req_data['QST_ID'] ) ? absint( $this->_req_data['QST_ID'] ) : FALSE; |
|
382 | + protected function _edit_question($action = 'add') { |
|
383 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
384 | + $ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint($this->_req_data['QST_ID']) : FALSE; |
|
385 | 385 | |
386 | - $this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action )); |
|
386 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
387 | 387 | // add PRC_ID to title if editing |
388 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
389 | - if($ID){ |
|
390 | - $question=$this->_question_model->get_one_by_ID($ID); |
|
391 | - $additional_hidden_fields=array('QST_ID'=>array('type'=>'hidden','value'=>$ID)); |
|
388 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
389 | + if ($ID) { |
|
390 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
391 | + $additional_hidden_fields = array('QST_ID'=>array('type'=>'hidden', 'value'=>$ID)); |
|
392 | 392 | $this->_set_add_edit_form_tags('update_question', $additional_hidden_fields); |
393 | - }else{ |
|
394 | - $question= EE_Question::new_instance(); |
|
393 | + } else { |
|
394 | + $question = EE_Question::new_instance(); |
|
395 | 395 | $question->set_order_to_latest(); |
396 | 396 | $this->_set_add_edit_form_tags('insert_question'); |
397 | 397 | } |
398 | - $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category( $question->type() ) : $this->_question_model->allowed_question_types(); |
|
399 | - $this->_template_args['QST_ID']=$ID; |
|
400 | - $this->_template_args['question']=$question; |
|
401 | - $this->_template_args['question_types']= $question_types; |
|
402 | - $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question( $question->system_ID() ); |
|
398 | + $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category($question->type()) : $this->_question_model->allowed_question_types(); |
|
399 | + $this->_template_args['QST_ID'] = $ID; |
|
400 | + $this->_template_args['question'] = $question; |
|
401 | + $this->_template_args['question_types'] = $question_types; |
|
402 | + $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question($question->system_ID()); |
|
403 | 403 | |
404 | - $this->_set_publish_post_box_vars( 'id', $ID ); |
|
405 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', $this->_template_args, TRUE ); |
|
404 | + $this->_set_publish_post_box_vars('id', $ID); |
|
405 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH.'questions_main_meta_box.template.php', $this->_template_args, TRUE); |
|
406 | 406 | |
407 | 407 | // the details template wrapper |
408 | 408 | $this->display_admin_page_with_sidebar(); |
@@ -414,58 +414,58 @@ discard block |
||
414 | 414 | * @param bool|true $new_question |
415 | 415 | * @throws \EE_Error |
416 | 416 | */ |
417 | - protected function _insert_or_update_question( $new_question = TRUE) { |
|
418 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
419 | - $set_column_values=$this->_set_column_values_for($this->_question_model); |
|
420 | - if($new_question){ |
|
421 | - $ID=$this->_question_model->insert($set_column_values); |
|
417 | + protected function _insert_or_update_question($new_question = TRUE) { |
|
418 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
419 | + $set_column_values = $this->_set_column_values_for($this->_question_model); |
|
420 | + if ($new_question) { |
|
421 | + $ID = $this->_question_model->insert($set_column_values); |
|
422 | 422 | $success = $ID ? true : false; |
423 | 423 | $action_desc = 'added'; |
424 | - }else{ |
|
425 | - $ID=absint($this->_req_data['QST_ID']); |
|
426 | - $pk=$this->_question_model->primary_key_name(); |
|
427 | - $wheres=array($pk=>$ID); |
|
424 | + } else { |
|
425 | + $ID = absint($this->_req_data['QST_ID']); |
|
426 | + $pk = $this->_question_model->primary_key_name(); |
|
427 | + $wheres = array($pk=>$ID); |
|
428 | 428 | unset($set_column_values[$pk]); |
429 | - $success= $this->_question_model->update($set_column_values,array($wheres)); |
|
430 | - $action_desc='updated'; |
|
429 | + $success = $this->_question_model->update($set_column_values, array($wheres)); |
|
430 | + $action_desc = 'updated'; |
|
431 | 431 | } |
432 | 432 | |
433 | - if ($ID){ |
|
433 | + if ($ID) { |
|
434 | 434 | //save the related options |
435 | 435 | //trash removed options, save old ones |
436 | 436 | //get list of all options |
437 | 437 | /** @type EE_Question $question */ |
438 | - $question=$this->_question_model->get_one_by_ID($ID); |
|
439 | - $options=$question->options(); |
|
440 | - if(! empty($options)){ |
|
441 | - foreach($options as $option_ID=>$option){ |
|
442 | - $option_req_index=$this->_get_option_req_data_index($option_ID); |
|
443 | - if($option_req_index!==FALSE){ |
|
438 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
439 | + $options = $question->options(); |
|
440 | + if ( ! empty($options)) { |
|
441 | + foreach ($options as $option_ID=>$option) { |
|
442 | + $option_req_index = $this->_get_option_req_data_index($option_ID); |
|
443 | + if ($option_req_index !== FALSE) { |
|
444 | 444 | $option->save($this->_req_data['question_options'][$option_req_index]); |
445 | - }else{ |
|
445 | + } else { |
|
446 | 446 | //not found, remove it |
447 | 447 | $option->delete(); |
448 | 448 | } |
449 | 449 | } |
450 | 450 | } |
451 | 451 | //save new related options |
452 | - foreach($this->_req_data['question_options'] as $index=>$option_req_data){ |
|
453 | - if( empty($option_req_data['QSO_ID'] ) && ( ( isset( $option_req_data['QSO_value'] ) && $option_req_data['QSO_value'] !== '' ) || ! empty( $option_req_data['QSO_desc'] ) ) ) {//no ID! save it! |
|
454 | - if( ! isset( $option_req_data['QSO_value'] ) || $option_req_data['QSO_value'] === '' ){ |
|
455 | - $option_req_data['QSO_value']=$option_req_data['QSO_desc']; |
|
452 | + foreach ($this->_req_data['question_options'] as $index=>$option_req_data) { |
|
453 | + if (empty($option_req_data['QSO_ID']) && ((isset($option_req_data['QSO_value']) && $option_req_data['QSO_value'] !== '') || ! empty($option_req_data['QSO_desc']))) {//no ID! save it! |
|
454 | + if ( ! isset($option_req_data['QSO_value']) || $option_req_data['QSO_value'] === '') { |
|
455 | + $option_req_data['QSO_value'] = $option_req_data['QSO_desc']; |
|
456 | 456 | } |
457 | - $new_option=EE_Question_Option::new_instance( array( 'QSO_value' => $option_req_data['QSO_value'], 'QSO_desc' => $option_req_data['QSO_desc'], 'QSO_order' => $option_req_data['QSO_order'], 'QST_ID' => $question->ID())); |
|
457 | + $new_option = EE_Question_Option::new_instance(array('QSO_value' => $option_req_data['QSO_value'], 'QSO_desc' => $option_req_data['QSO_desc'], 'QSO_order' => $option_req_data['QSO_order'], 'QST_ID' => $question->ID())); |
|
458 | 458 | $new_option->save(); |
459 | 459 | } |
460 | 460 | } |
461 | 461 | } |
462 | - $query_args = array( 'action' => 'edit_question', 'QST_ID' => $ID ); |
|
463 | - if ( $success !== FALSE ) { |
|
464 | - $msg = $new_question ? sprintf( __('The %s has been created', 'event_espresso'), $this->_question_model->item_name() ) : sprintf( __('The %s has been updated', 'event_espresso' ), $this->_question_model->item_name() ); |
|
465 | - EE_Error::add_success( $msg ); |
|
462 | + $query_args = array('action' => 'edit_question', 'QST_ID' => $ID); |
|
463 | + if ($success !== FALSE) { |
|
464 | + $msg = $new_question ? sprintf(__('The %s has been created', 'event_espresso'), $this->_question_model->item_name()) : sprintf(__('The %s has been updated', 'event_espresso'), $this->_question_model->item_name()); |
|
465 | + EE_Error::add_success($msg); |
|
466 | 466 | } |
467 | 467 | |
468 | - $this->_redirect_after_action( FALSE, '', $action_desc, $query_args, TRUE); |
|
468 | + $this->_redirect_after_action(FALSE, '', $action_desc, $query_args, TRUE); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | |
@@ -478,10 +478,10 @@ discard block |
||
478 | 478 | * @param int $ID of the question option to find |
479 | 479 | * @return int index in question_options array if successful, FALSE if unsuccessful |
480 | 480 | */ |
481 | - protected function _get_option_req_data_index($ID){ |
|
482 | - $req_data_for_question_options=$this->_req_data['question_options']; |
|
483 | - foreach($req_data_for_question_options as $num=>$option_data){ |
|
484 | - if(array_key_exists('QSO_ID',$option_data) && intval($option_data['QSO_ID'])==$ID){ |
|
481 | + protected function _get_option_req_data_index($ID) { |
|
482 | + $req_data_for_question_options = $this->_req_data['question_options']; |
|
483 | + foreach ($req_data_for_question_options as $num=>$option_data) { |
|
484 | + if (array_key_exists('QSO_ID', $option_data) && intval($option_data['QSO_ID']) == $ID) { |
|
485 | 485 | return $num; |
486 | 486 | } |
487 | 487 | } |
@@ -503,25 +503,25 @@ discard block |
||
503 | 503 | * @param int $current_page |
504 | 504 | * @return array lik EEM_Base::get_all's $query_params parameter |
505 | 505 | */ |
506 | - protected function get_query_params($model, $per_page=10,$current_page=10){ |
|
506 | + protected function get_query_params($model, $per_page = 10, $current_page = 10) { |
|
507 | 507 | $query_params = array(); |
508 | - $offset=($current_page-1)*$per_page; |
|
509 | - $query_params['limit']=array($offset,$per_page); |
|
510 | - $order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
508 | + $offset = ($current_page - 1) * $per_page; |
|
509 | + $query_params['limit'] = array($offset, $per_page); |
|
510 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
511 | 511 | $orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order'; |
512 | 512 | $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby']; |
513 | - $query_params['order_by']=array( $field_to_order_by => $order ); |
|
514 | - $search_string = array_key_exists('s',$this->_req_data) ? $this->_req_data['s'] : null; |
|
515 | - if(! empty($search_string)){ |
|
516 | - if($model instanceof EEM_Question_Group){ |
|
517 | - $query_params[0]=array( |
|
513 | + $query_params['order_by'] = array($field_to_order_by => $order); |
|
514 | + $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null; |
|
515 | + if ( ! empty($search_string)) { |
|
516 | + if ($model instanceof EEM_Question_Group) { |
|
517 | + $query_params[0] = array( |
|
518 | 518 | 'OR'=>array( |
519 | - 'QSG_name'=>array('LIKE',"%$search_string%"), |
|
520 | - 'QSG_desc'=>array('LIKE',"%$search_string%")) |
|
519 | + 'QSG_name'=>array('LIKE', "%$search_string%"), |
|
520 | + 'QSG_desc'=>array('LIKE', "%$search_string%")) |
|
521 | 521 | ); |
522 | - }else{ |
|
523 | - $query_params[0]=array( |
|
524 | - 'QST_display_text'=>array('LIKE',"%$search_string%") |
|
522 | + } else { |
|
523 | + $query_params[0] = array( |
|
524 | + 'QST_display_text'=>array('LIKE', "%$search_string%") |
|
525 | 525 | ); |
526 | 526 | } |
527 | 527 | } |
@@ -569,13 +569,13 @@ discard block |
||
569 | 569 | * @param bool|false $count |
570 | 570 | * @return \EE_Soft_Delete_Base_Class[]|int |
571 | 571 | */ |
572 | - public function get_questions( $per_page=10, $current_page = 1, $count = FALSE ) { |
|
572 | + public function get_questions($per_page = 10, $current_page = 1, $count = FALSE) { |
|
573 | 573 | $QST = EEM_Question::instance(); |
574 | 574 | $query_params = $this->get_query_params($QST, $per_page, $current_page); |
575 | - if ($count){ |
|
576 | - $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
|
575 | + if ($count) { |
|
576 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
577 | 577 | $results = $QST->count($where); |
578 | - }else{ |
|
578 | + } else { |
|
579 | 579 | $results = $QST->get_all($query_params); |
580 | 580 | } |
581 | 581 | return $results; |
@@ -590,10 +590,10 @@ discard block |
||
590 | 590 | * @param bool|false $count |
591 | 591 | * @return \EE_Soft_Delete_Base_Class[]|int |
592 | 592 | */ |
593 | - public function get_trashed_questions( $per_page, $current_page = 1, $count = FALSE ) { |
|
594 | - $query_params =$this->get_query_params( EEM_Question::instance(), $per_page, $current_page); |
|
595 | - $where = isset( $query_params[0] ) ? array($query_params[0]) : array(); |
|
596 | - $questions =$count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
593 | + public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) { |
|
594 | + $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
595 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
596 | + $questions = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
597 | 597 | return $questions; |
598 | 598 | } |
599 | 599 | |
@@ -605,11 +605,11 @@ discard block |
||
605 | 605 | * @param bool|false $count |
606 | 606 | * @return \EE_Soft_Delete_Base_Class[] |
607 | 607 | */ |
608 | - public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) { |
|
608 | + public function get_question_groups($per_page, $current_page = 1, $count = FALSE) { |
|
609 | 609 | /** @type EEM_Question_Group $questionGroupModel */ |
610 | - $questionGroupModel=EEM_Question_Group::instance(); |
|
611 | - $query_params=$this->get_query_params( $questionGroupModel, $per_page, $current_page ); |
|
612 | - $questionGroups=$questionGroupModel->get_all($query_params);//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
610 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
611 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
612 | + $questionGroups = $questionGroupModel->get_all($query_params); //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
613 | 613 | return $questionGroups; |
614 | 614 | } |
615 | 615 | |
@@ -626,36 +626,36 @@ discard block |
||
626 | 626 | |
627 | 627 | $this->_template_args['values'] = $this->_yes_no_values; |
628 | 628 | |
629 | - $this->_template_args['use_captcha'] = isset( EE_Registry::instance()->CFG->registration->use_captcha ) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE; |
|
630 | - $this->_template_args['show_captcha_settings'] = $this->_template_args['use_captcha'] ? 'style="display:table-row;"': ''; |
|
629 | + $this->_template_args['use_captcha'] = isset(EE_Registry::instance()->CFG->registration->use_captcha) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE; |
|
630 | + $this->_template_args['show_captcha_settings'] = $this->_template_args['use_captcha'] ? 'style="display:table-row;"' : ''; |
|
631 | 631 | |
632 | - $this->_template_args['recaptcha_publickey'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) : ''; |
|
633 | - $this->_template_args['recaptcha_privatekey'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) : ''; |
|
634 | - $this->_template_args['recaptcha_width'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_width ) ? absint( EE_Registry::instance()->CFG->registration->recaptcha_width ) : 500; |
|
632 | + $this->_template_args['recaptcha_publickey'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_publickey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_publickey) : ''; |
|
633 | + $this->_template_args['recaptcha_privatekey'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) : ''; |
|
634 | + $this->_template_args['recaptcha_width'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_width) ? absint(EE_Registry::instance()->CFG->registration->recaptcha_width) : 500; |
|
635 | 635 | |
636 | 636 | $this->_template_args['recaptcha_theme_options'] = array( |
637 | - array('id' => 'red','text'=> __('Red', 'event_espresso')), |
|
638 | - array('id' => 'white','text'=> __('White', 'event_espresso')), |
|
639 | - array('id' => 'blackglass','text'=> __('Blackglass', 'event_espresso')), |
|
640 | - array('id' => 'clean','text'=> __('Clean', 'event_espresso')) |
|
637 | + array('id' => 'red', 'text'=> __('Red', 'event_espresso')), |
|
638 | + array('id' => 'white', 'text'=> __('White', 'event_espresso')), |
|
639 | + array('id' => 'blackglass', 'text'=> __('Blackglass', 'event_espresso')), |
|
640 | + array('id' => 'clean', 'text'=> __('Clean', 'event_espresso')) |
|
641 | 641 | ); |
642 | - $this->_template_args['recaptcha_theme'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_theme ) ? EE_Registry::instance()->CFG->registration->get_pretty( 'recaptcha_theme' ) : 'clean'; |
|
642 | + $this->_template_args['recaptcha_theme'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_theme) ? EE_Registry::instance()->CFG->registration->get_pretty('recaptcha_theme') : 'clean'; |
|
643 | 643 | |
644 | 644 | $this->_template_args['recaptcha_language_options'] = array( |
645 | - array('id' => 'en','text'=> __('English', 'event_espresso')), |
|
646 | - array('id' => 'es','text'=> __('Spanish', 'event_espresso')), |
|
647 | - array('id' => 'nl','text'=> __('Dutch', 'event_espresso')), |
|
648 | - array('id' => 'fr','text'=> __('French', 'event_espresso')), |
|
649 | - array('id' => 'de','text'=> __('German', 'event_espresso')), |
|
650 | - array('id' => 'pt','text'=> __('Portuguese', 'event_espresso')), |
|
651 | - array('id' => 'ru','text'=> __('Russian', 'event_espresso')), |
|
652 | - array('id' => 'tr','text'=> __('Turkish', 'event_espresso')) |
|
645 | + array('id' => 'en', 'text'=> __('English', 'event_espresso')), |
|
646 | + array('id' => 'es', 'text'=> __('Spanish', 'event_espresso')), |
|
647 | + array('id' => 'nl', 'text'=> __('Dutch', 'event_espresso')), |
|
648 | + array('id' => 'fr', 'text'=> __('French', 'event_espresso')), |
|
649 | + array('id' => 'de', 'text'=> __('German', 'event_espresso')), |
|
650 | + array('id' => 'pt', 'text'=> __('Portuguese', 'event_espresso')), |
|
651 | + array('id' => 'ru', 'text'=> __('Russian', 'event_espresso')), |
|
652 | + array('id' => 'tr', 'text'=> __('Turkish', 'event_espresso')) |
|
653 | 653 | ); |
654 | - $this->_template_args['recaptcha_language'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_language ) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en'; |
|
654 | + $this->_template_args['recaptcha_language'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_language) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en'; |
|
655 | 655 | |
656 | - $this->_set_add_edit_form_tags( 'update_reg_form_settings' ); |
|
657 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
658 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_TEMPLATE_PATH . 'reg_form_settings.template.php', $this->_template_args, TRUE ); |
|
656 | + $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
657 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
658 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH.'reg_form_settings.template.php', $this->_template_args, TRUE); |
|
659 | 659 | $this->display_admin_page_with_sidebar(); |
660 | 660 | } |
661 | 661 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | // check if class object is instantiated, and instantiated properly |
38 | - if ( ! self::$_instance instanceof EE_Payment_Method_Manager ) { |
|
38 | + if ( ! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
39 | 39 | self::$_instance = new self(); |
40 | 40 | } |
41 | 41 | EE_Registry::instance()->load_lib('PMT_Base'); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * Resets the instance and returns a new one |
47 | 47 | * @return EE_Payment_Method_Manager |
48 | 48 | */ |
49 | - public static function reset(){ |
|
49 | + public static function reset() { |
|
50 | 50 | self::$_instance = NULL; |
51 | 51 | return self::instance(); |
52 | 52 | } |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | * or just re-use the PMTs we found last time we checked during this request (if |
58 | 58 | * we have not yet checked during this request, then we need to check anyways) |
59 | 59 | */ |
60 | - public function maybe_register_payment_methods( $force_recheck = FALSE ){ |
|
61 | - if( ! $this->_payment_method_types || $force_recheck ){ |
|
60 | + public function maybe_register_payment_methods($force_recheck = FALSE) { |
|
61 | + if ( ! $this->_payment_method_types || $force_recheck) { |
|
62 | 62 | $this->_register_payment_methods(); |
63 | 63 | //if in admin lets ensure caps are set. |
64 | - if ( is_admin() ) { |
|
65 | - add_filter( 'FHEE__EE_Capabilities__init_caps_map__caps', array( $this, 'add_payment_method_caps' ) ); |
|
64 | + if (is_admin()) { |
|
65 | + add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps')); |
|
66 | 66 | EE_Registry::instance()->CAP->init_caps(); |
67 | 67 | } |
68 | 68 | } |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | */ |
76 | 76 | protected function _register_payment_methods() { |
77 | 77 | // grab list of installed modules |
78 | - $pm_to_register = glob( EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR ); |
|
78 | + $pm_to_register = glob(EE_PAYMENT_METHODS.'*', GLOB_ONLYDIR); |
|
79 | 79 | // filter list of modules to register |
80 | - $pm_to_register = apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register ); |
|
80 | + $pm_to_register = apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register); |
|
81 | 81 | |
82 | 82 | // loop through folders |
83 | - foreach ( $pm_to_register as $pm_path ) { |
|
84 | - $this->register_payment_method( $pm_path ); |
|
83 | + foreach ($pm_to_register as $pm_path) { |
|
84 | + $this->register_payment_method($pm_path); |
|
85 | 85 | } |
86 | - do_action( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods' ); |
|
86 | + do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods'); |
|
87 | 87 | // filter list of installed modules |
88 | 88 | //keep them organized alphabetically by the payment method type's name |
89 | - ksort( $this->_payment_method_types ); |
|
90 | - return apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types ); |
|
89 | + ksort($this->_payment_method_types); |
|
90 | + return apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -99,35 +99,35 @@ discard block |
||
99 | 99 | * @param string $payment_method_path - full path up to and including payment method folder |
100 | 100 | * @return boolean |
101 | 101 | */ |
102 | - public function register_payment_method( $payment_method_path = '' ) { |
|
103 | - do_action( 'AHEE__EE_Payment_Method_Manager__register_payment_method__begin',$payment_method_path ); |
|
102 | + public function register_payment_method($payment_method_path = '') { |
|
103 | + do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path); |
|
104 | 104 | $module_ext = '.pm.php'; |
105 | 105 | // make all separators match |
106 | - $payment_method_path = rtrim( str_replace( '/\\', DS, $payment_method_path ), DS ); |
|
106 | + $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS); |
|
107 | 107 | // grab and sanitize module name |
108 | - $module_dir = basename( $payment_method_path ); |
|
108 | + $module_dir = basename($payment_method_path); |
|
109 | 109 | // create classname from module directory name |
110 | - $module = str_replace( ' ', '_', str_replace( '_', ' ', $module_dir )); |
|
110 | + $module = str_replace(' ', '_', str_replace('_', ' ', $module_dir)); |
|
111 | 111 | // add class prefix |
112 | - $module_class = 'EE_PMT_' . $module; |
|
112 | + $module_class = 'EE_PMT_'.$module; |
|
113 | 113 | // does the module exist ? |
114 | - if ( ! is_readable( $payment_method_path . DS . $module_class . $module_ext )) { |
|
115 | - $msg = sprintf( __( 'The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso' ), $module ); |
|
116 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
114 | + if ( ! is_readable($payment_method_path.DS.$module_class.$module_ext)) { |
|
115 | + $msg = sprintf(__('The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso'), $module); |
|
116 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
117 | 117 | return FALSE; |
118 | 118 | } |
119 | - if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->start_timer(); } |
|
119 | + if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->start_timer(); } |
|
120 | 120 | // load the module class file |
121 | - require_once( $payment_method_path . DS . $module_class . $module_ext ); |
|
122 | - if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); } |
|
121 | + require_once($payment_method_path.DS.$module_class.$module_ext); |
|
122 | + if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); } |
|
123 | 123 | // verify that class exists |
124 | - if ( ! class_exists( $module_class )) { |
|
125 | - $msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class ); |
|
126 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
124 | + if ( ! class_exists($module_class)) { |
|
125 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
126 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
127 | 127 | return FALSE; |
128 | 128 | } |
129 | 129 | // add to array of registered modules |
130 | - $this->_payment_method_types[ $module ] = $payment_method_path . DS . $module_class . $module_ext; |
|
130 | + $this->_payment_method_types[$module] = $payment_method_path.DS.$module_class.$module_ext; |
|
131 | 131 | return TRUE; |
132 | 132 | } |
133 | 133 | /** |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
137 | 137 | * @return boolean |
138 | 138 | */ |
139 | - public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE){ |
|
140 | - if ( ! is_array( $this->_payment_method_types ) || ! isset( $this->_payment_method_types[$payment_method_name] ) |
|
141 | - || $force_recheck ) { |
|
139 | + public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE) { |
|
140 | + if ( ! is_array($this->_payment_method_types) || ! isset($this->_payment_method_types[$payment_method_name]) |
|
141 | + || $force_recheck) { |
|
142 | 142 | $this->maybe_register_payment_methods($force_recheck); |
143 | 143 | } |
144 | - if(isset($this->_payment_method_types[$payment_method_name])){ |
|
144 | + if (isset($this->_payment_method_types[$payment_method_name])) { |
|
145 | 145 | require_once($this->_payment_method_types[$payment_method_name]); |
146 | 146 | return true; |
147 | - }else{ |
|
147 | + } else { |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | } |
@@ -155,16 +155,16 @@ discard block |
||
155 | 155 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
156 | 156 | * @return array |
157 | 157 | */ |
158 | - public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE ){ |
|
158 | + public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE) { |
|
159 | 159 | $this->maybe_register_payment_methods($force_recheck); |
160 | - if($with_prefixes){ |
|
160 | + if ($with_prefixes) { |
|
161 | 161 | $classnames = array_keys($this->_payment_method_types); |
162 | 162 | $payment_methods = array(); |
163 | - foreach($classnames as $classname){ |
|
163 | + foreach ($classnames as $classname) { |
|
164 | 164 | $payment_methods[] = $this->payment_method_class_from_type($classname); |
165 | 165 | } |
166 | 166 | return $payment_methods; |
167 | - }else{ |
|
167 | + } else { |
|
168 | 168 | return array_keys($this->_payment_method_types); |
169 | 169 | } |
170 | 170 | } |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
175 | 175 | * @return EE_PMT_Base[] |
176 | 176 | */ |
177 | - public function payment_method_types( $force_recheck = FALSE ){ |
|
177 | + public function payment_method_types($force_recheck = FALSE) { |
|
178 | 178 | $this->maybe_register_payment_methods($force_recheck); |
179 | 179 | $pmt_objs = array(); |
180 | - foreach($this->payment_method_type_names(true) as $classname){ |
|
180 | + foreach ($this->payment_method_type_names(true) as $classname) { |
|
181 | 181 | $pmt_objs[] = new $classname; |
182 | 182 | } |
183 | 183 | return $pmt_objs; |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | * @param string $classname |
190 | 190 | * @return string |
191 | 191 | */ |
192 | - public function payment_method_type_sans_class_prefix($classname){ |
|
193 | - $pmt_name = str_replace("EE_PMT_","",$classname); |
|
192 | + public function payment_method_type_sans_class_prefix($classname) { |
|
193 | + $pmt_name = str_replace("EE_PMT_", "", $classname); |
|
194 | 194 | return $pmt_name; |
195 | 195 | } |
196 | 196 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @param string $type |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public function payment_method_class_from_type($type){ |
|
202 | + public function payment_method_class_from_type($type) { |
|
203 | 203 | $this->maybe_register_payment_methods(); |
204 | 204 | return "EE_PMT_".$type; |
205 | 205 | } |
@@ -213,38 +213,38 @@ discard block |
||
213 | 213 | * @return \EE_Payment_Method |
214 | 214 | * @throws \EE_Error |
215 | 215 | */ |
216 | - public function activate_a_payment_method_of_type( $payment_method_type ){ |
|
216 | + public function activate_a_payment_method_of_type($payment_method_type) { |
|
217 | 217 | $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type); |
218 | - if( ! $payment_method instanceof EE_Payment_Method ){ |
|
218 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
219 | 219 | $pm_type_class = $this->payment_method_class_from_type($payment_method_type); |
220 | - if(class_exists($pm_type_class)){ |
|
220 | + if (class_exists($pm_type_class)) { |
|
221 | 221 | /** @var $pm_type_obj EE_PMT_Base */ |
222 | 222 | $pm_type_obj = new $pm_type_class; |
223 | 223 | $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name()); |
224 | - if( ! $payment_method){ |
|
225 | - $payment_method = $this->create_payment_method_of_type( $pm_type_obj ); |
|
224 | + if ( ! $payment_method) { |
|
225 | + $payment_method = $this->create_payment_method_of_type($pm_type_obj); |
|
226 | 226 | } |
227 | - $payment_method->set_type( $payment_method_type ); |
|
228 | - $this->initialize_payment_method( $payment_method ); |
|
227 | + $payment_method->set_type($payment_method_type); |
|
228 | + $this->initialize_payment_method($payment_method); |
|
229 | 229 | } else { |
230 | 230 | throw new EE_Error( |
231 | 231 | sprintf( |
232 | - __( 'There is no payment method of type %1$s, so it could not be activated', 'event_espresso'), |
|
232 | + __('There is no payment method of type %1$s, so it could not be activated', 'event_espresso'), |
|
233 | 233 | $pm_type_class ) |
234 | 234 | ); |
235 | 235 | } |
236 | 236 | } |
237 | 237 | $payment_method->set_active(); |
238 | 238 | $payment_method->save(); |
239 | - $this->set_usable_currencies_on_payment_method( $payment_method ); |
|
240 | - if( $payment_method->type() == 'Invoice' ){ |
|
241 | - $messages = EE_Registry::instance()->load_lib( 'messages' ); |
|
242 | - $messages->ensure_message_type_is_active( 'invoice', 'html' ); |
|
243 | - $messages->ensure_messenger_is_active( 'pdf' ); |
|
239 | + $this->set_usable_currencies_on_payment_method($payment_method); |
|
240 | + if ($payment_method->type() == 'Invoice') { |
|
241 | + $messages = EE_Registry::instance()->load_lib('messages'); |
|
242 | + $messages->ensure_message_type_is_active('invoice', 'html'); |
|
243 | + $messages->ensure_messenger_is_active('pdf'); |
|
244 | 244 | EE_Error::add_attention( |
245 | 245 | sprintf( |
246 | - __( 'Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso' ), |
|
247 | - '<a href="' . admin_url( 'admin.php?page=espresso_messages') . '">', |
|
246 | + __('Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso'), |
|
247 | + '<a href="'.admin_url('admin.php?page=espresso_messages').'">', |
|
248 | 248 | '</a>' |
249 | 249 | ) |
250 | 250 | ); |
@@ -258,17 +258,17 @@ discard block |
||
258 | 258 | * @param EE_PMT_Base $pm_type_obj |
259 | 259 | * @return EE_Payment_Method |
260 | 260 | */ |
261 | - public function create_payment_method_of_type( $pm_type_obj ) { |
|
261 | + public function create_payment_method_of_type($pm_type_obj) { |
|
262 | 262 | global $current_user; |
263 | 263 | $payment_method = EE_Payment_Method::new_instance( |
264 | 264 | array( |
265 | 265 | 'PMD_type' => $pm_type_obj->system_name(), |
266 | 266 | 'PMD_name' => $pm_type_obj->pretty_name(), |
267 | 267 | 'PMD_admin_name' => $pm_type_obj->pretty_name(), |
268 | - 'PMD_slug' => $pm_type_obj->system_name(),//automatically converted to slug |
|
268 | + 'PMD_slug' => $pm_type_obj->system_name(), //automatically converted to slug |
|
269 | 269 | 'PMD_wp_user' => $current_user->ID, |
270 | 270 | 'PMD_order' => EEM_Payment_Method::instance()->count( |
271 | - array( array( 'PMD_type' => array( '!=', 'Admin_Only' ))) |
|
271 | + array(array('PMD_type' => array('!=', 'Admin_Only'))) |
|
272 | 272 | ) * 10, |
273 | 273 | ) |
274 | 274 | ); |
@@ -280,16 +280,16 @@ discard block |
||
280 | 280 | * @param EE_Payment_Method $payment_method |
281 | 281 | * @return EE_Payment_Method |
282 | 282 | */ |
283 | - public function initialize_payment_method( $payment_method ) { |
|
283 | + public function initialize_payment_method($payment_method) { |
|
284 | 284 | $pm_type_obj = $payment_method->type_obj(); |
285 | - $payment_method->set_description( $pm_type_obj->default_description() ); |
|
286 | - if( ! $payment_method->button_url() ){ |
|
287 | - $payment_method->set_button_url( $pm_type_obj->default_button_url() ); |
|
285 | + $payment_method->set_description($pm_type_obj->default_description()); |
|
286 | + if ( ! $payment_method->button_url()) { |
|
287 | + $payment_method->set_button_url($pm_type_obj->default_button_url()); |
|
288 | 288 | } |
289 | 289 | //now add setup its default extra meta properties |
290 | 290 | $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs(); |
291 | - foreach( $extra_metas as $meta_name => $input ){ |
|
292 | - $payment_method->update_extra_meta($meta_name, $input->raw_value() ); |
|
291 | + foreach ($extra_metas as $meta_name => $input) { |
|
292 | + $payment_method->update_extra_meta($meta_name, $input->raw_value()); |
|
293 | 293 | } |
294 | 294 | return $payment_method; |
295 | 295 | } |
@@ -299,8 +299,8 @@ discard block |
||
299 | 299 | * @param EE_Payment_Method $payment_method |
300 | 300 | * @return EE_Payment_Method |
301 | 301 | */ |
302 | - public function set_usable_currencies_on_payment_method( $payment_method ) { |
|
303 | - foreach($payment_method->get_all_usable_currencies() as $currency_obj){ |
|
302 | + public function set_usable_currencies_on_payment_method($payment_method) { |
|
303 | + foreach ($payment_method->get_all_usable_currencies() as $currency_obj) { |
|
304 | 304 | $payment_method->_add_relation_to($currency_obj, 'Currency'); |
305 | 305 | } |
306 | 306 | return $payment_method; |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @return int count of rows updated. |
320 | 320 | */ |
321 | - public function deactivate_payment_method( $payment_method_slug ) { |
|
322 | - $count_updated = EEM_Payment_Method::instance()->update(array('PMD_scope'=>array()),array(array('PMD_slug'=>$payment_method_slug))); |
|
321 | + public function deactivate_payment_method($payment_method_slug) { |
|
322 | + $count_updated = EEM_Payment_Method::instance()->update(array('PMD_scope'=>array()), array(array('PMD_slug'=>$payment_method_slug))); |
|
323 | 323 | return $count_updated; |
324 | 324 | } |
325 | 325 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @param array $caps capabilities being filtered |
333 | 333 | * @return array |
334 | 334 | */ |
335 | - public function add_payment_method_caps( $caps ) { |
|
335 | + public function add_payment_method_caps($caps) { |
|
336 | 336 | /* add dynamic caps from payment methods |
337 | 337 | * at the time of writing, october 20 2014, these are the caps added: |
338 | 338 | * ee_payment_method_admin_only |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * their related capability automatically added too, so long as they are |
348 | 348 | * registered properly using EE_Register_Payment_Method::register() |
349 | 349 | */ |
350 | - foreach( $this->payment_method_types() as $payment_method_type_obj ){ |
|
350 | + foreach ($this->payment_method_types() as $payment_method_type_obj) { |
|
351 | 351 | $caps['administrator'][] = $payment_method_type_obj->cap_name(); |
352 | 352 | } |
353 | 353 | return $caps; |