@@ -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 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | /** |
185 | 185 | * returns the text for displaying the question to users |
186 | 186 | * @access public |
187 | - * @return string |
|
187 | + * @return boolean |
|
188 | 188 | */ |
189 | 189 | public function display_text() { |
190 | 190 | return $this->get( 'QST_display_text' ); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | /** |
196 | 196 | * returns the text for the administrative label |
197 | 197 | * @access public |
198 | - * @return string |
|
198 | + * @return boolean |
|
199 | 199 | */ |
200 | 200 | public function admin_label() { |
201 | 201 | return $this->get( 'QST_admin_label' ); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | /** |
207 | 207 | * returns the attendee column name for this question |
208 | 208 | * @access public |
209 | - * @return string |
|
209 | + * @return boolean |
|
210 | 210 | */ |
211 | 211 | public function system_ID() { |
212 | 212 | return $this->get( 'QST_system' ); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * returns the text which should be displayed when a user |
230 | 230 | * doesn't answer this question in a form |
231 | 231 | * @access public |
232 | - * @return string |
|
232 | + * @return boolean |
|
233 | 233 | */ |
234 | 234 | public function required_text() { |
235 | 235 | return $this->get( 'QST_required_text' ); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | /** |
241 | 241 | * returns the type of this question |
242 | 242 | * @access public |
243 | - * @return string |
|
243 | + * @return boolean |
|
244 | 244 | */ |
245 | 245 | public function type() { |
246 | 246 | return $this->get( 'QST_type' ); |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * returns an integer showing where this question should |
253 | 253 | * be placed in a sequence of questions |
254 | 254 | * @access public |
255 | - * @return int |
|
255 | + * @return boolean |
|
256 | 256 | */ |
257 | 257 | public function order() { |
258 | 258 | return $this->get( 'QST_order' ); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | /** |
276 | 276 | * returns the id the wordpress user who created this question |
277 | 277 | * @access public |
278 | - * @return int |
|
278 | + * @return boolean |
|
279 | 279 | */ |
280 | 280 | public function wp_user() { |
281 | 281 | return $this->get( 'QST_wp_user' ); |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * Adds an option for this question. Note: if the option were previously associated with a different |
370 | 370 | * Question, that relationship will be overwritten. |
371 | 371 | * @param EE_Question_Option $option |
372 | - * @return boolean success |
|
372 | + * @return EE_Base_Class success |
|
373 | 373 | */ |
374 | 374 | public function add_option( EE_Question_Option $option ) { |
375 | 375 | return $this->_add_relation_to( $option, 'Question_Option' ); |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | /** |
393 | 393 | * Marks the option as deleted. |
394 | 394 | * @param EE_Question_Option $option |
395 | - * @return boolean success |
|
395 | + * @return EE_Base_Class success |
|
396 | 396 | */ |
397 | 397 | public function remove_option( EE_Question_Option $option ) { |
398 | 398 | return $this->_remove_relation_to( $option, 'Question_Option' ); |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | |
462 | 462 | /** |
463 | 463 | * Returns the question's maximum allowed response size |
464 | - * @return int|float |
|
464 | + * @return boolean |
|
465 | 465 | */ |
466 | 466 | public function max() { |
467 | 467 | return $this->get( 'QST_max' ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | * date_format and the second value is the time format |
38 | 38 | * @return EE_Question |
39 | 39 | */ |
40 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
41 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
42 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
40 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
41 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
42 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * the website will be used. |
51 | 51 | * @return EE_Question |
52 | 52 | */ |
53 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
54 | - return new self( $props_n_values, TRUE, $timezone ); |
|
53 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
54 | + return new self($props_n_values, TRUE, $timezone); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * @access public |
63 | 63 | * @param string $QST_display_text |
64 | 64 | */ |
65 | - public function set_display_text( $QST_display_text = '' ) { |
|
66 | - $this->set( 'QST_display_text', $QST_display_text ); |
|
65 | + public function set_display_text($QST_display_text = '') { |
|
66 | + $this->set('QST_display_text', $QST_display_text); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | * @access public |
75 | 75 | * @param string $QST_admin_label |
76 | 76 | */ |
77 | - public function set_admin_label( $QST_admin_label = '' ) { |
|
78 | - $this->set( 'QST_admin_label', $QST_admin_label ); |
|
77 | + public function set_admin_label($QST_admin_label = '') { |
|
78 | + $this->set('QST_admin_label', $QST_admin_label); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | * @access public |
87 | 87 | * @param mixed $QST_system |
88 | 88 | */ |
89 | - public function set_system_ID( $QST_system = '' ) { |
|
90 | - $this->set( 'QST_system', $QST_system ); |
|
89 | + public function set_system_ID($QST_system = '') { |
|
90 | + $this->set('QST_system', $QST_system); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | * @access public |
99 | 99 | * @param string $QST_type |
100 | 100 | */ |
101 | - public function set_question_type( $QST_type = '' ) { |
|
102 | - $this->set( 'QST_type', $QST_type ); |
|
101 | + public function set_question_type($QST_type = '') { |
|
102 | + $this->set('QST_type', $QST_type); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | * @access public |
111 | 111 | * @param bool $QST_required |
112 | 112 | */ |
113 | - public function set_required( $QST_required = FALSE ) { |
|
114 | - $this->set( 'QST_required', $QST_required ); |
|
113 | + public function set_required($QST_required = FALSE) { |
|
114 | + $this->set('QST_required', $QST_required); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @access public |
123 | 123 | * @param string $QST_required_text |
124 | 124 | */ |
125 | - public function set_required_text( $QST_required_text = '' ) { |
|
126 | - $this->set( 'QST_required_text', $QST_required_text ); |
|
125 | + public function set_required_text($QST_required_text = '') { |
|
126 | + $this->set('QST_required_text', $QST_required_text); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | * @access public |
135 | 135 | * @param int $QST_order |
136 | 136 | */ |
137 | - public function set_order( $QST_order = 0 ) { |
|
138 | - $this->set( 'QST_order', $QST_order ); |
|
137 | + public function set_order($QST_order = 0) { |
|
138 | + $this->set('QST_order', $QST_order); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @access public |
147 | 147 | * @param bool $QST_admin_only |
148 | 148 | */ |
149 | - public function set_admin_only( $QST_admin_only = FALSE ) { |
|
150 | - $this->set( 'QST_admin_only', $QST_admin_only ); |
|
149 | + public function set_admin_only($QST_admin_only = FALSE) { |
|
150 | + $this->set('QST_admin_only', $QST_admin_only); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @access public |
159 | 159 | * @param int $QST_wp_user |
160 | 160 | */ |
161 | - public function set_wp_user( $QST_wp_user = 1 ) { |
|
162 | - $this->set( 'QST_wp_user', $QST_wp_user ); |
|
161 | + public function set_wp_user($QST_wp_user = 1) { |
|
162 | + $this->set('QST_wp_user', $QST_wp_user); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | * @access public |
176 | 176 | * @param bool $QST_deleted |
177 | 177 | */ |
178 | - public function set_deleted( $QST_deleted = FALSE ) { |
|
179 | - $this->set( 'QST_deleted', $QST_deleted ); |
|
178 | + public function set_deleted($QST_deleted = FALSE) { |
|
179 | + $this->set('QST_deleted', $QST_deleted); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @return string |
188 | 188 | */ |
189 | 189 | public function display_text() { |
190 | - return $this->get( 'QST_display_text' ); |
|
190 | + return $this->get('QST_display_text'); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @return string |
199 | 199 | */ |
200 | 200 | public function admin_label() { |
201 | - return $this->get( 'QST_admin_label' ); |
|
201 | + return $this->get('QST_admin_label'); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @return string |
210 | 210 | */ |
211 | 211 | public function system_ID() { |
212 | - return $this->get( 'QST_system' ); |
|
212 | + return $this->get('QST_system'); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @return boolean |
221 | 221 | */ |
222 | 222 | public function required() { |
223 | - return $this->get( 'QST_required' ); |
|
223 | + return $this->get('QST_required'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @return string |
233 | 233 | */ |
234 | 234 | public function required_text() { |
235 | - return $this->get( 'QST_required_text' ); |
|
235 | + return $this->get('QST_required_text'); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @return string |
244 | 244 | */ |
245 | 245 | public function type() { |
246 | - return $this->get( 'QST_type' ); |
|
246 | + return $this->get('QST_type'); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @return int |
256 | 256 | */ |
257 | 257 | public function order() { |
258 | - return $this->get( 'QST_order' ); |
|
258 | + return $this->get('QST_order'); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @return boolean |
268 | 268 | */ |
269 | 269 | public function admin_only() { |
270 | - return $this->get( 'QST_admin_only' ); |
|
270 | + return $this->get('QST_admin_only'); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @return int |
279 | 279 | */ |
280 | 280 | public function wp_user() { |
281 | - return $this->get( 'QST_wp_user' ); |
|
281 | + return $this->get('QST_wp_user'); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @return boolean |
290 | 290 | */ |
291 | 291 | public function deleted() { |
292 | - return $this->get( 'QST_deleted' ); |
|
292 | + return $this->get('QST_deleted'); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @return EE_Answer[] |
300 | 300 | */ |
301 | 301 | public function answers() { |
302 | - return $this->get_many_related( 'Answer' ); |
|
302 | + return $this->get_many_related('Answer'); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @return boolean true = has answers, false = no answers. |
310 | 310 | */ |
311 | 311 | public function has_answers() { |
312 | - return $this->count_related( 'Answer' ) > 0 ? TRUE : FALSE; |
|
312 | + return $this->count_related('Answer') > 0 ? TRUE : FALSE; |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @return EE_Question_Group[] |
320 | 320 | */ |
321 | 321 | public function question_groups() { |
322 | - return $this->get_many_related( 'Question_Group' ); |
|
322 | + return $this->get_many_related('Question_Group'); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -333,24 +333,24 @@ discard block |
||
333 | 333 | * whether it was trashed or not. |
334 | 334 | * @return EE_Question_Option[] |
335 | 335 | */ |
336 | - public function options( $notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL ) { |
|
337 | - if ( ! $this->ID() ) { |
|
336 | + public function options($notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL) { |
|
337 | + if ( ! $this->ID()) { |
|
338 | 338 | return array(); |
339 | 339 | } |
340 | 340 | $query_params = array(); |
341 | - if ( $selected_value_to_always_include ) { |
|
342 | - if ( is_array( $selected_value_to_always_include ) ) { |
|
343 | - $query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = array( 'IN', $selected_value_to_always_include ); |
|
341 | + if ($selected_value_to_always_include) { |
|
342 | + if (is_array($selected_value_to_always_include)) { |
|
343 | + $query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include); |
|
344 | 344 | } else { |
345 | - $query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = $selected_value_to_always_include; |
|
345 | + $query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include; |
|
346 | 346 | } |
347 | 347 | } |
348 | - if ( $notDeletedOptionsOnly ) { |
|
349 | - $query_params[ 0 ][ 'OR*options-query' ][ 'QSO_deleted' ] = FALSE; |
|
348 | + if ($notDeletedOptionsOnly) { |
|
349 | + $query_params[0]['OR*options-query']['QSO_deleted'] = FALSE; |
|
350 | 350 | } |
351 | 351 | //order by QSO_order |
352 | - $query_params[ 'order_by' ] = array( 'QSO_order' => 'ASC' ); |
|
353 | - return $this->get_many_related( 'Question_Option', $query_params ); |
|
352 | + $query_params['order_by'] = array('QSO_order' => 'ASC'); |
|
353 | + return $this->get_many_related('Question_Option', $query_params); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @return \EE_Question_Option[] |
361 | 361 | */ |
362 | 362 | public function temp_options() { |
363 | - return $this->_model_relations[ 'Question_Option' ]; |
|
363 | + return $this->_model_relations['Question_Option']; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | |
@@ -371,8 +371,8 @@ discard block |
||
371 | 371 | * @param EE_Question_Option $option |
372 | 372 | * @return boolean success |
373 | 373 | */ |
374 | - public function add_option( EE_Question_Option $option ) { |
|
375 | - return $this->_add_relation_to( $option, 'Question_Option' ); |
|
374 | + public function add_option(EE_Question_Option $option) { |
|
375 | + return $this->_add_relation_to($option, 'Question_Option'); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | * @param EE_Question_Option $option |
383 | 383 | * @return boolean success |
384 | 384 | */ |
385 | - public function add_temp_option( EE_Question_Option $option ) { |
|
386 | - $this->_model_relations[ 'Question_Option' ][ ] = $option; |
|
385 | + public function add_temp_option(EE_Question_Option $option) { |
|
386 | + $this->_model_relations['Question_Option'][] = $option; |
|
387 | 387 | return TRUE; |
388 | 388 | } |
389 | 389 | |
@@ -394,8 +394,8 @@ discard block |
||
394 | 394 | * @param EE_Question_Option $option |
395 | 395 | * @return boolean success |
396 | 396 | */ |
397 | - public function remove_option( EE_Question_Option $option ) { |
|
398 | - return $this->_remove_relation_to( $option, 'Question_Option' ); |
|
397 | + public function remove_option(EE_Question_Option $option) { |
|
398 | + return $this->_remove_relation_to($option, 'Question_Option'); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | * @return bool |
405 | 405 | */ |
406 | 406 | public function is_system_question() { |
407 | - $system_ID = $this->get( 'QST_system' ); |
|
408 | - return ! empty( $system_ID ) ? TRUE : FALSE; |
|
407 | + $system_ID = $this->get('QST_system'); |
|
408 | + return ! empty($system_ID) ? TRUE : FALSE; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | */ |
419 | 419 | public function set_order_to_latest() { |
420 | 420 | $latest_order = $this->get_model()->get_latest_question_order(); |
421 | - $latest_order ++; |
|
422 | - $this->set( 'QST_order', $latest_order ); |
|
421 | + $latest_order++; |
|
422 | + $this->set('QST_order', $latest_order); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | |
@@ -438,20 +438,20 @@ discard block |
||
438 | 438 | * Duplicates this question and its question options |
439 | 439 | * @return \EE_Question |
440 | 440 | */ |
441 | - public function duplicate( $options = array() ) { |
|
441 | + public function duplicate($options = array()) { |
|
442 | 442 | $new_question = clone $this; |
443 | - $new_question->set( 'QST_ID', null ); |
|
444 | - $new_question->set_display_text( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->display_text() ) ); |
|
445 | - $new_question->set_admin_label( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->admin_label() ) ); |
|
446 | - $new_question->set_system_ID( null ); |
|
447 | - $new_question->set_wp_user( get_current_user_id() ); |
|
443 | + $new_question->set('QST_ID', null); |
|
444 | + $new_question->set_display_text(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->display_text())); |
|
445 | + $new_question->set_admin_label(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->admin_label())); |
|
446 | + $new_question->set_system_ID(null); |
|
447 | + $new_question->set_wp_user(get_current_user_id()); |
|
448 | 448 | //if we're duplicating a trashed question, assume we don't want the new one to be trashed |
449 | - $new_question->set_deleted( false ); |
|
449 | + $new_question->set_deleted(false); |
|
450 | 450 | $success = $new_question->save(); |
451 | - if( $success ) { |
|
451 | + if ($success) { |
|
452 | 452 | //we don't totally want to duplicate the question options, because we want them to be for the NEW question |
453 | - foreach( $this->options() as $question_option ) { |
|
454 | - $question_option->duplicate( array( 'QST_ID' => $new_question->ID() ) ); |
|
453 | + foreach ($this->options() as $question_option) { |
|
454 | + $question_option->duplicate(array('QST_ID' => $new_question->ID())); |
|
455 | 455 | } |
456 | 456 | return $new_question; |
457 | 457 | } else { |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | * @return int|float |
465 | 465 | */ |
466 | 466 | public function max() { |
467 | - return $this->get( 'QST_max' ); |
|
467 | + return $this->get('QST_max'); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | * @param int|float $new_max |
473 | 473 | * @return int|float |
474 | 474 | */ |
475 | - public function set_max( $new_max ) { |
|
476 | - return $this->set( 'QST_max', $new_max ); |
|
475 | + public function set_max($new_max) { |
|
476 | + return $this->set('QST_max', $new_max); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 |
@@ -445,8 +445,8 @@ |
||
445 | 445 | $new_question->set_admin_label( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->admin_label() ) ); |
446 | 446 | $new_question->set_system_ID( null ); |
447 | 447 | $new_question->set_wp_user( get_current_user_id() ); |
448 | - //if we're duplicating a trashed question, assume we don't want the new one to be trashed |
|
449 | - $new_question->set_deleted( false ); |
|
448 | + //if we're duplicating a trashed question, assume we don't want the new one to be trashed |
|
449 | + $new_question->set_deleted( false ); |
|
450 | 450 | $success = $new_question->save(); |
451 | 451 | if( $success ) { |
452 | 452 | //we don't totally want to duplicate the question options, because we want them to be for the NEW question |
@@ -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 | } |
@@ -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; |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * |
4 | 6 | * Class EE_Payment_Method_Manager |
@@ -144,7 +146,7 @@ discard block |
||
144 | 146 | if(isset($this->_payment_method_types[$payment_method_name])){ |
145 | 147 | require_once($this->_payment_method_types[$payment_method_name]); |
146 | 148 | return true; |
147 | - }else{ |
|
149 | + } else{ |
|
148 | 150 | return false; |
149 | 151 | } |
150 | 152 | } |
@@ -164,7 +166,7 @@ discard block |
||
164 | 166 | $payment_methods[] = $this->payment_method_class_from_type($classname); |
165 | 167 | } |
166 | 168 | return $payment_methods; |
167 | - }else{ |
|
169 | + } else{ |
|
168 | 170 | return array_keys($this->_payment_method_types); |
169 | 171 | } |
170 | 172 | } |
@@ -21,26 +21,26 @@ |
||
21 | 21 | * @since $VID:$ |
22 | 22 | * |
23 | 23 | */ |
24 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
24 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
25 | 25 | exit('No direct script access allowed'); |
26 | 26 | } |
27 | 27 | |
28 | -class EEM_Extra_Join extends EEM_Base{ |
|
28 | +class EEM_Extra_Join extends EEM_Base { |
|
29 | 29 | // private instance of the Extra Join object |
30 | 30 | protected static $_instance = NULL; |
31 | 31 | |
32 | 32 | public function __construct($timezone = NULL) { |
33 | - $models_this_can_join = array_keys( EE_Registry::instance()->non_abstract_db_models ); |
|
33 | + $models_this_can_join = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
34 | 34 | $this->_tables = array( |
35 | - 'Extra_Join' => new EE_Primary_Table( 'esp_extra_join', 'EXJ_ID' ), |
|
35 | + 'Extra_Join' => new EE_Primary_Table('esp_extra_join', 'EXJ_ID'), |
|
36 | 36 | ); |
37 | 37 | $this->_fields = array( |
38 | 38 | 'Extra_Join' => array( |
39 | - 'EXJ_ID' => new EE_Primary_Key_Int_Field( 'EXJ_ID', __( 'Extra Join ID', 'event_espresso' ) ), |
|
40 | - 'EXJ_first_model_ID' => new EE_Foreign_Key_String_Field( 'EXJ_first_model_ID', __( 'First Model ID', 'event_espresso' ), true, 0, $models_this_can_join ), |
|
41 | - 'EXJ_first_model_name' => new EE_Any_Foreign_Model_Name_Field( 'EXJ_first_model_name', __( 'First Model Name', 'event_espresso'), true, '', $models_this_can_join ), |
|
42 | - 'EXJ_second_model_ID' => new EE_Foreign_Key_String_Field( 'EXJ_second_model_ID', __( 'Second Model ID', 'event_espresso' ), true, 0, $models_this_can_join ), |
|
43 | - 'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field( 'EXJ_second_model_name', __( 'Second Model Name', 'event_espresso'), true, '', $models_this_can_join ), |
|
39 | + 'EXJ_ID' => new EE_Primary_Key_Int_Field('EXJ_ID', __('Extra Join ID', 'event_espresso')), |
|
40 | + 'EXJ_first_model_ID' => new EE_Foreign_Key_String_Field('EXJ_first_model_ID', __('First Model ID', 'event_espresso'), true, 0, $models_this_can_join), |
|
41 | + 'EXJ_first_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_first_model_name', __('First Model Name', 'event_espresso'), true, '', $models_this_can_join), |
|
42 | + 'EXJ_second_model_ID' => new EE_Foreign_Key_String_Field('EXJ_second_model_ID', __('Second Model ID', 'event_espresso'), true, 0, $models_this_can_join), |
|
43 | + 'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field('EXJ_second_model_name', __('Second Model Name', 'event_espresso'), true, '', $models_this_can_join), |
|
44 | 44 | |
45 | 45 | ) |
46 | 46 | ); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | <tbody> |
22 | 22 | <tr> |
23 | 23 | <th> |
24 | - <label for="QST_display_text"><?php echo $fields['QST_display_text']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_text_info');?> |
|
24 | + <label for="QST_display_text"><?php echo $fields['QST_display_text']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_text_info'); ?> |
|
25 | 25 | </th> |
26 | 26 | <td> |
27 | 27 | <input type="text" class="regular-text" id="QST_display_text" name="QST_display_text" value="<?php $question->f('QST_display_text')?>"/> |
@@ -31,23 +31,23 @@ discard block |
||
31 | 31 | |
32 | 32 | <tr> |
33 | 33 | <th> |
34 | - <label for="QST_admin_label"><?php echo $fields['QST_admin_label']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_label_info');?> |
|
34 | + <label for="QST_admin_label"><?php echo $fields['QST_admin_label']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_label_info'); ?> |
|
35 | 35 | </th> |
36 | 36 | <td> |
37 | 37 | <?php |
38 | - $disabled = ! empty( $QST_system ) ? ' disabled="disabled"' : ''; |
|
39 | - $id = ! empty( $QST_system ) ? '_disabled' : ''; |
|
38 | + $disabled = ! empty($QST_system) ? ' disabled="disabled"' : ''; |
|
39 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
40 | 40 | ?> |
41 | 41 | <input type="text" class="regular-text" id="QST_admin_label<?php echo $id?>" name="QST_admin_label<?php echo $id?>" value="<?php $question->f('QST_admin_label')?>"<?php echo $disabled?>/> |
42 | 42 | <input class="QST_order" type="hidden" id="QST_order<?php echo $id; ?>" name = "QST_order<?php echo $id; ?>" value="<?php echo $question->get('QST_order'); ?>" /> |
43 | - <?php if ( ! empty( $QST_system )) { ?> |
|
43 | + <?php if ( ! empty($QST_system)) { ?> |
|
44 | 44 | <input type="hidden" id="QST_admin_label" name="QST_admin_label" value="<?php echo $question->admin_label()?>"/> |
45 | 45 | <?php } ?> |
46 | 46 | <br/> |
47 | 47 | <p class="description"> |
48 | - <?php if ( ! empty( $QST_system )) { ?> |
|
48 | + <?php if ( ! empty($QST_system)) { ?> |
|
49 | 49 | <span class="description" style="color:#D54E21;"> |
50 | - <?php _e('System question! This field cannot be changed.','event_espresso')?> |
|
50 | + <?php _e('System question! This field cannot be changed.', 'event_espresso')?> |
|
51 | 51 | </span> |
52 | 52 | <?php } ?> |
53 | 53 | |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | |
58 | 58 | <tr> |
59 | 59 | <th> |
60 | - <label for="QST_admin_only"><?php echo $fields['QST_admin_only']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_admin_only_info');?> |
|
60 | + <label for="QST_admin_only"><?php echo $fields['QST_admin_only']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_admin_only_info'); ?> |
|
61 | 61 | </th> |
62 | 62 | <td> |
63 | 63 | <?php |
64 | - $disabled = ! empty( $QST_system ) ? ' disabled="disabled"' : ''; |
|
65 | - $id = ! empty( $QST_system ) ? '_disabled' : ''; |
|
64 | + $disabled = ! empty($QST_system) ? ' disabled="disabled"' : ''; |
|
65 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
66 | 66 | $admin_only = $question->get('QST_admin_only'); |
67 | - $checked = !empty( $admin_only ) ? ' checked="checked"' : ''; |
|
67 | + $checked = ! empty($admin_only) ? ' checked="checked"' : ''; |
|
68 | 68 | ?> |
69 | 69 | <input class="QST_admin_only" type="checkbox" id="QST_admin_only<?php echo $id; ?>" name = "QST_admin_only<?php echo $id; ?>" value="1"<?php echo $disabled; echo $checked; ?>/> |
70 | 70 | <br/> |
71 | 71 | <p class="description"> |
72 | - <?php if ( ! empty( $QST_system )) { ?> |
|
72 | + <?php if ( ! empty($QST_system)) { ?> |
|
73 | 73 | <span class="description" style="color:#D54E21;"> |
74 | - <?php _e('System question! This field cannot be changed.','event_espresso')?> |
|
74 | + <?php _e('System question! This field cannot be changed.', 'event_espresso')?> |
|
75 | 75 | </span> |
76 | 76 | <?php } ?> |
77 | 77 | |
@@ -81,21 +81,21 @@ discard block |
||
81 | 81 | |
82 | 82 | <tr> |
83 | 83 | <th> |
84 | - <label for="QST_type"><?php echo $fields['QST_type']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_type_info');?> |
|
84 | + <label for="QST_type"><?php echo $fields['QST_type']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_type_info'); ?> |
|
85 | 85 | </th> |
86 | 86 | <td> |
87 | 87 | <?php |
88 | - $disabled = ! empty( $QST_system ) ? ' disabled="disabled"' : ''; |
|
89 | - $id = ! empty( $QST_system ) ? '_disabled' : ''; |
|
90 | - echo EEH_Form_Fields::select_input( 'QST_type' . $id, $question_types, $question->type(), 'id="QST_type' . $id . '"' . $disabled ); |
|
91 | - if( ! empty( $QST_system ) ) { ?> |
|
88 | + $disabled = ! empty($QST_system) ? ' disabled="disabled"' : ''; |
|
89 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
90 | + echo EEH_Form_Fields::select_input('QST_type'.$id, $question_types, $question->type(), 'id="QST_type'.$id.'"'.$disabled); |
|
91 | + if ( ! empty($QST_system)) { ?> |
|
92 | 92 | <input type="hidden" id="QST_type" name="QST_type" value="<?php echo $question->type()?>"/> |
93 | 93 | <?php |
94 | - $explanatory_text = __('System question! This field cannot be changed.','event_espresso'); |
|
95 | - }else{ |
|
96 | - $explanatory_text = __('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.','event_espresso'); |
|
94 | + $explanatory_text = __('System question! This field cannot be changed.', 'event_espresso'); |
|
95 | + } else { |
|
96 | + $explanatory_text = __('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.', 'event_espresso'); |
|
97 | 97 | } |
98 | - if ( ! empty( $QST_system ) || $has_answers ) { ?> |
|
98 | + if ( ! empty($QST_system) || $has_answers) { ?> |
|
99 | 99 | <p><span class="description" style="color:#D54E21;"> |
100 | 100 | <?php echo $explanatory_text; ?> |
101 | 101 | </span></p> |
@@ -108,22 +108,22 @@ discard block |
||
108 | 108 | <tr id="text_input_question_options"> |
109 | 109 | <th> |
110 | 110 | <label> |
111 | - <?php _e( 'Maximum Allowed Response Size', 'event_espresso' );?> |
|
111 | + <?php _e('Maximum Allowed Response Size', 'event_espresso'); ?> |
|
112 | 112 | </label> |
113 | 113 | </th> |
114 | 114 | <td> |
115 | - <input id="QST_max" name="QST_max" type="number" <?php echo $max_max == EE_INF ? '' : "max='$max_max'";?> value="<?php $question->f( 'QST_max' );?>" min="1"> |
|
115 | + <input id="QST_max" name="QST_max" type="number" <?php echo $max_max == EE_INF ? '' : "max='$max_max'"; ?> value="<?php $question->f('QST_max'); ?>" min="1"> |
|
116 | 116 | <p> |
117 | 117 | <span class="description"> |
118 | - <?php _e( 'Maximum number of characters allowed when answering this question', 'event_espresso' );?> |
|
118 | + <?php _e('Maximum number of characters allowed when answering this question', 'event_espresso'); ?> |
|
119 | 119 | </span> |
120 | 120 | </p> |
121 | - <?php if ( $QST_system ) { ?> |
|
121 | + <?php if ($QST_system) { ?> |
|
122 | 122 | <p> |
123 | 123 | <span class="description" style="color:#D54E21;"> |
124 | 124 | <?php printf( |
125 | - __( 'System question! The maximum number of characters that can be used for this question is %1$s', 'event_espresso' ), |
|
126 | - $max_max );?> |
|
125 | + __('System question! The maximum number of characters that can be used for this question is %1$s', 'event_espresso'), |
|
126 | + $max_max ); ?> |
|
127 | 127 | </span> |
128 | 128 | </p> |
129 | 129 | <?php } ?> |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | <tr id="question_options"> |
133 | 133 | <th> |
134 | 134 | <label> |
135 | - <?php _e('Answer Options','event_espresso')?> |
|
135 | + <?php _e('Answer Options', 'event_espresso')?> |
|
136 | 136 | </label> |
137 | 137 | </th> |
138 | 138 | <td> |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | <thead> |
142 | 142 | <tr> |
143 | 143 | <th class="option-value-header"> |
144 | - <?php _e('Value','event_espresso')?> |
|
144 | + <?php _e('Value', 'event_espresso')?> |
|
145 | 145 | </th> |
146 | 146 | <th class="option-desc-header"> |
147 | - <?php _e('Description (optional, only shown on registration form)','event_espresso')?> |
|
147 | + <?php _e('Description (optional, only shown on registration form)', 'event_espresso')?> |
|
148 | 148 | </th> |
149 | 149 | <th> |
150 | 150 | </th> |
@@ -167,17 +167,17 @@ discard block |
||
167 | 167 | </tr> |
168 | 168 | |
169 | 169 | <?php |
170 | - $count=0; |
|
170 | + $count = 0; |
|
171 | 171 | $question_options = $question->options(); |
172 | - if ( ! empty( $question_options )) { |
|
173 | - foreach( $question_options as $option_id => $option ) { |
|
174 | - $disabled = $has_answers || $option->get('QSO_system') ? ' disabled="disabled"' : ''; |
|
172 | + if ( ! empty($question_options)) { |
|
173 | + foreach ($question_options as $option_id => $option) { |
|
174 | + $disabled = $has_answers || $option->get('QSO_system') ? ' disabled="disabled"' : ''; |
|
175 | 175 | ?> |
176 | 176 | <tr class="question-option ee-options-sortable"> |
177 | 177 | <td class="option-value-cell"> |
178 | 178 | <input type="hidden" class="QSO_order" name="question_options[<?php echo $count; ?>][QSO_order]" value="<?php echo $count; ?>"> |
179 | 179 | <input type="text" class="option-value regular-text" name="question_options[<?php echo $count?>][QSO_value]" value="<?php $option->f('QSO_value')?>"<?php echo $disabled; ?>> |
180 | - <?php if ( $has_answers ) : ?> |
|
180 | + <?php if ($has_answers) : ?> |
|
181 | 181 | <input type="hidden" name="question_options[<?php echo $count; ?>][QSO_value]" value="<?php echo $option->f('QSO_value'); ?>" > |
182 | 182 | <?php endif; ?> |
183 | 183 | </td> |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | <input type="text" class="option-desc regular-text" name="question_options[<?php echo $count?>][QSO_desc]" value="<?php $option->f('QSO_desc')?>"> |
186 | 186 | </td> |
187 | 187 | <td> |
188 | - <?php if ( ! $option->system() ) { ?> |
|
188 | + <?php if ( ! $option->system()) { ?> |
|
189 | 189 | <span class="dashicons clickable dashicons-post-trash ee-icon-size-18 remove-option remove-item"></span> |
190 | 190 | <?php } ?> |
191 | 191 | <span class="dashicons dashicons-image-flip-vertical sortable-drag-handle ee-icon-size-18"></span> |
@@ -224,13 +224,13 @@ discard block |
||
224 | 224 | </table> |
225 | 225 | |
226 | 226 | <a id="new-question-option" class="button" style="margin:0 0 1em 3px;"> |
227 | - <?php _e('Add Another Answer Option','event_espresso')?> |
|
227 | + <?php _e('Add Another Answer Option', 'event_espresso')?> |
|
228 | 228 | </a><br/> |
229 | 229 | |
230 | 230 | <p class="description"> |
231 | - <?php _e('Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.','event_espresso')?> |
|
231 | + <?php _e('Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.', 'event_espresso')?> |
|
232 | 232 | </p> |
233 | - <?php if ( $has_answers ) : ?> |
|
233 | + <?php if ($has_answers) : ?> |
|
234 | 234 | <p class="description" style="color:#D54E21;"> |
235 | 235 | <?php _e('Answer values that are uneditable are this way because there are registrations in the database that have answers for this question. If you need to correct a mistake, or edit an existing option value, then trash the existing one and create a new option with the changes. This will ensure that the existing registrations that chose the original answer will preserve that answer.', 'event_espresso'); ?> |
236 | 236 | </p> |
@@ -241,32 +241,32 @@ discard block |
||
241 | 241 | |
242 | 242 | <tr> |
243 | 243 | <th> |
244 | - <label for="QST_required"><?php echo $fields['QST_required']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('required_question_info');?> |
|
244 | + <label for="QST_required"><?php echo $fields['QST_required']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('required_question_info'); ?> |
|
245 | 245 | </th> |
246 | 246 | <td> |
247 | 247 | <?php |
248 | - $system_required = array( 'fname', 'email' ); |
|
249 | - $disabled = in_array( $QST_system, $system_required ) ? ' disabled="disabled"' : ''; |
|
248 | + $system_required = array('fname', 'email'); |
|
249 | + $disabled = in_array($QST_system, $system_required) ? ' disabled="disabled"' : ''; |
|
250 | 250 | $required_on = $question->get('QST_admin_only'); |
251 | 251 | $show_required_msg = $required_on ? '' : ' display:none;'; |
252 | - $disabled = $required_on || ! empty( $disabled ) ? ' disabled="disabled"' : ''; |
|
253 | - $id = ! empty( $disabled ) && in_array( $QST_system, $system_required) ? '_disabled' : ''; |
|
254 | - $requiredOptions=array( |
|
255 | - array('text'=>'Optional','id'=>0), |
|
256 | - array('text'=>'Required','id'=>1) |
|
252 | + $disabled = $required_on || ! empty($disabled) ? ' disabled="disabled"' : ''; |
|
253 | + $id = ! empty($disabled) && in_array($QST_system, $system_required) ? '_disabled' : ''; |
|
254 | + $requiredOptions = array( |
|
255 | + array('text'=>'Optional', 'id'=>0), |
|
256 | + array('text'=>'Required', 'id'=>1) |
|
257 | 257 | ); |
258 | - echo EEH_Form_Fields::select_input('QST_required' . $id, $requiredOptions, $question->required(), 'id="QST_required' . $id . '"' . $disabled ); |
|
258 | + echo EEH_Form_Fields::select_input('QST_required'.$id, $requiredOptions, $question->required(), 'id="QST_required'.$id.'"'.$disabled); |
|
259 | 259 | ?> |
260 | 260 | <p><span id="required_toggled_on" class="description" style="color:#D54E21;<?php echo $show_required_msg; ?>"> |
261 | - <?php _e('Required is set to optional, and this field is disabled, because the question is Admin-Only.','event_espresso')?> |
|
261 | + <?php _e('Required is set to optional, and this field is disabled, because the question is Admin-Only.', 'event_espresso')?> |
|
262 | 262 | </span></p> |
263 | 263 | <p><span id="required_toggled_off" class="description" style="color:#D54E21; display: none;"> |
264 | - <?php _e('Required option field is no longer disabled because the question is not Admin-Only','event_espresso')?> |
|
264 | + <?php _e('Required option field is no longer disabled because the question is not Admin-Only', 'event_espresso')?> |
|
265 | 265 | </span></p> |
266 | - <?php if ( ! empty( $disabled ) && in_array( $QST_system, $system_required ) ) { ?> |
|
266 | + <?php if ( ! empty($disabled) && in_array($QST_system, $system_required)) { ?> |
|
267 | 267 | <input type="hidden" id="QST_required" name="QST_required" value="1"/> |
268 | 268 | <p><span class="description" style="color:#D54E21;"> |
269 | - <?php _e('System question! This field cannot be changed.','event_espresso')?> |
|
269 | + <?php _e('System question! This field cannot be changed.', 'event_espresso')?> |
|
270 | 270 | </span></p> |
271 | 271 | <?php } ?> |
272 | 272 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | <tr> |
277 | 277 | <th> |
278 | - <label for="QST_required_text"><?php _e('Required Text', 'event_espresso'); ?></label> <?php echo EEH_Template::get_help_tab_link('required_text_info');?> |
|
278 | + <label for="QST_required_text"><?php _e('Required Text', 'event_espresso'); ?></label> <?php echo EEH_Template::get_help_tab_link('required_text_info'); ?> |
|
279 | 279 | </th> |
280 | 280 | <td> |
281 | 281 | <input type="text" class="regular-text" id="QST_required_text" name="QST_required_text" value="<?php $question->f('QST_required_text')?>"/> |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once( EE_CLASSES . 'EE_Question.class.php'); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once(EE_CLASSES.'EE_Question.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Question extends EEM_Soft_Delete_Base { |
28 | 28 | |
@@ -69,21 +69,21 @@ discard block |
||
69 | 69 | // private instance of the Attendee object |
70 | 70 | protected static $_instance = NULL; |
71 | 71 | |
72 | - protected function __construct( $timezone = NULL ) { |
|
73 | - $this->singular_item = __('Question','event_espresso'); |
|
74 | - $this->plural_item = __('Questions','event_espresso'); |
|
75 | - $this->_allowed_question_types=apply_filters( |
|
72 | + protected function __construct($timezone = NULL) { |
|
73 | + $this->singular_item = __('Question', 'event_espresso'); |
|
74 | + $this->plural_item = __('Questions', 'event_espresso'); |
|
75 | + $this->_allowed_question_types = apply_filters( |
|
76 | 76 | 'FHEE__EEM_Question__construct__allowed_question_types', |
77 | 77 | array( |
78 | - EEM_Question::QST_type_text =>__('Text','event_espresso'), |
|
79 | - EEM_Question::QST_type_textarea =>__('Textarea','event_espresso'), |
|
80 | - EEM_Question::QST_type_checkbox =>__('Checkboxes','event_espresso'), |
|
81 | - EEM_Question::QST_type_radio =>__('Radio Buttons','event_espresso'), |
|
82 | - EEM_Question::QST_type_dropdown =>__('Dropdown','event_espresso'), |
|
83 | - EEM_Question::QST_type_state =>__('State/Province Dropdown','event_espresso'), |
|
84 | - EEM_Question::QST_type_country =>__('Country Dropdown','event_espresso'), |
|
85 | - EEM_Question::QST_type_date =>__('Date Picker','event_espresso'), |
|
86 | - EEM_Question::QST_type_html_textarea => __( 'HTML Textarea', 'event_espresso' ), |
|
78 | + EEM_Question::QST_type_text =>__('Text', 'event_espresso'), |
|
79 | + EEM_Question::QST_type_textarea =>__('Textarea', 'event_espresso'), |
|
80 | + EEM_Question::QST_type_checkbox =>__('Checkboxes', 'event_espresso'), |
|
81 | + EEM_Question::QST_type_radio =>__('Radio Buttons', 'event_espresso'), |
|
82 | + EEM_Question::QST_type_dropdown =>__('Dropdown', 'event_espresso'), |
|
83 | + EEM_Question::QST_type_state =>__('State/Province Dropdown', 'event_espresso'), |
|
84 | + EEM_Question::QST_type_country =>__('Country Dropdown', 'event_espresso'), |
|
85 | + EEM_Question::QST_type_date =>__('Date Picker', 'event_espresso'), |
|
86 | + EEM_Question::QST_type_html_textarea => __('HTML Textarea', 'event_espresso'), |
|
87 | 87 | ) |
88 | 88 | ); |
89 | 89 | $this->_question_type_categories = apply_filters( |
@@ -102,22 +102,22 @@ discard block |
||
102 | 102 | ); |
103 | 103 | |
104 | 104 | $this->_tables = array( |
105 | - 'Question'=>new EE_Primary_Table('esp_question','QST_ID') |
|
105 | + 'Question'=>new EE_Primary_Table('esp_question', 'QST_ID') |
|
106 | 106 | ); |
107 | 107 | $this->_fields = array( |
108 | 108 | 'Question'=>array( |
109 | - 'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID','event_espresso')), |
|
110 | - 'QST_display_text'=>new EE_Full_HTML_Field('QST_display_text', __('Question Text','event_espresso'), true, ''), |
|
111 | - 'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)','event_espresso'), true, ''), |
|
112 | - 'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question','event_espresso'), TRUE, NULL ), |
|
113 | - 'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type','event_espresso'),false, 'TEXT',$this->_allowed_question_types), |
|
114 | - 'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?','event_espresso'), false, false), |
|
115 | - 'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided','event_espresso'), true, ''), |
|
116 | - 'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order','event_espresso'), false, 0), |
|
117 | - 'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?','event_espresso'), false, false), |
|
118 | - 'QST_max' => new EE_Infinite_Integer_Field( 'QST_max', __( 'Max Size', 'event_espresso' ), false, EE_INF ), |
|
119 | - 'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID','event_espresso'), false ), |
|
120 | - 'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted','event_espresso'), false, false) |
|
109 | + 'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso')), |
|
110 | + 'QST_display_text'=>new EE_Full_HTML_Field('QST_display_text', __('Question Text', 'event_espresso'), true, ''), |
|
111 | + 'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)', 'event_espresso'), true, ''), |
|
112 | + 'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question', 'event_espresso'), TRUE, NULL), |
|
113 | + 'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type', 'event_espresso'), false, 'TEXT', $this->_allowed_question_types), |
|
114 | + 'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?', 'event_espresso'), false, false), |
|
115 | + 'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided', 'event_espresso'), true, ''), |
|
116 | + 'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order', 'event_espresso'), false, 0), |
|
117 | + 'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?', 'event_espresso'), false, false), |
|
118 | + 'QST_max' => new EE_Infinite_Integer_Field('QST_max', __('Max Size', 'event_espresso'), false, EE_INF), |
|
119 | + 'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID', 'event_espresso'), false), |
|
120 | + 'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted', 'event_espresso'), false, false) |
|
121 | 121 | ) |
122 | 122 | ); |
123 | 123 | $this->_model_relations = array( |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | 'Question_Group_Question'=>new EE_Has_Many_Relation() |
130 | 130 | ); |
131 | 131 | //this model is generally available for reading |
132 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
133 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
134 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
135 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
136 | - parent::__construct( $timezone ); |
|
132 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
133 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
134 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
135 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
136 | + parent::__construct($timezone); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * but they can be extended |
142 | 142 | * @return string[] |
143 | 143 | */ |
144 | - public function allowed_question_types(){ |
|
144 | + public function allowed_question_types() { |
|
145 | 145 | return $this->_allowed_question_types; |
146 | 146 | } |
147 | 147 | /** |
@@ -149,16 +149,16 @@ discard block |
||
149 | 149 | * @param string $question_type one of EEM_Question::allowed_question_types( |
150 | 150 | * @return string[] like EEM_Question::allowed_question_types() |
151 | 151 | */ |
152 | - public function question_types_in_same_category( $question_type ) { |
|
153 | - $question_types = array( $question_type ); |
|
154 | - foreach( $this->_question_type_categories as $category => $question_types_in_category ) { |
|
155 | - if( in_array( $question_type, $question_types_in_category ) ) { |
|
152 | + public function question_types_in_same_category($question_type) { |
|
153 | + $question_types = array($question_type); |
|
154 | + foreach ($this->_question_type_categories as $category => $question_types_in_category) { |
|
155 | + if (in_array($question_type, $question_types_in_category)) { |
|
156 | 156 | $question_types = $question_types_in_category; |
157 | 157 | break; |
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | - return array_intersect_key( $this->allowed_question_types(), array_flip( $question_types ) ); |
|
161 | + return array_intersect_key($this->allowed_question_types(), array_flip($question_types)); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | * @param string $category one of the top-level keys of EEM_Question::question_type_categories() |
168 | 168 | * @return boolean |
169 | 169 | */ |
170 | - public function question_type_is_in_category( $question_type, $category ) { |
|
171 | - if( ! isset( $this->_question_type_categories[ $category ] ) ) { |
|
170 | + public function question_type_is_in_category($question_type, $category) { |
|
171 | + if ( ! isset($this->_question_type_categories[$category])) { |
|
172 | 172 | return false; |
173 | 173 | } |
174 | - return in_array( $question_type, $this->_question_type_categories[ $category ] ); |
|
174 | + return in_array($question_type, $this->_question_type_categories[$category]); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | * @param string $system_question_group_id QSG_system |
189 | 189 | * @return array of system question names (QST_system) |
190 | 190 | */ |
191 | - public function allowed_system_questions_in_system_question_group( $system_question_group_id ) { |
|
191 | + public function allowed_system_questions_in_system_question_group($system_question_group_id) { |
|
192 | 192 | $question_system_ids = array(); |
193 | - switch( $system_question_group_id ) { |
|
193 | + switch ($system_question_group_id) { |
|
194 | 194 | case EEM_Question_Group::system_personal: |
195 | 195 | $question_system_ids = array( |
196 | 196 | EEM_Attendee::system_question_fname, |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | ); |
212 | 212 | break; |
213 | 213 | } |
214 | - return apply_filters( 'FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id ); |
|
214 | + return apply_filters('FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | * @param string $system_question_group_id QSG_system |
221 | 221 | * @return array of system question names (QST_system) |
222 | 222 | */ |
223 | - public function required_system_questions_in_system_question_group( $system_question_group_id ) { |
|
223 | + public function required_system_questions_in_system_question_group($system_question_group_id) { |
|
224 | 224 | $question_system_ids = null; |
225 | - switch( $system_question_group_id ) { |
|
225 | + switch ($system_question_group_id) { |
|
226 | 226 | case EEM_Question_Group::system_personal: |
227 | - $question_system_ids = array( |
|
227 | + $question_system_ids = array( |
|
228 | 228 | EEM_Attendee::system_question_fname, |
229 | 229 | EEM_Attendee::system_question_email, |
230 | 230 | ); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | default: |
233 | 233 | $question_system_ids = array(); |
234 | 234 | } |
235 | - return apply_filters( 'FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id ); |
|
235 | + return apply_filters('FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | * @param $QST_system |
244 | 244 | * @return int of QST_ID for the question that corresponds to that QST_system |
245 | 245 | */ |
246 | - public function get_Question_ID_from_system_string( $QST_system ){ |
|
247 | - return $this->get_var( array( array( 'QST_system' => $QST_system ) ) ); |
|
246 | + public function get_Question_ID_from_system_string($QST_system) { |
|
247 | + return $this->get_var(array(array('QST_system' => $QST_system))); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | */ |
257 | 257 | public function get_latest_question_order() { |
258 | 258 | $columns_to_select = array( |
259 | - 'max_order' => array("MAX(QST_order)","%d") |
|
259 | + 'max_order' => array("MAX(QST_order)", "%d") |
|
260 | 260 | ); |
261 | - $max = $this->_get_all_wpdb_results( array(), ARRAY_A, $columns_to_select ); |
|
261 | + $max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select); |
|
262 | 262 | return $max[0]['max_order']; |
263 | 263 | } |
264 | 264 | |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | * @param string $system_question_value |
289 | 289 | * @return int|float |
290 | 290 | */ |
291 | - public function absolute_max_for_system_question( $system_question_value ) { |
|
291 | + public function absolute_max_for_system_question($system_question_value) { |
|
292 | 292 | $maxes = $this->system_question_maxes(); |
293 | - if( isset( $maxes[ $system_question_value ] ) ) { |
|
294 | - return $maxes[ $system_question_value ]; |
|
293 | + if (isset($maxes[$system_question_value])) { |
|
294 | + return $maxes[$system_question_value]; |
|
295 | 295 | } else { |
296 | 296 | return EE_INF; |
297 | 297 | } |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |