@@ -30,7 +30,7 @@ |
||
30 | 30 | * @param array $props_n_values incoming values from the database |
31 | 31 | * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
32 | 32 | * the website will be used. |
33 | - * @return EE_Attendee |
|
33 | + * @return EE_Price |
|
34 | 34 | */ |
35 | 35 | public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
36 | 36 | { |
@@ -10,290 +10,290 @@ |
||
10 | 10 | class EE_Price extends EE_Soft_Delete_Base_Class |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * |
|
15 | - * @param array $props_n_values incoming values |
|
16 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
17 | - * used.) |
|
18 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
19 | - * date_format and the second value is the time format |
|
20 | - * @return EE_Attendee |
|
21 | - */ |
|
22 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
23 | - { |
|
24 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
25 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
26 | - } |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * @param array $props_n_values incoming values from the database |
|
31 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
32 | - * the website will be used. |
|
33 | - * @return EE_Attendee |
|
34 | - */ |
|
35 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
36 | - { |
|
37 | - return new self($props_n_values, true, $timezone); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * Set Price type ID |
|
43 | - * |
|
44 | - * @access public |
|
45 | - * @param int $PRT_ID |
|
46 | - */ |
|
47 | - public function set_type($PRT_ID = 0) |
|
48 | - { |
|
49 | - $this->set('PRT_ID', $PRT_ID); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * Set Price Amount |
|
55 | - * |
|
56 | - * @access public |
|
57 | - * @param float $PRC_amount |
|
58 | - */ |
|
59 | - public function set_amount($PRC_amount = 0.00) |
|
60 | - { |
|
61 | - $this->set('PRC_amount', $PRC_amount); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * Set Price Name |
|
67 | - * |
|
68 | - * @access public |
|
69 | - * @param string $PRC_name |
|
70 | - */ |
|
71 | - public function set_name($PRC_name = '') |
|
72 | - { |
|
73 | - $this->set('PRC_name', $PRC_name); |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * Set Price Description |
|
79 | - * |
|
80 | - * @access public |
|
81 | - * @param string $PRC_desc |
|
82 | - */ |
|
83 | - public function set_description($PRC_desc = '') |
|
84 | - { |
|
85 | - $this->Set('PRC_desc', $PRC_desc); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * set is_default |
|
91 | - * |
|
92 | - * @access public |
|
93 | - * @param bool $PRC_is_default |
|
94 | - */ |
|
95 | - public function set_is_default($PRC_is_default = false) |
|
96 | - { |
|
97 | - $this->set('PRC_is_default', $PRC_is_default); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * set deleted |
|
103 | - * |
|
104 | - * @access public |
|
105 | - * @param bool $PRC_deleted |
|
106 | - */ |
|
107 | - public function set_deleted($PRC_deleted = null) |
|
108 | - { |
|
109 | - $this->set('PRC_deleted', $PRC_deleted); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * get Price type |
|
115 | - * |
|
116 | - * @access public |
|
117 | - * @return int |
|
118 | - */ |
|
119 | - public function type() |
|
120 | - { |
|
121 | - return $this->get('PRT_ID'); |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * get Price Amount |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @return float |
|
130 | - */ |
|
131 | - public function amount() |
|
132 | - { |
|
133 | - return $this->get('PRC_amount'); |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * get Price Name |
|
139 | - * |
|
140 | - * @access public |
|
141 | - * @return string |
|
142 | - */ |
|
143 | - public function name() |
|
144 | - { |
|
145 | - return $this->get('PRC_name'); |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * get Price description |
|
151 | - * |
|
152 | - * @access public |
|
153 | - * @return string |
|
154 | - */ |
|
155 | - public function desc() |
|
156 | - { |
|
157 | - return $this->get('PRC_desc'); |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * get overrides |
|
163 | - * |
|
164 | - * @access public |
|
165 | - * @return int |
|
166 | - */ |
|
167 | - public function overrides() |
|
168 | - { |
|
169 | - return $this->get('PRC_overrides'); |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * get order |
|
175 | - * |
|
176 | - * @access public |
|
177 | - * @return int |
|
178 | - */ |
|
179 | - public function order() |
|
180 | - { |
|
181 | - return $this->get('PRC_order'); |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * get the author of the price |
|
187 | - * |
|
188 | - * @since 4.5.0 |
|
189 | - * |
|
190 | - * @return int |
|
191 | - */ |
|
192 | - public function wp_user() |
|
193 | - { |
|
194 | - return $this->get('PRC_wp_user'); |
|
195 | - } |
|
196 | - |
|
197 | - |
|
198 | - /** |
|
199 | - * get is_default |
|
200 | - * |
|
201 | - * @access public |
|
202 | - * @return bool |
|
203 | - */ |
|
204 | - public function is_default() |
|
205 | - { |
|
206 | - return $this->get('PRC_is_default'); |
|
207 | - } |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * get deleted |
|
212 | - * |
|
213 | - * @access public |
|
214 | - * @return bool |
|
215 | - */ |
|
216 | - public function deleted() |
|
217 | - { |
|
218 | - return $this->get('PRC_deleted'); |
|
219 | - } |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * @return bool |
|
224 | - */ |
|
225 | - public function parent() |
|
226 | - { |
|
227 | - return $this->get('PRC_parent'); |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - // some helper methods for getting info on the price_type for this price |
|
232 | - |
|
233 | - /** |
|
234 | - * return whether the price is a base price or not |
|
235 | - * |
|
236 | - * @return boolean |
|
237 | - */ |
|
238 | - public function is_base_price() |
|
239 | - { |
|
240 | - $price_type = $this->type_obj(); |
|
241 | - return $price_type->base_type() === 1; |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * |
|
247 | - * @return EE_Price_Type |
|
248 | - */ |
|
249 | - public function type_obj() |
|
250 | - { |
|
251 | - return $this->get_first_related('Price_Type'); |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * Simply indicates whether this price increases or decreases the total |
|
257 | - * |
|
258 | - * @return boolean true = discount, otherwise adds to the total |
|
259 | - */ |
|
260 | - public function is_discount() |
|
261 | - { |
|
262 | - $price_type = $this->type_obj(); |
|
263 | - return $price_type->is_discount(); |
|
264 | - } |
|
265 | - |
|
266 | - |
|
267 | - /** |
|
268 | - * whether the price is a percentage or not |
|
269 | - * |
|
270 | - * @return boolean |
|
271 | - */ |
|
272 | - public function is_percent() |
|
273 | - { |
|
274 | - $price_type = $this->type_obj(); |
|
275 | - return $price_type->get('PRT_is_percent'); |
|
276 | - } |
|
277 | - |
|
278 | - |
|
279 | - /** |
|
280 | - * return pretty price dependant on whether its a dollar or percent. |
|
281 | - * |
|
282 | - * @since 4.4.0 |
|
283 | - * |
|
284 | - * @return string |
|
285 | - */ |
|
286 | - public function pretty_price() |
|
287 | - { |
|
288 | - return ! $this->is_percent() ? $this->get_pretty('PRC_amount') : $this->get('PRC_amount') . '%'; |
|
289 | - } |
|
290 | - |
|
291 | - |
|
292 | - /** |
|
293 | - * @return mixed |
|
294 | - */ |
|
295 | - public function get_price_without_currency_symbol() |
|
296 | - { |
|
297 | - return str_replace(EE_Registry::instance()->CFG->currency->sign, '', $this->get_pretty('PRC_amount')); |
|
298 | - } |
|
13 | + /** |
|
14 | + * |
|
15 | + * @param array $props_n_values incoming values |
|
16 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
17 | + * used.) |
|
18 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
19 | + * date_format and the second value is the time format |
|
20 | + * @return EE_Attendee |
|
21 | + */ |
|
22 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
23 | + { |
|
24 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
25 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
26 | + } |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * @param array $props_n_values incoming values from the database |
|
31 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
32 | + * the website will be used. |
|
33 | + * @return EE_Attendee |
|
34 | + */ |
|
35 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
36 | + { |
|
37 | + return new self($props_n_values, true, $timezone); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * Set Price type ID |
|
43 | + * |
|
44 | + * @access public |
|
45 | + * @param int $PRT_ID |
|
46 | + */ |
|
47 | + public function set_type($PRT_ID = 0) |
|
48 | + { |
|
49 | + $this->set('PRT_ID', $PRT_ID); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * Set Price Amount |
|
55 | + * |
|
56 | + * @access public |
|
57 | + * @param float $PRC_amount |
|
58 | + */ |
|
59 | + public function set_amount($PRC_amount = 0.00) |
|
60 | + { |
|
61 | + $this->set('PRC_amount', $PRC_amount); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * Set Price Name |
|
67 | + * |
|
68 | + * @access public |
|
69 | + * @param string $PRC_name |
|
70 | + */ |
|
71 | + public function set_name($PRC_name = '') |
|
72 | + { |
|
73 | + $this->set('PRC_name', $PRC_name); |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * Set Price Description |
|
79 | + * |
|
80 | + * @access public |
|
81 | + * @param string $PRC_desc |
|
82 | + */ |
|
83 | + public function set_description($PRC_desc = '') |
|
84 | + { |
|
85 | + $this->Set('PRC_desc', $PRC_desc); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * set is_default |
|
91 | + * |
|
92 | + * @access public |
|
93 | + * @param bool $PRC_is_default |
|
94 | + */ |
|
95 | + public function set_is_default($PRC_is_default = false) |
|
96 | + { |
|
97 | + $this->set('PRC_is_default', $PRC_is_default); |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * set deleted |
|
103 | + * |
|
104 | + * @access public |
|
105 | + * @param bool $PRC_deleted |
|
106 | + */ |
|
107 | + public function set_deleted($PRC_deleted = null) |
|
108 | + { |
|
109 | + $this->set('PRC_deleted', $PRC_deleted); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * get Price type |
|
115 | + * |
|
116 | + * @access public |
|
117 | + * @return int |
|
118 | + */ |
|
119 | + public function type() |
|
120 | + { |
|
121 | + return $this->get('PRT_ID'); |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * get Price Amount |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @return float |
|
130 | + */ |
|
131 | + public function amount() |
|
132 | + { |
|
133 | + return $this->get('PRC_amount'); |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * get Price Name |
|
139 | + * |
|
140 | + * @access public |
|
141 | + * @return string |
|
142 | + */ |
|
143 | + public function name() |
|
144 | + { |
|
145 | + return $this->get('PRC_name'); |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * get Price description |
|
151 | + * |
|
152 | + * @access public |
|
153 | + * @return string |
|
154 | + */ |
|
155 | + public function desc() |
|
156 | + { |
|
157 | + return $this->get('PRC_desc'); |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * get overrides |
|
163 | + * |
|
164 | + * @access public |
|
165 | + * @return int |
|
166 | + */ |
|
167 | + public function overrides() |
|
168 | + { |
|
169 | + return $this->get('PRC_overrides'); |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * get order |
|
175 | + * |
|
176 | + * @access public |
|
177 | + * @return int |
|
178 | + */ |
|
179 | + public function order() |
|
180 | + { |
|
181 | + return $this->get('PRC_order'); |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * get the author of the price |
|
187 | + * |
|
188 | + * @since 4.5.0 |
|
189 | + * |
|
190 | + * @return int |
|
191 | + */ |
|
192 | + public function wp_user() |
|
193 | + { |
|
194 | + return $this->get('PRC_wp_user'); |
|
195 | + } |
|
196 | + |
|
197 | + |
|
198 | + /** |
|
199 | + * get is_default |
|
200 | + * |
|
201 | + * @access public |
|
202 | + * @return bool |
|
203 | + */ |
|
204 | + public function is_default() |
|
205 | + { |
|
206 | + return $this->get('PRC_is_default'); |
|
207 | + } |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * get deleted |
|
212 | + * |
|
213 | + * @access public |
|
214 | + * @return bool |
|
215 | + */ |
|
216 | + public function deleted() |
|
217 | + { |
|
218 | + return $this->get('PRC_deleted'); |
|
219 | + } |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * @return bool |
|
224 | + */ |
|
225 | + public function parent() |
|
226 | + { |
|
227 | + return $this->get('PRC_parent'); |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + // some helper methods for getting info on the price_type for this price |
|
232 | + |
|
233 | + /** |
|
234 | + * return whether the price is a base price or not |
|
235 | + * |
|
236 | + * @return boolean |
|
237 | + */ |
|
238 | + public function is_base_price() |
|
239 | + { |
|
240 | + $price_type = $this->type_obj(); |
|
241 | + return $price_type->base_type() === 1; |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * |
|
247 | + * @return EE_Price_Type |
|
248 | + */ |
|
249 | + public function type_obj() |
|
250 | + { |
|
251 | + return $this->get_first_related('Price_Type'); |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * Simply indicates whether this price increases or decreases the total |
|
257 | + * |
|
258 | + * @return boolean true = discount, otherwise adds to the total |
|
259 | + */ |
|
260 | + public function is_discount() |
|
261 | + { |
|
262 | + $price_type = $this->type_obj(); |
|
263 | + return $price_type->is_discount(); |
|
264 | + } |
|
265 | + |
|
266 | + |
|
267 | + /** |
|
268 | + * whether the price is a percentage or not |
|
269 | + * |
|
270 | + * @return boolean |
|
271 | + */ |
|
272 | + public function is_percent() |
|
273 | + { |
|
274 | + $price_type = $this->type_obj(); |
|
275 | + return $price_type->get('PRT_is_percent'); |
|
276 | + } |
|
277 | + |
|
278 | + |
|
279 | + /** |
|
280 | + * return pretty price dependant on whether its a dollar or percent. |
|
281 | + * |
|
282 | + * @since 4.4.0 |
|
283 | + * |
|
284 | + * @return string |
|
285 | + */ |
|
286 | + public function pretty_price() |
|
287 | + { |
|
288 | + return ! $this->is_percent() ? $this->get_pretty('PRC_amount') : $this->get('PRC_amount') . '%'; |
|
289 | + } |
|
290 | + |
|
291 | + |
|
292 | + /** |
|
293 | + * @return mixed |
|
294 | + */ |
|
295 | + public function get_price_without_currency_symbol() |
|
296 | + { |
|
297 | + return str_replace(EE_Registry::instance()->CFG->currency->sign, '', $this->get_pretty('PRC_amount')); |
|
298 | + } |
|
299 | 299 | } |
@@ -285,7 +285,7 @@ |
||
285 | 285 | */ |
286 | 286 | public function pretty_price() |
287 | 287 | { |
288 | - return ! $this->is_percent() ? $this->get_pretty('PRC_amount') : $this->get('PRC_amount') . '%'; |
|
288 | + return ! $this->is_percent() ? $this->get_pretty('PRC_amount') : $this->get('PRC_amount').'%'; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * Question, that relationship will be overwritten. |
372 | 372 | * |
373 | 373 | * @param EE_Question_Option $option |
374 | - * @return boolean success |
|
374 | + * @return EE_Base_Class success |
|
375 | 375 | */ |
376 | 376 | public function add_option(EE_Question_Option $option) |
377 | 377 | { |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | * Marks the option as deleted. |
397 | 397 | * |
398 | 398 | * @param EE_Question_Option $option |
399 | - * @return boolean success |
|
399 | + * @return EE_Base_Class success |
|
400 | 400 | */ |
401 | 401 | public function remove_option(EE_Question_Option $option) |
402 | 402 | { |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | */ |
336 | 336 | public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null) |
337 | 337 | { |
338 | - if (! $this->ID()) { |
|
338 | + if ( ! $this->ID()) { |
|
339 | 339 | return array(); |
340 | 340 | } |
341 | 341 | $query_params = array(); |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | ), |
510 | 510 | $input_constructor_args |
511 | 511 | ); |
512 | - if (! $answer instanceof EE_Answer && $registration instanceof EE_Registration) { |
|
512 | + if ( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration) { |
|
513 | 513 | $answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID()); |
514 | 514 | } |
515 | 515 | // has this question been answered ? |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | $this, |
648 | 648 | $input_constructor_args |
649 | 649 | ); |
650 | - if (! $default_input) { |
|
650 | + if ( ! $default_input) { |
|
651 | 651 | $default_input = new EE_Text_Input($input_constructor_args); |
652 | 652 | } |
653 | 653 | $result = $default_input; |
@@ -14,661 +14,661 @@ |
||
14 | 14 | class EE_Question extends EE_Soft_Delete_Base_Class implements EEI_Duplicatable |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * |
|
19 | - * @param array $props_n_values incoming values |
|
20 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
21 | - * used.) |
|
22 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
23 | - * date_format and the second value is the time format |
|
24 | - * @return EE_Question |
|
25 | - */ |
|
26 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
27 | - { |
|
28 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
29 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
30 | - } |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * @param array $props_n_values incoming values from the database |
|
35 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
36 | - * the website will be used. |
|
37 | - * @return EE_Question |
|
38 | - */ |
|
39 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
40 | - { |
|
41 | - return new self($props_n_values, true, $timezone); |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * Set Question display text |
|
47 | - * |
|
48 | - * @access public |
|
49 | - * @param string $QST_display_text |
|
50 | - */ |
|
51 | - public function set_display_text($QST_display_text = '') |
|
52 | - { |
|
53 | - $this->set('QST_display_text', $QST_display_text); |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * Set Question admin text |
|
59 | - * |
|
60 | - * @access public |
|
61 | - * @param string $QST_admin_label |
|
62 | - */ |
|
63 | - public function set_admin_label($QST_admin_label = '') |
|
64 | - { |
|
65 | - $this->set('QST_admin_label', $QST_admin_label); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * Set system name |
|
71 | - * |
|
72 | - * @access public |
|
73 | - * @param mixed $QST_system |
|
74 | - */ |
|
75 | - public function set_system_ID($QST_system = '') |
|
76 | - { |
|
77 | - $this->set('QST_system', $QST_system); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * Set question's type |
|
83 | - * |
|
84 | - * @access public |
|
85 | - * @param string $QST_type |
|
86 | - */ |
|
87 | - public function set_question_type($QST_type = '') |
|
88 | - { |
|
89 | - $this->set('QST_type', $QST_type); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * Sets whether this question must be answered when presented in a form |
|
95 | - * |
|
96 | - * @access public |
|
97 | - * @param bool $QST_required |
|
98 | - */ |
|
99 | - public function set_required($QST_required = false) |
|
100 | - { |
|
101 | - $this->set('QST_required', $QST_required); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * Set Question display text |
|
107 | - * |
|
108 | - * @access public |
|
109 | - * @param string $QST_required_text |
|
110 | - */ |
|
111 | - public function set_required_text($QST_required_text = '') |
|
112 | - { |
|
113 | - $this->set('QST_required_text', $QST_required_text); |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * Sets the order of this question when placed in a sequence of questions |
|
119 | - * |
|
120 | - * @access public |
|
121 | - * @param int $QST_order |
|
122 | - */ |
|
123 | - public function set_order($QST_order = 0) |
|
124 | - { |
|
125 | - $this->set('QST_order', $QST_order); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * Sets whether the question is admin-only |
|
131 | - * |
|
132 | - * @access public |
|
133 | - * @param bool $QST_admin_only |
|
134 | - */ |
|
135 | - public function set_admin_only($QST_admin_only = false) |
|
136 | - { |
|
137 | - $this->set('QST_admin_only', $QST_admin_only); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * Sets the wordpress user ID on the question |
|
143 | - * |
|
144 | - * @access public |
|
145 | - * @param int $QST_wp_user |
|
146 | - */ |
|
147 | - public function set_wp_user($QST_wp_user = 1) |
|
148 | - { |
|
149 | - $this->set('QST_wp_user', $QST_wp_user); |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * Sets whether the question has been deleted |
|
155 | - * (we use this boolean instead of actually |
|
156 | - * deleting it because when users delete this question |
|
157 | - * they really want to remove the question from future |
|
158 | - * forms, BUT keep their old answers which depend |
|
159 | - * on this record actually existing. |
|
160 | - * |
|
161 | - * @access public |
|
162 | - * @param bool $QST_deleted |
|
163 | - */ |
|
164 | - public function set_deleted($QST_deleted = false) |
|
165 | - { |
|
166 | - $this->set('QST_deleted', $QST_deleted); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * returns the text for displaying the question to users |
|
172 | - * |
|
173 | - * @access public |
|
174 | - * @return string |
|
175 | - */ |
|
176 | - public function display_text() |
|
177 | - { |
|
178 | - return $this->get('QST_display_text'); |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * returns the text for the administrative label |
|
184 | - * |
|
185 | - * @access public |
|
186 | - * @return string |
|
187 | - */ |
|
188 | - public function admin_label() |
|
189 | - { |
|
190 | - return $this->get('QST_admin_label'); |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - /** |
|
195 | - * returns the attendee column name for this question |
|
196 | - * |
|
197 | - * @access public |
|
198 | - * @return string |
|
199 | - */ |
|
200 | - public function system_ID() |
|
201 | - { |
|
202 | - return $this->get('QST_system'); |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - /** |
|
207 | - * returns either a string of 'text', 'textfield', etc. |
|
208 | - * |
|
209 | - * @access public |
|
210 | - * @return boolean |
|
211 | - */ |
|
212 | - public function required() |
|
213 | - { |
|
214 | - return $this->get('QST_required'); |
|
215 | - } |
|
216 | - |
|
217 | - |
|
218 | - /** |
|
219 | - * returns the text which should be displayed when a user |
|
220 | - * doesn't answer this question in a form |
|
221 | - * |
|
222 | - * @access public |
|
223 | - * @return string |
|
224 | - */ |
|
225 | - public function required_text() |
|
226 | - { |
|
227 | - return $this->get('QST_required_text'); |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * returns the type of this question |
|
233 | - * |
|
234 | - * @access public |
|
235 | - * @return string |
|
236 | - */ |
|
237 | - public function type() |
|
238 | - { |
|
239 | - return $this->get('QST_type'); |
|
240 | - } |
|
241 | - |
|
242 | - |
|
243 | - /** |
|
244 | - * returns an integer showing where this question should |
|
245 | - * be placed in a sequence of questions |
|
246 | - * |
|
247 | - * @access public |
|
248 | - * @return int |
|
249 | - */ |
|
250 | - public function order() |
|
251 | - { |
|
252 | - return $this->get('QST_order'); |
|
253 | - } |
|
254 | - |
|
255 | - |
|
256 | - /** |
|
257 | - * returns whether this question should only appears to admins, |
|
258 | - * or to everyone |
|
259 | - * |
|
260 | - * @access public |
|
261 | - * @return boolean |
|
262 | - */ |
|
263 | - public function admin_only() |
|
264 | - { |
|
265 | - return $this->get('QST_admin_only'); |
|
266 | - } |
|
267 | - |
|
268 | - |
|
269 | - /** |
|
270 | - * returns the id the wordpress user who created this question |
|
271 | - * |
|
272 | - * @access public |
|
273 | - * @return int |
|
274 | - */ |
|
275 | - public function wp_user() |
|
276 | - { |
|
277 | - return $this->get('QST_wp_user'); |
|
278 | - } |
|
279 | - |
|
280 | - |
|
281 | - /** |
|
282 | - * returns whether this question has been marked as 'deleted' |
|
283 | - * |
|
284 | - * @access public |
|
285 | - * @return boolean |
|
286 | - */ |
|
287 | - public function deleted() |
|
288 | - { |
|
289 | - return $this->get('QST_deleted'); |
|
290 | - } |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * Gets an array of related EE_Answer to this EE_Question |
|
295 | - * |
|
296 | - * @return EE_Answer[] |
|
297 | - */ |
|
298 | - public function answers() |
|
299 | - { |
|
300 | - return $this->get_many_related('Answer'); |
|
301 | - } |
|
302 | - |
|
303 | - |
|
304 | - /** |
|
305 | - * Boolean check for if there are answers on this question in th db |
|
306 | - * |
|
307 | - * @return boolean true = has answers, false = no answers. |
|
308 | - */ |
|
309 | - public function has_answers() |
|
310 | - { |
|
311 | - return $this->count_related('Answer') > 0 ? true : false; |
|
312 | - } |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * gets an array of EE_Question_Group which relate to this question |
|
317 | - * |
|
318 | - * @return EE_Question_Group[] |
|
319 | - */ |
|
320 | - public function question_groups() |
|
321 | - { |
|
322 | - return $this->get_many_related('Question_Group'); |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * Returns all the options for this question. By default, it returns only the not-yet-deleted ones. |
|
328 | - * |
|
329 | - * @param boolean $notDeletedOptionsOnly 1 |
|
330 | - * whether to return ALL options, or only the ones which have |
|
331 | - * not yet been deleleted |
|
332 | - * @param string|array $selected_value_to_always_include , when retrieving options to an ANSWERED question, |
|
333 | - * we want to usually only show non-deleted options AND the |
|
334 | - * value that was selected for the answer, whether it was |
|
335 | - * trashed or not. |
|
336 | - * @return EE_Question_Option[] |
|
337 | - */ |
|
338 | - public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null) |
|
339 | - { |
|
340 | - if (! $this->ID()) { |
|
341 | - return array(); |
|
342 | - } |
|
343 | - $query_params = array(); |
|
344 | - if ($selected_value_to_always_include) { |
|
345 | - if (is_array($selected_value_to_always_include)) { |
|
346 | - $query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include); |
|
347 | - } else { |
|
348 | - $query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include; |
|
349 | - } |
|
350 | - } |
|
351 | - if ($notDeletedOptionsOnly) { |
|
352 | - $query_params[0]['OR*options-query']['QSO_deleted'] = false; |
|
353 | - } |
|
354 | - // order by QSO_order |
|
355 | - $query_params['order_by'] = array('QSO_order' => 'ASC'); |
|
356 | - return $this->get_many_related('Question_Option', $query_params); |
|
357 | - } |
|
358 | - |
|
359 | - |
|
360 | - /** |
|
361 | - * returns an array of EE_Question_Options which relate to this question |
|
362 | - * |
|
363 | - * @return \EE_Question_Option[] |
|
364 | - */ |
|
365 | - public function temp_options() |
|
366 | - { |
|
367 | - return $this->_model_relations['Question_Option']; |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * Adds an option for this question. Note: if the option were previously associated with a different |
|
373 | - * Question, that relationship will be overwritten. |
|
374 | - * |
|
375 | - * @param EE_Question_Option $option |
|
376 | - * @return boolean success |
|
377 | - */ |
|
378 | - public function add_option(EE_Question_Option $option) |
|
379 | - { |
|
380 | - return $this->_add_relation_to($option, 'Question_Option'); |
|
381 | - } |
|
382 | - |
|
383 | - |
|
384 | - /** |
|
385 | - * Adds an option directly to this question without saving to the db |
|
386 | - * |
|
387 | - * @param EE_Question_Option $option |
|
388 | - * @return boolean success |
|
389 | - */ |
|
390 | - public function add_temp_option(EE_Question_Option $option) |
|
391 | - { |
|
392 | - $this->_model_relations['Question_Option'][] = $option; |
|
393 | - return true; |
|
394 | - } |
|
395 | - |
|
396 | - |
|
397 | - /** |
|
398 | - * Marks the option as deleted. |
|
399 | - * |
|
400 | - * @param EE_Question_Option $option |
|
401 | - * @return boolean success |
|
402 | - */ |
|
403 | - public function remove_option(EE_Question_Option $option) |
|
404 | - { |
|
405 | - return $this->_remove_relation_to($option, 'Question_Option'); |
|
406 | - } |
|
407 | - |
|
408 | - |
|
409 | - /** |
|
410 | - * @return bool |
|
411 | - */ |
|
412 | - public function is_system_question() |
|
413 | - { |
|
414 | - $system_ID = $this->get('QST_system'); |
|
415 | - return ! empty($system_ID) ? true : false; |
|
416 | - } |
|
417 | - |
|
418 | - |
|
419 | - /** |
|
420 | - * The purpose of this method is set the question order this question order to be the max out of all questions |
|
421 | - * |
|
422 | - * @access public |
|
423 | - * @return void |
|
424 | - */ |
|
425 | - public function set_order_to_latest() |
|
426 | - { |
|
427 | - $latest_order = $this->get_model()->get_latest_question_order(); |
|
428 | - $latest_order++; |
|
429 | - $this->set('QST_order', $latest_order); |
|
430 | - } |
|
431 | - |
|
432 | - |
|
433 | - /** |
|
434 | - * Retrieves the list of allowed question types from the model. |
|
435 | - * |
|
436 | - * @return string[] |
|
437 | - */ |
|
438 | - private function _allowed_question_types() |
|
439 | - { |
|
440 | - $questionModel = $this->get_model(); |
|
441 | - /* @var $questionModel EEM_Question */ |
|
442 | - return $questionModel->allowed_question_types(); |
|
443 | - } |
|
444 | - |
|
445 | - /** |
|
446 | - * Duplicates this question and its question options |
|
447 | - * |
|
448 | - * @return \EE_Question |
|
449 | - */ |
|
450 | - public function duplicate($options = array()) |
|
451 | - { |
|
452 | - $new_question = clone $this; |
|
453 | - $new_question->set('QST_ID', null); |
|
454 | - $new_question->set_display_text(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->display_text())); |
|
455 | - $new_question->set_admin_label(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->admin_label())); |
|
456 | - $new_question->set_system_ID(null); |
|
457 | - $new_question->set_wp_user(get_current_user_id()); |
|
458 | - // if we're duplicating a trashed question, assume we don't want the new one to be trashed |
|
459 | - $new_question->set_deleted(false); |
|
460 | - $success = $new_question->save(); |
|
461 | - if ($success) { |
|
462 | - // we don't totally want to duplicate the question options, because we want them to be for the NEW question |
|
463 | - foreach ($this->options() as $question_option) { |
|
464 | - $question_option->duplicate(array('QST_ID' => $new_question->ID())); |
|
465 | - } |
|
466 | - return $new_question; |
|
467 | - } else { |
|
468 | - return null; |
|
469 | - } |
|
470 | - } |
|
471 | - |
|
472 | - /** |
|
473 | - * Returns the question's maximum allowed response size |
|
474 | - * |
|
475 | - * @return int|float |
|
476 | - */ |
|
477 | - public function max() |
|
478 | - { |
|
479 | - return $this->get('QST_max'); |
|
480 | - } |
|
481 | - |
|
482 | - /** |
|
483 | - * Sets the question's maximum allowed response size |
|
484 | - * |
|
485 | - * @param int|float $new_max |
|
486 | - * @return void |
|
487 | - */ |
|
488 | - public function set_max($new_max) |
|
489 | - { |
|
490 | - $this->set('QST_max', $new_max); |
|
491 | - } |
|
492 | - |
|
493 | - |
|
494 | - /** |
|
495 | - * Creates a form input from this question which can be used in HTML forms |
|
496 | - * |
|
497 | - * @param EE_Registration $registration |
|
498 | - * @param EE_Answer $answer |
|
499 | - * @param array $input_constructor_args |
|
500 | - * @return EE_Form_Input_Base |
|
501 | - */ |
|
502 | - public function generate_form_input($registration = null, $answer = null, $input_constructor_args = array()) |
|
503 | - { |
|
504 | - $identifier = $this->is_system_question() ? $this->system_ID() : $this->ID(); |
|
505 | - |
|
506 | - $input_constructor_args = array_merge( |
|
507 | - array( |
|
508 | - 'required' => $this->required() ? true : false, |
|
509 | - 'html_label_text' => $this->display_text(), |
|
510 | - 'required_validation_error_message' => $this->required_text(), |
|
511 | - ), |
|
512 | - $input_constructor_args |
|
513 | - ); |
|
514 | - if (! $answer instanceof EE_Answer && $registration instanceof EE_Registration) { |
|
515 | - $answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID()); |
|
516 | - } |
|
517 | - // has this question been answered ? |
|
518 | - if ($answer instanceof EE_Answer |
|
519 | - && $answer->value() !== '' |
|
520 | - ) { |
|
521 | - // answer gets htmlspecialchars called on it, undo that please |
|
522 | - // because the form input's display strategy may call esc_attr too |
|
523 | - // which also does html special characters |
|
524 | - $values_with_html_special_chars = $answer->value(); |
|
525 | - if (is_array($values_with_html_special_chars)) { |
|
526 | - $default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars); |
|
527 | - } else { |
|
528 | - $default_value = htmlspecialchars_decode($values_with_html_special_chars); |
|
529 | - } |
|
530 | - $input_constructor_args['default'] = $default_value; |
|
531 | - } |
|
532 | - $max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID()); |
|
533 | - if (in_array( |
|
534 | - $this->type(), |
|
535 | - EEM_Question::instance()->questionTypesWithMaxLength(), |
|
536 | - true |
|
537 | - )) { |
|
538 | - $input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy( |
|
539 | - null, |
|
540 | - min($max_max_for_question, $this->max()) |
|
541 | - ); |
|
542 | - } |
|
543 | - $input_constructor_args = apply_filters( |
|
544 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args', |
|
545 | - $input_constructor_args, |
|
546 | - $registration, |
|
547 | - $this, |
|
548 | - $answer |
|
549 | - ); |
|
550 | - |
|
551 | - $result = null; |
|
552 | - switch ($this->type()) { |
|
553 | - // Text |
|
554 | - case EEM_Question::QST_type_text: |
|
555 | - $result = new EE_Text_Input($input_constructor_args); |
|
556 | - break; |
|
557 | - // Textarea |
|
558 | - case EEM_Question::QST_type_textarea: |
|
559 | - $result = new EE_Text_Area_Input($input_constructor_args); |
|
560 | - break; |
|
561 | - // Radio Buttons |
|
562 | - case EEM_Question::QST_type_radio: |
|
563 | - $result = new EE_Radio_Button_Input($this->options(), $input_constructor_args); |
|
564 | - break; |
|
565 | - // Dropdown |
|
566 | - case EEM_Question::QST_type_dropdown: |
|
567 | - $result = new EE_Select_Input($this->options(), $input_constructor_args); |
|
568 | - break; |
|
569 | - // State Dropdown |
|
570 | - case EEM_Question::QST_type_state: |
|
571 | - $state_options = apply_filters( |
|
572 | - 'FHEE__EE_Question__generate_form_input__state_options', |
|
573 | - null, |
|
574 | - $this, |
|
575 | - $registration, |
|
576 | - $answer |
|
577 | - ); |
|
578 | - $result = new EE_State_Select_Input($state_options, $input_constructor_args); |
|
579 | - break; |
|
580 | - // Country Dropdown |
|
581 | - case EEM_Question::QST_type_country: |
|
582 | - $country_options = apply_filters( |
|
583 | - 'FHEE__EE_Question__generate_form_input__country_options', |
|
584 | - null, |
|
585 | - $this, |
|
586 | - $registration, |
|
587 | - $answer |
|
588 | - ); |
|
589 | - $result = new EE_Country_Select_Input($country_options, $input_constructor_args); |
|
590 | - break; |
|
591 | - // Checkboxes |
|
592 | - case EEM_Question::QST_type_checkbox: |
|
593 | - $result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args); |
|
594 | - break; |
|
595 | - // Date |
|
596 | - case EEM_Question::QST_type_date: |
|
597 | - $result = new EE_Datepicker_Input($input_constructor_args); |
|
598 | - break; |
|
599 | - case EEM_Question::QST_type_html_textarea: |
|
600 | - $input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy(); |
|
601 | - $result = new EE_Text_Area_Input($input_constructor_args); |
|
602 | - $result->remove_validation_strategy('EE_Plaintext_Validation_Strategy'); |
|
603 | - break; |
|
604 | - case EEM_Question::QST_type_email: |
|
605 | - $result = new EE_Email_Input($input_constructor_args); |
|
606 | - break; |
|
607 | - case EEM_Question::QST_type_us_phone: |
|
608 | - $result = new EE_Phone_Input($input_constructor_args); |
|
609 | - break; |
|
610 | - case EEM_Question::QST_type_int: |
|
611 | - $result = new EE_Integer_Input($input_constructor_args); |
|
612 | - break; |
|
613 | - case EEM_Question::QST_type_decimal: |
|
614 | - $result = new EE_Float_Input($input_constructor_args); |
|
615 | - break; |
|
616 | - case EEM_Question::QST_type_url: |
|
617 | - $input_constructor_args['validation_strategies'][] = LoaderFactory::getLoader()->getNew('EE_URL_Validation_Strategy'); |
|
618 | - $result = new EE_Text_Input($input_constructor_args); |
|
619 | - break; |
|
620 | - case EEM_Question::QST_type_year: |
|
621 | - $result = new EE_Year_Input( |
|
622 | - $input_constructor_args, |
|
623 | - apply_filters( |
|
624 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', |
|
625 | - true, |
|
626 | - $this |
|
627 | - ), |
|
628 | - apply_filters( |
|
629 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', |
|
630 | - 100, |
|
631 | - $this |
|
632 | - ), |
|
633 | - apply_filters( |
|
634 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', |
|
635 | - 100, |
|
636 | - $this |
|
637 | - ) |
|
638 | - ); |
|
639 | - break; |
|
640 | - case EEM_Question::QST_type_multi_select: |
|
641 | - $result = new EE_Select_Multiple_Input($this->options(), $input_constructor_args); |
|
642 | - break; |
|
643 | - // fallback |
|
644 | - default: |
|
645 | - $default_input = apply_filters( |
|
646 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__default', |
|
647 | - null, |
|
648 | - $this->type(), |
|
649 | - $this, |
|
650 | - $input_constructor_args |
|
651 | - ); |
|
652 | - if (! $default_input) { |
|
653 | - $default_input = new EE_Text_Input($input_constructor_args); |
|
654 | - } |
|
655 | - $result = $default_input; |
|
656 | - } |
|
657 | - return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer); |
|
658 | - } |
|
659 | - |
|
660 | - |
|
661 | - /** |
|
662 | - * Returns whether or not this question type should have question option entries |
|
663 | - * |
|
664 | - * @return bool |
|
665 | - */ |
|
666 | - public function should_have_question_options() |
|
667 | - { |
|
668 | - return in_array( |
|
669 | - $this->type(), |
|
670 | - $this->_model->question_types_with_options(), |
|
671 | - true |
|
672 | - ); |
|
673 | - } |
|
17 | + /** |
|
18 | + * |
|
19 | + * @param array $props_n_values incoming values |
|
20 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
21 | + * used.) |
|
22 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
23 | + * date_format and the second value is the time format |
|
24 | + * @return EE_Question |
|
25 | + */ |
|
26 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
27 | + { |
|
28 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
29 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
30 | + } |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * @param array $props_n_values incoming values from the database |
|
35 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
36 | + * the website will be used. |
|
37 | + * @return EE_Question |
|
38 | + */ |
|
39 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
40 | + { |
|
41 | + return new self($props_n_values, true, $timezone); |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * Set Question display text |
|
47 | + * |
|
48 | + * @access public |
|
49 | + * @param string $QST_display_text |
|
50 | + */ |
|
51 | + public function set_display_text($QST_display_text = '') |
|
52 | + { |
|
53 | + $this->set('QST_display_text', $QST_display_text); |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * Set Question admin text |
|
59 | + * |
|
60 | + * @access public |
|
61 | + * @param string $QST_admin_label |
|
62 | + */ |
|
63 | + public function set_admin_label($QST_admin_label = '') |
|
64 | + { |
|
65 | + $this->set('QST_admin_label', $QST_admin_label); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * Set system name |
|
71 | + * |
|
72 | + * @access public |
|
73 | + * @param mixed $QST_system |
|
74 | + */ |
|
75 | + public function set_system_ID($QST_system = '') |
|
76 | + { |
|
77 | + $this->set('QST_system', $QST_system); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * Set question's type |
|
83 | + * |
|
84 | + * @access public |
|
85 | + * @param string $QST_type |
|
86 | + */ |
|
87 | + public function set_question_type($QST_type = '') |
|
88 | + { |
|
89 | + $this->set('QST_type', $QST_type); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * Sets whether this question must be answered when presented in a form |
|
95 | + * |
|
96 | + * @access public |
|
97 | + * @param bool $QST_required |
|
98 | + */ |
|
99 | + public function set_required($QST_required = false) |
|
100 | + { |
|
101 | + $this->set('QST_required', $QST_required); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * Set Question display text |
|
107 | + * |
|
108 | + * @access public |
|
109 | + * @param string $QST_required_text |
|
110 | + */ |
|
111 | + public function set_required_text($QST_required_text = '') |
|
112 | + { |
|
113 | + $this->set('QST_required_text', $QST_required_text); |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * Sets the order of this question when placed in a sequence of questions |
|
119 | + * |
|
120 | + * @access public |
|
121 | + * @param int $QST_order |
|
122 | + */ |
|
123 | + public function set_order($QST_order = 0) |
|
124 | + { |
|
125 | + $this->set('QST_order', $QST_order); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * Sets whether the question is admin-only |
|
131 | + * |
|
132 | + * @access public |
|
133 | + * @param bool $QST_admin_only |
|
134 | + */ |
|
135 | + public function set_admin_only($QST_admin_only = false) |
|
136 | + { |
|
137 | + $this->set('QST_admin_only', $QST_admin_only); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * Sets the wordpress user ID on the question |
|
143 | + * |
|
144 | + * @access public |
|
145 | + * @param int $QST_wp_user |
|
146 | + */ |
|
147 | + public function set_wp_user($QST_wp_user = 1) |
|
148 | + { |
|
149 | + $this->set('QST_wp_user', $QST_wp_user); |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * Sets whether the question has been deleted |
|
155 | + * (we use this boolean instead of actually |
|
156 | + * deleting it because when users delete this question |
|
157 | + * they really want to remove the question from future |
|
158 | + * forms, BUT keep their old answers which depend |
|
159 | + * on this record actually existing. |
|
160 | + * |
|
161 | + * @access public |
|
162 | + * @param bool $QST_deleted |
|
163 | + */ |
|
164 | + public function set_deleted($QST_deleted = false) |
|
165 | + { |
|
166 | + $this->set('QST_deleted', $QST_deleted); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * returns the text for displaying the question to users |
|
172 | + * |
|
173 | + * @access public |
|
174 | + * @return string |
|
175 | + */ |
|
176 | + public function display_text() |
|
177 | + { |
|
178 | + return $this->get('QST_display_text'); |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * returns the text for the administrative label |
|
184 | + * |
|
185 | + * @access public |
|
186 | + * @return string |
|
187 | + */ |
|
188 | + public function admin_label() |
|
189 | + { |
|
190 | + return $this->get('QST_admin_label'); |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + /** |
|
195 | + * returns the attendee column name for this question |
|
196 | + * |
|
197 | + * @access public |
|
198 | + * @return string |
|
199 | + */ |
|
200 | + public function system_ID() |
|
201 | + { |
|
202 | + return $this->get('QST_system'); |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + /** |
|
207 | + * returns either a string of 'text', 'textfield', etc. |
|
208 | + * |
|
209 | + * @access public |
|
210 | + * @return boolean |
|
211 | + */ |
|
212 | + public function required() |
|
213 | + { |
|
214 | + return $this->get('QST_required'); |
|
215 | + } |
|
216 | + |
|
217 | + |
|
218 | + /** |
|
219 | + * returns the text which should be displayed when a user |
|
220 | + * doesn't answer this question in a form |
|
221 | + * |
|
222 | + * @access public |
|
223 | + * @return string |
|
224 | + */ |
|
225 | + public function required_text() |
|
226 | + { |
|
227 | + return $this->get('QST_required_text'); |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * returns the type of this question |
|
233 | + * |
|
234 | + * @access public |
|
235 | + * @return string |
|
236 | + */ |
|
237 | + public function type() |
|
238 | + { |
|
239 | + return $this->get('QST_type'); |
|
240 | + } |
|
241 | + |
|
242 | + |
|
243 | + /** |
|
244 | + * returns an integer showing where this question should |
|
245 | + * be placed in a sequence of questions |
|
246 | + * |
|
247 | + * @access public |
|
248 | + * @return int |
|
249 | + */ |
|
250 | + public function order() |
|
251 | + { |
|
252 | + return $this->get('QST_order'); |
|
253 | + } |
|
254 | + |
|
255 | + |
|
256 | + /** |
|
257 | + * returns whether this question should only appears to admins, |
|
258 | + * or to everyone |
|
259 | + * |
|
260 | + * @access public |
|
261 | + * @return boolean |
|
262 | + */ |
|
263 | + public function admin_only() |
|
264 | + { |
|
265 | + return $this->get('QST_admin_only'); |
|
266 | + } |
|
267 | + |
|
268 | + |
|
269 | + /** |
|
270 | + * returns the id the wordpress user who created this question |
|
271 | + * |
|
272 | + * @access public |
|
273 | + * @return int |
|
274 | + */ |
|
275 | + public function wp_user() |
|
276 | + { |
|
277 | + return $this->get('QST_wp_user'); |
|
278 | + } |
|
279 | + |
|
280 | + |
|
281 | + /** |
|
282 | + * returns whether this question has been marked as 'deleted' |
|
283 | + * |
|
284 | + * @access public |
|
285 | + * @return boolean |
|
286 | + */ |
|
287 | + public function deleted() |
|
288 | + { |
|
289 | + return $this->get('QST_deleted'); |
|
290 | + } |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * Gets an array of related EE_Answer to this EE_Question |
|
295 | + * |
|
296 | + * @return EE_Answer[] |
|
297 | + */ |
|
298 | + public function answers() |
|
299 | + { |
|
300 | + return $this->get_many_related('Answer'); |
|
301 | + } |
|
302 | + |
|
303 | + |
|
304 | + /** |
|
305 | + * Boolean check for if there are answers on this question in th db |
|
306 | + * |
|
307 | + * @return boolean true = has answers, false = no answers. |
|
308 | + */ |
|
309 | + public function has_answers() |
|
310 | + { |
|
311 | + return $this->count_related('Answer') > 0 ? true : false; |
|
312 | + } |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * gets an array of EE_Question_Group which relate to this question |
|
317 | + * |
|
318 | + * @return EE_Question_Group[] |
|
319 | + */ |
|
320 | + public function question_groups() |
|
321 | + { |
|
322 | + return $this->get_many_related('Question_Group'); |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * Returns all the options for this question. By default, it returns only the not-yet-deleted ones. |
|
328 | + * |
|
329 | + * @param boolean $notDeletedOptionsOnly 1 |
|
330 | + * whether to return ALL options, or only the ones which have |
|
331 | + * not yet been deleleted |
|
332 | + * @param string|array $selected_value_to_always_include , when retrieving options to an ANSWERED question, |
|
333 | + * we want to usually only show non-deleted options AND the |
|
334 | + * value that was selected for the answer, whether it was |
|
335 | + * trashed or not. |
|
336 | + * @return EE_Question_Option[] |
|
337 | + */ |
|
338 | + public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null) |
|
339 | + { |
|
340 | + if (! $this->ID()) { |
|
341 | + return array(); |
|
342 | + } |
|
343 | + $query_params = array(); |
|
344 | + if ($selected_value_to_always_include) { |
|
345 | + if (is_array($selected_value_to_always_include)) { |
|
346 | + $query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include); |
|
347 | + } else { |
|
348 | + $query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include; |
|
349 | + } |
|
350 | + } |
|
351 | + if ($notDeletedOptionsOnly) { |
|
352 | + $query_params[0]['OR*options-query']['QSO_deleted'] = false; |
|
353 | + } |
|
354 | + // order by QSO_order |
|
355 | + $query_params['order_by'] = array('QSO_order' => 'ASC'); |
|
356 | + return $this->get_many_related('Question_Option', $query_params); |
|
357 | + } |
|
358 | + |
|
359 | + |
|
360 | + /** |
|
361 | + * returns an array of EE_Question_Options which relate to this question |
|
362 | + * |
|
363 | + * @return \EE_Question_Option[] |
|
364 | + */ |
|
365 | + public function temp_options() |
|
366 | + { |
|
367 | + return $this->_model_relations['Question_Option']; |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * Adds an option for this question. Note: if the option were previously associated with a different |
|
373 | + * Question, that relationship will be overwritten. |
|
374 | + * |
|
375 | + * @param EE_Question_Option $option |
|
376 | + * @return boolean success |
|
377 | + */ |
|
378 | + public function add_option(EE_Question_Option $option) |
|
379 | + { |
|
380 | + return $this->_add_relation_to($option, 'Question_Option'); |
|
381 | + } |
|
382 | + |
|
383 | + |
|
384 | + /** |
|
385 | + * Adds an option directly to this question without saving to the db |
|
386 | + * |
|
387 | + * @param EE_Question_Option $option |
|
388 | + * @return boolean success |
|
389 | + */ |
|
390 | + public function add_temp_option(EE_Question_Option $option) |
|
391 | + { |
|
392 | + $this->_model_relations['Question_Option'][] = $option; |
|
393 | + return true; |
|
394 | + } |
|
395 | + |
|
396 | + |
|
397 | + /** |
|
398 | + * Marks the option as deleted. |
|
399 | + * |
|
400 | + * @param EE_Question_Option $option |
|
401 | + * @return boolean success |
|
402 | + */ |
|
403 | + public function remove_option(EE_Question_Option $option) |
|
404 | + { |
|
405 | + return $this->_remove_relation_to($option, 'Question_Option'); |
|
406 | + } |
|
407 | + |
|
408 | + |
|
409 | + /** |
|
410 | + * @return bool |
|
411 | + */ |
|
412 | + public function is_system_question() |
|
413 | + { |
|
414 | + $system_ID = $this->get('QST_system'); |
|
415 | + return ! empty($system_ID) ? true : false; |
|
416 | + } |
|
417 | + |
|
418 | + |
|
419 | + /** |
|
420 | + * The purpose of this method is set the question order this question order to be the max out of all questions |
|
421 | + * |
|
422 | + * @access public |
|
423 | + * @return void |
|
424 | + */ |
|
425 | + public function set_order_to_latest() |
|
426 | + { |
|
427 | + $latest_order = $this->get_model()->get_latest_question_order(); |
|
428 | + $latest_order++; |
|
429 | + $this->set('QST_order', $latest_order); |
|
430 | + } |
|
431 | + |
|
432 | + |
|
433 | + /** |
|
434 | + * Retrieves the list of allowed question types from the model. |
|
435 | + * |
|
436 | + * @return string[] |
|
437 | + */ |
|
438 | + private function _allowed_question_types() |
|
439 | + { |
|
440 | + $questionModel = $this->get_model(); |
|
441 | + /* @var $questionModel EEM_Question */ |
|
442 | + return $questionModel->allowed_question_types(); |
|
443 | + } |
|
444 | + |
|
445 | + /** |
|
446 | + * Duplicates this question and its question options |
|
447 | + * |
|
448 | + * @return \EE_Question |
|
449 | + */ |
|
450 | + public function duplicate($options = array()) |
|
451 | + { |
|
452 | + $new_question = clone $this; |
|
453 | + $new_question->set('QST_ID', null); |
|
454 | + $new_question->set_display_text(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->display_text())); |
|
455 | + $new_question->set_admin_label(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->admin_label())); |
|
456 | + $new_question->set_system_ID(null); |
|
457 | + $new_question->set_wp_user(get_current_user_id()); |
|
458 | + // if we're duplicating a trashed question, assume we don't want the new one to be trashed |
|
459 | + $new_question->set_deleted(false); |
|
460 | + $success = $new_question->save(); |
|
461 | + if ($success) { |
|
462 | + // we don't totally want to duplicate the question options, because we want them to be for the NEW question |
|
463 | + foreach ($this->options() as $question_option) { |
|
464 | + $question_option->duplicate(array('QST_ID' => $new_question->ID())); |
|
465 | + } |
|
466 | + return $new_question; |
|
467 | + } else { |
|
468 | + return null; |
|
469 | + } |
|
470 | + } |
|
471 | + |
|
472 | + /** |
|
473 | + * Returns the question's maximum allowed response size |
|
474 | + * |
|
475 | + * @return int|float |
|
476 | + */ |
|
477 | + public function max() |
|
478 | + { |
|
479 | + return $this->get('QST_max'); |
|
480 | + } |
|
481 | + |
|
482 | + /** |
|
483 | + * Sets the question's maximum allowed response size |
|
484 | + * |
|
485 | + * @param int|float $new_max |
|
486 | + * @return void |
|
487 | + */ |
|
488 | + public function set_max($new_max) |
|
489 | + { |
|
490 | + $this->set('QST_max', $new_max); |
|
491 | + } |
|
492 | + |
|
493 | + |
|
494 | + /** |
|
495 | + * Creates a form input from this question which can be used in HTML forms |
|
496 | + * |
|
497 | + * @param EE_Registration $registration |
|
498 | + * @param EE_Answer $answer |
|
499 | + * @param array $input_constructor_args |
|
500 | + * @return EE_Form_Input_Base |
|
501 | + */ |
|
502 | + public function generate_form_input($registration = null, $answer = null, $input_constructor_args = array()) |
|
503 | + { |
|
504 | + $identifier = $this->is_system_question() ? $this->system_ID() : $this->ID(); |
|
505 | + |
|
506 | + $input_constructor_args = array_merge( |
|
507 | + array( |
|
508 | + 'required' => $this->required() ? true : false, |
|
509 | + 'html_label_text' => $this->display_text(), |
|
510 | + 'required_validation_error_message' => $this->required_text(), |
|
511 | + ), |
|
512 | + $input_constructor_args |
|
513 | + ); |
|
514 | + if (! $answer instanceof EE_Answer && $registration instanceof EE_Registration) { |
|
515 | + $answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID()); |
|
516 | + } |
|
517 | + // has this question been answered ? |
|
518 | + if ($answer instanceof EE_Answer |
|
519 | + && $answer->value() !== '' |
|
520 | + ) { |
|
521 | + // answer gets htmlspecialchars called on it, undo that please |
|
522 | + // because the form input's display strategy may call esc_attr too |
|
523 | + // which also does html special characters |
|
524 | + $values_with_html_special_chars = $answer->value(); |
|
525 | + if (is_array($values_with_html_special_chars)) { |
|
526 | + $default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars); |
|
527 | + } else { |
|
528 | + $default_value = htmlspecialchars_decode($values_with_html_special_chars); |
|
529 | + } |
|
530 | + $input_constructor_args['default'] = $default_value; |
|
531 | + } |
|
532 | + $max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID()); |
|
533 | + if (in_array( |
|
534 | + $this->type(), |
|
535 | + EEM_Question::instance()->questionTypesWithMaxLength(), |
|
536 | + true |
|
537 | + )) { |
|
538 | + $input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy( |
|
539 | + null, |
|
540 | + min($max_max_for_question, $this->max()) |
|
541 | + ); |
|
542 | + } |
|
543 | + $input_constructor_args = apply_filters( |
|
544 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args', |
|
545 | + $input_constructor_args, |
|
546 | + $registration, |
|
547 | + $this, |
|
548 | + $answer |
|
549 | + ); |
|
550 | + |
|
551 | + $result = null; |
|
552 | + switch ($this->type()) { |
|
553 | + // Text |
|
554 | + case EEM_Question::QST_type_text: |
|
555 | + $result = new EE_Text_Input($input_constructor_args); |
|
556 | + break; |
|
557 | + // Textarea |
|
558 | + case EEM_Question::QST_type_textarea: |
|
559 | + $result = new EE_Text_Area_Input($input_constructor_args); |
|
560 | + break; |
|
561 | + // Radio Buttons |
|
562 | + case EEM_Question::QST_type_radio: |
|
563 | + $result = new EE_Radio_Button_Input($this->options(), $input_constructor_args); |
|
564 | + break; |
|
565 | + // Dropdown |
|
566 | + case EEM_Question::QST_type_dropdown: |
|
567 | + $result = new EE_Select_Input($this->options(), $input_constructor_args); |
|
568 | + break; |
|
569 | + // State Dropdown |
|
570 | + case EEM_Question::QST_type_state: |
|
571 | + $state_options = apply_filters( |
|
572 | + 'FHEE__EE_Question__generate_form_input__state_options', |
|
573 | + null, |
|
574 | + $this, |
|
575 | + $registration, |
|
576 | + $answer |
|
577 | + ); |
|
578 | + $result = new EE_State_Select_Input($state_options, $input_constructor_args); |
|
579 | + break; |
|
580 | + // Country Dropdown |
|
581 | + case EEM_Question::QST_type_country: |
|
582 | + $country_options = apply_filters( |
|
583 | + 'FHEE__EE_Question__generate_form_input__country_options', |
|
584 | + null, |
|
585 | + $this, |
|
586 | + $registration, |
|
587 | + $answer |
|
588 | + ); |
|
589 | + $result = new EE_Country_Select_Input($country_options, $input_constructor_args); |
|
590 | + break; |
|
591 | + // Checkboxes |
|
592 | + case EEM_Question::QST_type_checkbox: |
|
593 | + $result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args); |
|
594 | + break; |
|
595 | + // Date |
|
596 | + case EEM_Question::QST_type_date: |
|
597 | + $result = new EE_Datepicker_Input($input_constructor_args); |
|
598 | + break; |
|
599 | + case EEM_Question::QST_type_html_textarea: |
|
600 | + $input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy(); |
|
601 | + $result = new EE_Text_Area_Input($input_constructor_args); |
|
602 | + $result->remove_validation_strategy('EE_Plaintext_Validation_Strategy'); |
|
603 | + break; |
|
604 | + case EEM_Question::QST_type_email: |
|
605 | + $result = new EE_Email_Input($input_constructor_args); |
|
606 | + break; |
|
607 | + case EEM_Question::QST_type_us_phone: |
|
608 | + $result = new EE_Phone_Input($input_constructor_args); |
|
609 | + break; |
|
610 | + case EEM_Question::QST_type_int: |
|
611 | + $result = new EE_Integer_Input($input_constructor_args); |
|
612 | + break; |
|
613 | + case EEM_Question::QST_type_decimal: |
|
614 | + $result = new EE_Float_Input($input_constructor_args); |
|
615 | + break; |
|
616 | + case EEM_Question::QST_type_url: |
|
617 | + $input_constructor_args['validation_strategies'][] = LoaderFactory::getLoader()->getNew('EE_URL_Validation_Strategy'); |
|
618 | + $result = new EE_Text_Input($input_constructor_args); |
|
619 | + break; |
|
620 | + case EEM_Question::QST_type_year: |
|
621 | + $result = new EE_Year_Input( |
|
622 | + $input_constructor_args, |
|
623 | + apply_filters( |
|
624 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', |
|
625 | + true, |
|
626 | + $this |
|
627 | + ), |
|
628 | + apply_filters( |
|
629 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', |
|
630 | + 100, |
|
631 | + $this |
|
632 | + ), |
|
633 | + apply_filters( |
|
634 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', |
|
635 | + 100, |
|
636 | + $this |
|
637 | + ) |
|
638 | + ); |
|
639 | + break; |
|
640 | + case EEM_Question::QST_type_multi_select: |
|
641 | + $result = new EE_Select_Multiple_Input($this->options(), $input_constructor_args); |
|
642 | + break; |
|
643 | + // fallback |
|
644 | + default: |
|
645 | + $default_input = apply_filters( |
|
646 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__default', |
|
647 | + null, |
|
648 | + $this->type(), |
|
649 | + $this, |
|
650 | + $input_constructor_args |
|
651 | + ); |
|
652 | + if (! $default_input) { |
|
653 | + $default_input = new EE_Text_Input($input_constructor_args); |
|
654 | + } |
|
655 | + $result = $default_input; |
|
656 | + } |
|
657 | + return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer); |
|
658 | + } |
|
659 | + |
|
660 | + |
|
661 | + /** |
|
662 | + * Returns whether or not this question type should have question option entries |
|
663 | + * |
|
664 | + * @return bool |
|
665 | + */ |
|
666 | + public function should_have_question_options() |
|
667 | + { |
|
668 | + return in_array( |
|
669 | + $this->type(), |
|
670 | + $this->_model->question_types_with_options(), |
|
671 | + true |
|
672 | + ); |
|
673 | + } |
|
674 | 674 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * generate_question_form_inputs_for_object |
242 | 242 | * |
243 | 243 | * @access protected |
244 | - * @param bool|object $object $object |
|
244 | + * @param EE_Base_Class|null $object $object |
|
245 | 245 | * @param array $input_types |
246 | 246 | * @return array |
247 | 247 | */ |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * |
355 | 355 | * @access public |
356 | 356 | * @param \EE_Question_Option $QSO EE_Question_Option |
357 | - * @return boolean |
|
357 | + * @return boolean|null |
|
358 | 358 | */ |
359 | 359 | public function add_temp_option(EE_Question_Option $QSO) |
360 | 360 | { |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @access public |
369 | 369 | * @param string $property |
370 | - * @param mixed $value |
|
371 | - * @return mixed |
|
370 | + * @param boolean $value |
|
371 | + * @return boolean|null |
|
372 | 372 | */ |
373 | 373 | public function set($property = null, $value = null) |
374 | 374 | { |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * get_meta |
417 | 417 | * |
418 | 418 | * @access public |
419 | - * @param mixed $key |
|
419 | + * @param string $key |
|
420 | 420 | * @return mixed |
421 | 421 | */ |
422 | 422 | public function get_meta($key = false) |
@@ -13,435 +13,435 @@ |
||
13 | 13 | class EE_Question_Form_Input |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * EE_Question object |
|
18 | - * |
|
19 | - * @access private |
|
20 | - * @var object |
|
21 | - */ |
|
22 | - private $_QST = null; |
|
23 | - |
|
24 | - /** |
|
25 | - * EE_Answer object |
|
26 | - * |
|
27 | - * @access private |
|
28 | - * @var object |
|
29 | - */ |
|
30 | - private $_ANS = null; |
|
31 | - |
|
32 | - /** |
|
33 | - * $_QST_meta |
|
34 | - * @access private |
|
35 | - * @var array |
|
36 | - */ |
|
37 | - private $_QST_meta = array(); |
|
38 | - |
|
39 | - /** |
|
40 | - * $QST_input_name |
|
41 | - * @access private |
|
42 | - * @var string |
|
43 | - */ |
|
44 | - private $QST_input_name = ''; |
|
45 | - |
|
46 | - /** |
|
47 | - * $QST_input_id |
|
48 | - * @access private |
|
49 | - * @var string |
|
50 | - */ |
|
51 | - private $QST_input_id = ''; |
|
52 | - |
|
53 | - /** |
|
54 | - * $QST_input_class |
|
55 | - * @access private |
|
56 | - * @var string |
|
57 | - */ |
|
58 | - private $QST_input_class = ''; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var bool $QST_disabled |
|
62 | - */ |
|
63 | - private $QST_disabled = false; |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * constructor for questions |
|
68 | - * |
|
69 | - * @param \EE_Question $QST EE_Question object |
|
70 | - * @param \EE_Answer $ANS EE_Answer object |
|
71 | - * @param array $q_meta |
|
72 | - * @access public |
|
73 | - * @return \EE_Question_Form_Input |
|
74 | - */ |
|
75 | - public function __construct(EE_Question $QST = null, EE_Answer $ANS = null, $q_meta = array()) |
|
76 | - { |
|
77 | - if (empty($QST) || empty($ANS)) { |
|
78 | - EE_Error::add_error( |
|
79 | - __('An error occurred. A valid EE_Question or EE_Answer object was not received.', 'event_espresso'), |
|
80 | - __FILE__, |
|
81 | - __FUNCTION__, |
|
82 | - __LINE__ |
|
83 | - ); |
|
84 | - return null; |
|
85 | - } |
|
86 | - $this->_QST = $QST; |
|
87 | - $this->_ANS = $ANS; |
|
88 | - $this->set_question_form_input_meta($q_meta); |
|
89 | - $this->set_question_form_input_init(); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * sets meta data for the question form input |
|
95 | - * |
|
96 | - * @access public |
|
97 | - * @param array $q_meta |
|
98 | - * @return void |
|
99 | - */ |
|
100 | - public function set_question_form_input_meta($q_meta = array()) |
|
101 | - { |
|
102 | - $default_q_meta = array( |
|
103 | - 'att_nmbr' => 1, |
|
104 | - 'ticket_id' => '', |
|
105 | - 'date' => '', |
|
106 | - 'time' => '', |
|
107 | - 'input_name' => '', |
|
108 | - 'input_id' => '', |
|
109 | - 'input_class' => '', |
|
110 | - 'input_prefix' => 'qstn', |
|
111 | - 'append_qstn_id' => true, |
|
112 | - 'htmlentities' => true, |
|
113 | - 'allow_null' => false, |
|
114 | - ); |
|
115 | - $this->_QST_meta = array_merge($default_q_meta, $q_meta); |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * set_question_form_input_init |
|
121 | - * |
|
122 | - * @access public |
|
123 | - * @return void |
|
124 | - */ |
|
125 | - public function set_question_form_input_init() |
|
126 | - { |
|
127 | - $qstn_id = $this->_QST->system_ID() ? $this->_QST->system_ID() : $this->_QST->ID(); |
|
128 | - $this->_set_input_name($qstn_id); |
|
129 | - $this->_set_input_id($qstn_id); |
|
130 | - $this->_set_input_class($qstn_id); |
|
131 | - $this->set_question_form_input_answer($qstn_id); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * set_input_name |
|
137 | - * |
|
138 | - * @access private |
|
139 | - * @param $qstn_id |
|
140 | - * @return void |
|
141 | - */ |
|
142 | - private function _set_input_name($qstn_id) |
|
143 | - { |
|
144 | - if (! empty($qstn_id)) { |
|
145 | - $ANS_ID = $this->get('ANS_ID'); |
|
146 | - $qstn_id = ! empty($ANS_ID) ? '[' . $qstn_id . '][' . $ANS_ID . ']' : '[' . $qstn_id . ']'; |
|
147 | - } |
|
148 | - $this->QST_input_name = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id) |
|
149 | - ? $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name'] . $qstn_id |
|
150 | - : $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name']; |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * get property values for question form input |
|
156 | - * |
|
157 | - * @access public |
|
158 | - * @param string $property |
|
159 | - * @return mixed |
|
160 | - */ |
|
161 | - public function get($property = null) |
|
162 | - { |
|
163 | - if (! empty($property)) { |
|
164 | - if (EEM_Question::instance()->has_field($property)) { |
|
165 | - return $this->_QST->get($property); |
|
166 | - } elseif (EEM_Answer::instance()->has_field($property)) { |
|
167 | - return $this->_ANS->get($property); |
|
168 | - } elseif ($this->_question_form_input_property_exists(__CLASS__, $property)) { |
|
169 | - return $this->{$property}; |
|
170 | - } |
|
171 | - } |
|
172 | - return null; |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * _question_form_input_property_exists |
|
178 | - * |
|
179 | - * @access private |
|
180 | - * @param string $classname |
|
181 | - * @param string $property |
|
182 | - * @return boolean |
|
183 | - */ |
|
184 | - private function _question_form_input_property_exists($classname, $property) |
|
185 | - { |
|
186 | - // first try regular property exists method which works as expected in PHP 5.3+ |
|
187 | - $prop = EEH_Class_Tools::has_property($classname, $property); |
|
188 | - if (! $prop) { |
|
189 | - // use reflection for < PHP 5.3 as a double check when property is not found, possible due to access restriction |
|
190 | - $reflector = new ReflectionClass($classname); |
|
191 | - $prop = $reflector->hasProperty($property); |
|
192 | - } |
|
193 | - return $prop; |
|
194 | - } |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * set_input_id |
|
199 | - * |
|
200 | - * @access private |
|
201 | - * @param $qstn_id |
|
202 | - * @return void |
|
203 | - */ |
|
204 | - private function _set_input_id($qstn_id) |
|
205 | - { |
|
206 | - $input_id = isset($this->_QST_meta['input_id']) && ! empty($this->_QST_meta['input_id']) |
|
207 | - ? $this->_QST_meta['input_id'] |
|
208 | - : sanitize_key(strip_tags($this->_QST->get('QST_display_text'))); |
|
209 | - $this->QST_input_id = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id) |
|
210 | - ? $input_id . '-' . $qstn_id |
|
211 | - : $input_id; |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * set_input_class |
|
217 | - * |
|
218 | - * @access private |
|
219 | - * @return void |
|
220 | - */ |
|
221 | - private function _set_input_class() |
|
222 | - { |
|
223 | - $this->QST_input_class = isset($this->_QST_meta['input_class']) ? $this->_QST_meta['input_class'] : ''; |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - /** |
|
228 | - * set_question_form_input_answer |
|
229 | - * |
|
230 | - * @access public |
|
231 | - * @param mixed int | string $qstn_id |
|
232 | - * @return void |
|
233 | - */ |
|
234 | - public function set_question_form_input_answer($qstn_id) |
|
235 | - { |
|
236 | - // check for answer in $_REQUEST in case we are reprocessing a form after an error |
|
237 | - if (isset($this->_QST_meta['EVT_ID']) |
|
238 | - && isset($this->_QST_meta['att_nmbr']) |
|
239 | - && isset($this->_QST_meta['date']) |
|
240 | - && isset($this->_QST_meta['time']) |
|
241 | - && isset($this->_QST_meta['price_id']) |
|
242 | - ) { |
|
243 | - if (isset($_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ]) |
|
244 | - ) { |
|
245 | - $answer = $_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ]; |
|
246 | - $this->_ANS->set('ANS_value', $answer); |
|
247 | - } |
|
248 | - } |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * generate_question_form_inputs_for_object |
|
254 | - * |
|
255 | - * @access protected |
|
256 | - * @param bool|object $object $object |
|
257 | - * @param array $input_types |
|
258 | - * @return array |
|
259 | - */ |
|
260 | - public static function generate_question_form_inputs_for_object($object = false, $input_types = array()) |
|
261 | - { |
|
262 | - if (! is_object($object)) { |
|
263 | - return false; |
|
264 | - } |
|
265 | - $inputs = array(); |
|
266 | - $fields = $object->get_model()->field_settings(false); |
|
267 | - // $pk = $object->ID(); <<< NO! |
|
268 | - // EEH_Debug_Tools::printr( $object, get_class( $object ) . '<br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
269 | - // EEH_Debug_Tools::printr( $fields, '$fields <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
270 | - // EEH_Debug_Tools::printr( $input_types, '$input_types <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
271 | - foreach ($fields as $field_ID => $field) { |
|
272 | - if ($field instanceof EE_Model_Field_Base) { |
|
273 | - // echo '<h4>$field_ID : ' . $field_ID . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
|
274 | - // EEH_Debug_Tools::printr( $field, '$field <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
275 | - if (isset($input_types[ $field_ID ])) { |
|
276 | - // get saved value for field |
|
277 | - $value = $object->get($field_ID); |
|
278 | - // echo '<h4>$value : ' . $value . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
|
279 | - // if no saved value, then use default |
|
280 | - $value = $value !== null ? $value : $field->get_default_value(); |
|
281 | - // if ( $field_ID == 'CNT_active' ) |
|
282 | - // echo '<h4>$value : ' . $value . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
|
283 | - // determine question type |
|
284 | - $type = isset($input_types[ $field_ID ]) ? $input_types[ $field_ID ]['type'] : 'TEXT'; |
|
285 | - // input name |
|
286 | - $input_name = isset($input_types[ $field_ID ]) && isset($input_types[ $field_ID ]['input_name']) |
|
287 | - ? $input_types[ $field_ID ]['input_name'] . '[' . $field_ID . ']' |
|
288 | - : $field_ID; |
|
289 | - // css class for input |
|
290 | - $class = isset($input_types[ $field_ID ]['class']) && ! empty($input_types[ $field_ID ]['class']) |
|
291 | - ? ' ' . $input_types[ $field_ID ]['class'] |
|
292 | - : ''; |
|
293 | - // whether to apply htmlentities to answer |
|
294 | - $htmlentities = isset($input_types[ $field_ID ]['htmlentities']) |
|
295 | - ? $input_types[ $field_ID ]['htmlentities'] |
|
296 | - : true; |
|
297 | - // whether to apply htmlentities to answer |
|
298 | - $label_b4 = isset($input_types[ $field_ID ]['label_b4']) |
|
299 | - ? $input_types[ $field_ID ]['label_b4'] |
|
300 | - : false; |
|
301 | - // whether to apply htmlentities to answer |
|
302 | - $use_desc_4_label = isset($input_types[ $field_ID ]['use_desc_4_label']) |
|
303 | - ? $input_types[ $field_ID ]['use_desc_4_label'] |
|
304 | - : false; |
|
305 | - // whether input is disabled |
|
306 | - $disabled = isset($input_types[ $field_ID ]['disabled']) |
|
307 | - ? $input_types[ $field_ID ]['disabled'] |
|
308 | - : false; |
|
309 | - |
|
310 | - // create EE_Question_Form_Input object |
|
311 | - $QFI = new EE_Question_Form_Input( |
|
312 | - EE_Question::new_instance( |
|
313 | - array( |
|
314 | - 'QST_ID' => 0, |
|
315 | - 'QST_display_text' => $field->get_nicename(), |
|
316 | - 'QST_type' => $type, |
|
317 | - ) |
|
318 | - ), |
|
319 | - EE_Answer::new_instance( |
|
320 | - array( |
|
321 | - 'ANS_ID' => 0, |
|
322 | - 'QST_ID' => 0, |
|
323 | - 'REG_ID' => 0, |
|
324 | - 'ANS_value' => $value, |
|
325 | - ) |
|
326 | - ), |
|
327 | - array( |
|
328 | - 'input_id' => $field_ID . '-' . $object->ID(), |
|
329 | - 'input_name' => $input_name, |
|
330 | - 'input_class' => $field_ID . $class, |
|
331 | - 'input_prefix' => '', |
|
332 | - 'append_qstn_id' => false, |
|
333 | - 'htmlentities' => $htmlentities, |
|
334 | - 'label_b4' => $label_b4, |
|
335 | - 'use_desc_4_label' => $use_desc_4_label, |
|
336 | - ) |
|
337 | - ); |
|
338 | - // does question type have options ? |
|
339 | - if (in_array($type, array('DROPDOWN', 'RADIO_BTN', 'CHECKBOX')) |
|
340 | - && isset($input_types[ $field_ID ]) |
|
341 | - && isset($input_types[ $field_ID ]['options']) |
|
342 | - ) { |
|
343 | - foreach ($input_types[ $field_ID ]['options'] as $option) { |
|
344 | - $option = stripslashes_deep($option); |
|
345 | - $option_id = ! empty($option['id']) ? $option['id'] : 0; |
|
346 | - $QSO = EE_Question_Option::new_instance( |
|
347 | - array( |
|
348 | - 'QSO_value' => (string) $option_id, |
|
349 | - 'QSO_desc' => $option['text'], |
|
350 | - 'QSO_deleted' => false, |
|
351 | - ) |
|
352 | - ); |
|
353 | - // all QST (and ANS) properties can be accessed indirectly thru QFI |
|
354 | - $QFI->add_temp_option($QSO); |
|
355 | - } |
|
356 | - } |
|
357 | - // we don't want ppl manually changing primary keys cuz that would just lead to total craziness man |
|
358 | - if ($disabled || $field_ID == $object->get_model()->primary_key_name()) { |
|
359 | - $QFI->set('QST_disabled', true); |
|
360 | - } |
|
361 | - // EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
362 | - $inputs[ $field_ID ] = $QFI; |
|
363 | - // if ( $field_ID == 'CNT_active' ) { |
|
364 | - // EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
365 | - // } |
|
366 | - } |
|
367 | - } |
|
368 | - } |
|
369 | - return $inputs; |
|
370 | - } |
|
371 | - |
|
372 | - |
|
373 | - /** |
|
374 | - * add_temp_option |
|
375 | - * |
|
376 | - * @access public |
|
377 | - * @param \EE_Question_Option $QSO EE_Question_Option |
|
378 | - * @return boolean |
|
379 | - */ |
|
380 | - public function add_temp_option(EE_Question_Option $QSO) |
|
381 | - { |
|
382 | - $this->_QST->add_temp_option($QSO); |
|
383 | - } |
|
384 | - |
|
385 | - |
|
386 | - /** |
|
387 | - * set property values for question form input |
|
388 | - * |
|
389 | - * @access public |
|
390 | - * @param string $property |
|
391 | - * @param mixed $value |
|
392 | - * @return mixed |
|
393 | - */ |
|
394 | - public function set($property = null, $value = null) |
|
395 | - { |
|
396 | - if (! empty($property)) { |
|
397 | - if (EEM_Question::instance()->has_field($property)) { |
|
398 | - $this->_QST->set($property, $value); |
|
399 | - } elseif (EEM_Answer::instance()->has_field($property)) { |
|
400 | - $this->_ANS->set($property, $value); |
|
401 | - } elseif ($this->_question_form_input_property_exists(__CLASS__, $property)) { |
|
402 | - // echo "<hr>$property is a prop of QFI"; |
|
403 | - $this->{$property} = $value; |
|
404 | - return true; |
|
405 | - } |
|
406 | - } |
|
407 | - return null; |
|
408 | - } |
|
409 | - |
|
410 | - |
|
411 | - /** |
|
412 | - * _question_form_input_property_exists |
|
413 | - * |
|
414 | - * @access public |
|
415 | - * @param boolean $notDeletedOptionsOnly 1 |
|
416 | - * whether to return ALL options, or only the ones which have |
|
417 | - * not yet been deleted |
|
418 | - * @param string|array $selected_value_to_always_include , when retrieving options to an ANSWERED question, |
|
419 | - * we want to usually only show non-deleted options AND the |
|
420 | - * value that was selected for the answer, whether it was |
|
421 | - * trashed or not. |
|
422 | - * @return EE_Question_Option |
|
423 | - */ |
|
424 | - public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null) |
|
425 | - { |
|
426 | - $temp_options = $this->_QST->temp_options(); |
|
427 | - return ! empty($temp_options) |
|
428 | - ? $temp_options |
|
429 | - : $this->_QST->options( |
|
430 | - $notDeletedOptionsOnly, |
|
431 | - $selected_value_to_always_include |
|
432 | - ); |
|
433 | - } |
|
434 | - |
|
435 | - |
|
436 | - /** |
|
437 | - * get_meta |
|
438 | - * |
|
439 | - * @access public |
|
440 | - * @param mixed $key |
|
441 | - * @return mixed |
|
442 | - */ |
|
443 | - public function get_meta($key = false) |
|
444 | - { |
|
445 | - return $key && isset($this->_QST_meta[ $key ]) ? $this->_QST_meta[ $key ] : false; |
|
446 | - } |
|
16 | + /** |
|
17 | + * EE_Question object |
|
18 | + * |
|
19 | + * @access private |
|
20 | + * @var object |
|
21 | + */ |
|
22 | + private $_QST = null; |
|
23 | + |
|
24 | + /** |
|
25 | + * EE_Answer object |
|
26 | + * |
|
27 | + * @access private |
|
28 | + * @var object |
|
29 | + */ |
|
30 | + private $_ANS = null; |
|
31 | + |
|
32 | + /** |
|
33 | + * $_QST_meta |
|
34 | + * @access private |
|
35 | + * @var array |
|
36 | + */ |
|
37 | + private $_QST_meta = array(); |
|
38 | + |
|
39 | + /** |
|
40 | + * $QST_input_name |
|
41 | + * @access private |
|
42 | + * @var string |
|
43 | + */ |
|
44 | + private $QST_input_name = ''; |
|
45 | + |
|
46 | + /** |
|
47 | + * $QST_input_id |
|
48 | + * @access private |
|
49 | + * @var string |
|
50 | + */ |
|
51 | + private $QST_input_id = ''; |
|
52 | + |
|
53 | + /** |
|
54 | + * $QST_input_class |
|
55 | + * @access private |
|
56 | + * @var string |
|
57 | + */ |
|
58 | + private $QST_input_class = ''; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var bool $QST_disabled |
|
62 | + */ |
|
63 | + private $QST_disabled = false; |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * constructor for questions |
|
68 | + * |
|
69 | + * @param \EE_Question $QST EE_Question object |
|
70 | + * @param \EE_Answer $ANS EE_Answer object |
|
71 | + * @param array $q_meta |
|
72 | + * @access public |
|
73 | + * @return \EE_Question_Form_Input |
|
74 | + */ |
|
75 | + public function __construct(EE_Question $QST = null, EE_Answer $ANS = null, $q_meta = array()) |
|
76 | + { |
|
77 | + if (empty($QST) || empty($ANS)) { |
|
78 | + EE_Error::add_error( |
|
79 | + __('An error occurred. A valid EE_Question or EE_Answer object was not received.', 'event_espresso'), |
|
80 | + __FILE__, |
|
81 | + __FUNCTION__, |
|
82 | + __LINE__ |
|
83 | + ); |
|
84 | + return null; |
|
85 | + } |
|
86 | + $this->_QST = $QST; |
|
87 | + $this->_ANS = $ANS; |
|
88 | + $this->set_question_form_input_meta($q_meta); |
|
89 | + $this->set_question_form_input_init(); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * sets meta data for the question form input |
|
95 | + * |
|
96 | + * @access public |
|
97 | + * @param array $q_meta |
|
98 | + * @return void |
|
99 | + */ |
|
100 | + public function set_question_form_input_meta($q_meta = array()) |
|
101 | + { |
|
102 | + $default_q_meta = array( |
|
103 | + 'att_nmbr' => 1, |
|
104 | + 'ticket_id' => '', |
|
105 | + 'date' => '', |
|
106 | + 'time' => '', |
|
107 | + 'input_name' => '', |
|
108 | + 'input_id' => '', |
|
109 | + 'input_class' => '', |
|
110 | + 'input_prefix' => 'qstn', |
|
111 | + 'append_qstn_id' => true, |
|
112 | + 'htmlentities' => true, |
|
113 | + 'allow_null' => false, |
|
114 | + ); |
|
115 | + $this->_QST_meta = array_merge($default_q_meta, $q_meta); |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * set_question_form_input_init |
|
121 | + * |
|
122 | + * @access public |
|
123 | + * @return void |
|
124 | + */ |
|
125 | + public function set_question_form_input_init() |
|
126 | + { |
|
127 | + $qstn_id = $this->_QST->system_ID() ? $this->_QST->system_ID() : $this->_QST->ID(); |
|
128 | + $this->_set_input_name($qstn_id); |
|
129 | + $this->_set_input_id($qstn_id); |
|
130 | + $this->_set_input_class($qstn_id); |
|
131 | + $this->set_question_form_input_answer($qstn_id); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * set_input_name |
|
137 | + * |
|
138 | + * @access private |
|
139 | + * @param $qstn_id |
|
140 | + * @return void |
|
141 | + */ |
|
142 | + private function _set_input_name($qstn_id) |
|
143 | + { |
|
144 | + if (! empty($qstn_id)) { |
|
145 | + $ANS_ID = $this->get('ANS_ID'); |
|
146 | + $qstn_id = ! empty($ANS_ID) ? '[' . $qstn_id . '][' . $ANS_ID . ']' : '[' . $qstn_id . ']'; |
|
147 | + } |
|
148 | + $this->QST_input_name = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id) |
|
149 | + ? $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name'] . $qstn_id |
|
150 | + : $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name']; |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * get property values for question form input |
|
156 | + * |
|
157 | + * @access public |
|
158 | + * @param string $property |
|
159 | + * @return mixed |
|
160 | + */ |
|
161 | + public function get($property = null) |
|
162 | + { |
|
163 | + if (! empty($property)) { |
|
164 | + if (EEM_Question::instance()->has_field($property)) { |
|
165 | + return $this->_QST->get($property); |
|
166 | + } elseif (EEM_Answer::instance()->has_field($property)) { |
|
167 | + return $this->_ANS->get($property); |
|
168 | + } elseif ($this->_question_form_input_property_exists(__CLASS__, $property)) { |
|
169 | + return $this->{$property}; |
|
170 | + } |
|
171 | + } |
|
172 | + return null; |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * _question_form_input_property_exists |
|
178 | + * |
|
179 | + * @access private |
|
180 | + * @param string $classname |
|
181 | + * @param string $property |
|
182 | + * @return boolean |
|
183 | + */ |
|
184 | + private function _question_form_input_property_exists($classname, $property) |
|
185 | + { |
|
186 | + // first try regular property exists method which works as expected in PHP 5.3+ |
|
187 | + $prop = EEH_Class_Tools::has_property($classname, $property); |
|
188 | + if (! $prop) { |
|
189 | + // use reflection for < PHP 5.3 as a double check when property is not found, possible due to access restriction |
|
190 | + $reflector = new ReflectionClass($classname); |
|
191 | + $prop = $reflector->hasProperty($property); |
|
192 | + } |
|
193 | + return $prop; |
|
194 | + } |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * set_input_id |
|
199 | + * |
|
200 | + * @access private |
|
201 | + * @param $qstn_id |
|
202 | + * @return void |
|
203 | + */ |
|
204 | + private function _set_input_id($qstn_id) |
|
205 | + { |
|
206 | + $input_id = isset($this->_QST_meta['input_id']) && ! empty($this->_QST_meta['input_id']) |
|
207 | + ? $this->_QST_meta['input_id'] |
|
208 | + : sanitize_key(strip_tags($this->_QST->get('QST_display_text'))); |
|
209 | + $this->QST_input_id = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id) |
|
210 | + ? $input_id . '-' . $qstn_id |
|
211 | + : $input_id; |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * set_input_class |
|
217 | + * |
|
218 | + * @access private |
|
219 | + * @return void |
|
220 | + */ |
|
221 | + private function _set_input_class() |
|
222 | + { |
|
223 | + $this->QST_input_class = isset($this->_QST_meta['input_class']) ? $this->_QST_meta['input_class'] : ''; |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + /** |
|
228 | + * set_question_form_input_answer |
|
229 | + * |
|
230 | + * @access public |
|
231 | + * @param mixed int | string $qstn_id |
|
232 | + * @return void |
|
233 | + */ |
|
234 | + public function set_question_form_input_answer($qstn_id) |
|
235 | + { |
|
236 | + // check for answer in $_REQUEST in case we are reprocessing a form after an error |
|
237 | + if (isset($this->_QST_meta['EVT_ID']) |
|
238 | + && isset($this->_QST_meta['att_nmbr']) |
|
239 | + && isset($this->_QST_meta['date']) |
|
240 | + && isset($this->_QST_meta['time']) |
|
241 | + && isset($this->_QST_meta['price_id']) |
|
242 | + ) { |
|
243 | + if (isset($_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ]) |
|
244 | + ) { |
|
245 | + $answer = $_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ]; |
|
246 | + $this->_ANS->set('ANS_value', $answer); |
|
247 | + } |
|
248 | + } |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * generate_question_form_inputs_for_object |
|
254 | + * |
|
255 | + * @access protected |
|
256 | + * @param bool|object $object $object |
|
257 | + * @param array $input_types |
|
258 | + * @return array |
|
259 | + */ |
|
260 | + public static function generate_question_form_inputs_for_object($object = false, $input_types = array()) |
|
261 | + { |
|
262 | + if (! is_object($object)) { |
|
263 | + return false; |
|
264 | + } |
|
265 | + $inputs = array(); |
|
266 | + $fields = $object->get_model()->field_settings(false); |
|
267 | + // $pk = $object->ID(); <<< NO! |
|
268 | + // EEH_Debug_Tools::printr( $object, get_class( $object ) . '<br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
269 | + // EEH_Debug_Tools::printr( $fields, '$fields <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
270 | + // EEH_Debug_Tools::printr( $input_types, '$input_types <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
271 | + foreach ($fields as $field_ID => $field) { |
|
272 | + if ($field instanceof EE_Model_Field_Base) { |
|
273 | + // echo '<h4>$field_ID : ' . $field_ID . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
|
274 | + // EEH_Debug_Tools::printr( $field, '$field <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
275 | + if (isset($input_types[ $field_ID ])) { |
|
276 | + // get saved value for field |
|
277 | + $value = $object->get($field_ID); |
|
278 | + // echo '<h4>$value : ' . $value . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
|
279 | + // if no saved value, then use default |
|
280 | + $value = $value !== null ? $value : $field->get_default_value(); |
|
281 | + // if ( $field_ID == 'CNT_active' ) |
|
282 | + // echo '<h4>$value : ' . $value . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
|
283 | + // determine question type |
|
284 | + $type = isset($input_types[ $field_ID ]) ? $input_types[ $field_ID ]['type'] : 'TEXT'; |
|
285 | + // input name |
|
286 | + $input_name = isset($input_types[ $field_ID ]) && isset($input_types[ $field_ID ]['input_name']) |
|
287 | + ? $input_types[ $field_ID ]['input_name'] . '[' . $field_ID . ']' |
|
288 | + : $field_ID; |
|
289 | + // css class for input |
|
290 | + $class = isset($input_types[ $field_ID ]['class']) && ! empty($input_types[ $field_ID ]['class']) |
|
291 | + ? ' ' . $input_types[ $field_ID ]['class'] |
|
292 | + : ''; |
|
293 | + // whether to apply htmlentities to answer |
|
294 | + $htmlentities = isset($input_types[ $field_ID ]['htmlentities']) |
|
295 | + ? $input_types[ $field_ID ]['htmlentities'] |
|
296 | + : true; |
|
297 | + // whether to apply htmlentities to answer |
|
298 | + $label_b4 = isset($input_types[ $field_ID ]['label_b4']) |
|
299 | + ? $input_types[ $field_ID ]['label_b4'] |
|
300 | + : false; |
|
301 | + // whether to apply htmlentities to answer |
|
302 | + $use_desc_4_label = isset($input_types[ $field_ID ]['use_desc_4_label']) |
|
303 | + ? $input_types[ $field_ID ]['use_desc_4_label'] |
|
304 | + : false; |
|
305 | + // whether input is disabled |
|
306 | + $disabled = isset($input_types[ $field_ID ]['disabled']) |
|
307 | + ? $input_types[ $field_ID ]['disabled'] |
|
308 | + : false; |
|
309 | + |
|
310 | + // create EE_Question_Form_Input object |
|
311 | + $QFI = new EE_Question_Form_Input( |
|
312 | + EE_Question::new_instance( |
|
313 | + array( |
|
314 | + 'QST_ID' => 0, |
|
315 | + 'QST_display_text' => $field->get_nicename(), |
|
316 | + 'QST_type' => $type, |
|
317 | + ) |
|
318 | + ), |
|
319 | + EE_Answer::new_instance( |
|
320 | + array( |
|
321 | + 'ANS_ID' => 0, |
|
322 | + 'QST_ID' => 0, |
|
323 | + 'REG_ID' => 0, |
|
324 | + 'ANS_value' => $value, |
|
325 | + ) |
|
326 | + ), |
|
327 | + array( |
|
328 | + 'input_id' => $field_ID . '-' . $object->ID(), |
|
329 | + 'input_name' => $input_name, |
|
330 | + 'input_class' => $field_ID . $class, |
|
331 | + 'input_prefix' => '', |
|
332 | + 'append_qstn_id' => false, |
|
333 | + 'htmlentities' => $htmlentities, |
|
334 | + 'label_b4' => $label_b4, |
|
335 | + 'use_desc_4_label' => $use_desc_4_label, |
|
336 | + ) |
|
337 | + ); |
|
338 | + // does question type have options ? |
|
339 | + if (in_array($type, array('DROPDOWN', 'RADIO_BTN', 'CHECKBOX')) |
|
340 | + && isset($input_types[ $field_ID ]) |
|
341 | + && isset($input_types[ $field_ID ]['options']) |
|
342 | + ) { |
|
343 | + foreach ($input_types[ $field_ID ]['options'] as $option) { |
|
344 | + $option = stripslashes_deep($option); |
|
345 | + $option_id = ! empty($option['id']) ? $option['id'] : 0; |
|
346 | + $QSO = EE_Question_Option::new_instance( |
|
347 | + array( |
|
348 | + 'QSO_value' => (string) $option_id, |
|
349 | + 'QSO_desc' => $option['text'], |
|
350 | + 'QSO_deleted' => false, |
|
351 | + ) |
|
352 | + ); |
|
353 | + // all QST (and ANS) properties can be accessed indirectly thru QFI |
|
354 | + $QFI->add_temp_option($QSO); |
|
355 | + } |
|
356 | + } |
|
357 | + // we don't want ppl manually changing primary keys cuz that would just lead to total craziness man |
|
358 | + if ($disabled || $field_ID == $object->get_model()->primary_key_name()) { |
|
359 | + $QFI->set('QST_disabled', true); |
|
360 | + } |
|
361 | + // EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
362 | + $inputs[ $field_ID ] = $QFI; |
|
363 | + // if ( $field_ID == 'CNT_active' ) { |
|
364 | + // EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
365 | + // } |
|
366 | + } |
|
367 | + } |
|
368 | + } |
|
369 | + return $inputs; |
|
370 | + } |
|
371 | + |
|
372 | + |
|
373 | + /** |
|
374 | + * add_temp_option |
|
375 | + * |
|
376 | + * @access public |
|
377 | + * @param \EE_Question_Option $QSO EE_Question_Option |
|
378 | + * @return boolean |
|
379 | + */ |
|
380 | + public function add_temp_option(EE_Question_Option $QSO) |
|
381 | + { |
|
382 | + $this->_QST->add_temp_option($QSO); |
|
383 | + } |
|
384 | + |
|
385 | + |
|
386 | + /** |
|
387 | + * set property values for question form input |
|
388 | + * |
|
389 | + * @access public |
|
390 | + * @param string $property |
|
391 | + * @param mixed $value |
|
392 | + * @return mixed |
|
393 | + */ |
|
394 | + public function set($property = null, $value = null) |
|
395 | + { |
|
396 | + if (! empty($property)) { |
|
397 | + if (EEM_Question::instance()->has_field($property)) { |
|
398 | + $this->_QST->set($property, $value); |
|
399 | + } elseif (EEM_Answer::instance()->has_field($property)) { |
|
400 | + $this->_ANS->set($property, $value); |
|
401 | + } elseif ($this->_question_form_input_property_exists(__CLASS__, $property)) { |
|
402 | + // echo "<hr>$property is a prop of QFI"; |
|
403 | + $this->{$property} = $value; |
|
404 | + return true; |
|
405 | + } |
|
406 | + } |
|
407 | + return null; |
|
408 | + } |
|
409 | + |
|
410 | + |
|
411 | + /** |
|
412 | + * _question_form_input_property_exists |
|
413 | + * |
|
414 | + * @access public |
|
415 | + * @param boolean $notDeletedOptionsOnly 1 |
|
416 | + * whether to return ALL options, or only the ones which have |
|
417 | + * not yet been deleted |
|
418 | + * @param string|array $selected_value_to_always_include , when retrieving options to an ANSWERED question, |
|
419 | + * we want to usually only show non-deleted options AND the |
|
420 | + * value that was selected for the answer, whether it was |
|
421 | + * trashed or not. |
|
422 | + * @return EE_Question_Option |
|
423 | + */ |
|
424 | + public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null) |
|
425 | + { |
|
426 | + $temp_options = $this->_QST->temp_options(); |
|
427 | + return ! empty($temp_options) |
|
428 | + ? $temp_options |
|
429 | + : $this->_QST->options( |
|
430 | + $notDeletedOptionsOnly, |
|
431 | + $selected_value_to_always_include |
|
432 | + ); |
|
433 | + } |
|
434 | + |
|
435 | + |
|
436 | + /** |
|
437 | + * get_meta |
|
438 | + * |
|
439 | + * @access public |
|
440 | + * @param mixed $key |
|
441 | + * @return mixed |
|
442 | + */ |
|
443 | + public function get_meta($key = false) |
|
444 | + { |
|
445 | + return $key && isset($this->_QST_meta[ $key ]) ? $this->_QST_meta[ $key ] : false; |
|
446 | + } |
|
447 | 447 | } |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | */ |
142 | 142 | private function _set_input_name($qstn_id) |
143 | 143 | { |
144 | - if (! empty($qstn_id)) { |
|
144 | + if ( ! empty($qstn_id)) { |
|
145 | 145 | $ANS_ID = $this->get('ANS_ID'); |
146 | - $qstn_id = ! empty($ANS_ID) ? '[' . $qstn_id . '][' . $ANS_ID . ']' : '[' . $qstn_id . ']'; |
|
146 | + $qstn_id = ! empty($ANS_ID) ? '['.$qstn_id.']['.$ANS_ID.']' : '['.$qstn_id.']'; |
|
147 | 147 | } |
148 | 148 | $this->QST_input_name = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id) |
149 | - ? $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name'] . $qstn_id |
|
150 | - : $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name']; |
|
149 | + ? $this->_QST_meta['input_prefix'].$this->_QST_meta['input_name'].$qstn_id |
|
150 | + : $this->_QST_meta['input_prefix'].$this->_QST_meta['input_name']; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function get($property = null) |
162 | 162 | { |
163 | - if (! empty($property)) { |
|
163 | + if ( ! empty($property)) { |
|
164 | 164 | if (EEM_Question::instance()->has_field($property)) { |
165 | 165 | return $this->_QST->get($property); |
166 | 166 | } elseif (EEM_Answer::instance()->has_field($property)) { |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | { |
186 | 186 | // first try regular property exists method which works as expected in PHP 5.3+ |
187 | 187 | $prop = EEH_Class_Tools::has_property($classname, $property); |
188 | - if (! $prop) { |
|
188 | + if ( ! $prop) { |
|
189 | 189 | // use reflection for < PHP 5.3 as a double check when property is not found, possible due to access restriction |
190 | 190 | $reflector = new ReflectionClass($classname); |
191 | 191 | $prop = $reflector->hasProperty($property); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | ? $this->_QST_meta['input_id'] |
208 | 208 | : sanitize_key(strip_tags($this->_QST->get('QST_display_text'))); |
209 | 209 | $this->QST_input_id = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id) |
210 | - ? $input_id . '-' . $qstn_id |
|
210 | + ? $input_id.'-'.$qstn_id |
|
211 | 211 | : $input_id; |
212 | 212 | } |
213 | 213 | |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | && isset($this->_QST_meta['time']) |
241 | 241 | && isset($this->_QST_meta['price_id']) |
242 | 242 | ) { |
243 | - if (isset($_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ]) |
|
243 | + if (isset($_REQUEST['qstn'][$this->_QST_meta['EVT_ID']][$this->_QST_meta['att_nmbr']][$this->_QST_meta['date']][$this->_QST_meta['time']][$this->_QST_meta['price_id']][$qstn_id]) |
|
244 | 244 | ) { |
245 | - $answer = $_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ]; |
|
245 | + $answer = $_REQUEST['qstn'][$this->_QST_meta['EVT_ID']][$this->_QST_meta['att_nmbr']][$this->_QST_meta['date']][$this->_QST_meta['time']][$this->_QST_meta['price_id']][$qstn_id]; |
|
246 | 246 | $this->_ANS->set('ANS_value', $answer); |
247 | 247 | } |
248 | 248 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | */ |
260 | 260 | public static function generate_question_form_inputs_for_object($object = false, $input_types = array()) |
261 | 261 | { |
262 | - if (! is_object($object)) { |
|
262 | + if ( ! is_object($object)) { |
|
263 | 263 | return false; |
264 | 264 | } |
265 | 265 | $inputs = array(); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | if ($field instanceof EE_Model_Field_Base) { |
273 | 273 | // echo '<h4>$field_ID : ' . $field_ID . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
274 | 274 | // EEH_Debug_Tools::printr( $field, '$field <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
275 | - if (isset($input_types[ $field_ID ])) { |
|
275 | + if (isset($input_types[$field_ID])) { |
|
276 | 276 | // get saved value for field |
277 | 277 | $value = $object->get($field_ID); |
278 | 278 | // echo '<h4>$value : ' . $value . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
@@ -281,30 +281,30 @@ discard block |
||
281 | 281 | // if ( $field_ID == 'CNT_active' ) |
282 | 282 | // echo '<h4>$value : ' . $value . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
283 | 283 | // determine question type |
284 | - $type = isset($input_types[ $field_ID ]) ? $input_types[ $field_ID ]['type'] : 'TEXT'; |
|
284 | + $type = isset($input_types[$field_ID]) ? $input_types[$field_ID]['type'] : 'TEXT'; |
|
285 | 285 | // input name |
286 | - $input_name = isset($input_types[ $field_ID ]) && isset($input_types[ $field_ID ]['input_name']) |
|
287 | - ? $input_types[ $field_ID ]['input_name'] . '[' . $field_ID . ']' |
|
286 | + $input_name = isset($input_types[$field_ID]) && isset($input_types[$field_ID]['input_name']) |
|
287 | + ? $input_types[$field_ID]['input_name'].'['.$field_ID.']' |
|
288 | 288 | : $field_ID; |
289 | 289 | // css class for input |
290 | - $class = isset($input_types[ $field_ID ]['class']) && ! empty($input_types[ $field_ID ]['class']) |
|
291 | - ? ' ' . $input_types[ $field_ID ]['class'] |
|
290 | + $class = isset($input_types[$field_ID]['class']) && ! empty($input_types[$field_ID]['class']) |
|
291 | + ? ' '.$input_types[$field_ID]['class'] |
|
292 | 292 | : ''; |
293 | 293 | // whether to apply htmlentities to answer |
294 | - $htmlentities = isset($input_types[ $field_ID ]['htmlentities']) |
|
295 | - ? $input_types[ $field_ID ]['htmlentities'] |
|
294 | + $htmlentities = isset($input_types[$field_ID]['htmlentities']) |
|
295 | + ? $input_types[$field_ID]['htmlentities'] |
|
296 | 296 | : true; |
297 | 297 | // whether to apply htmlentities to answer |
298 | - $label_b4 = isset($input_types[ $field_ID ]['label_b4']) |
|
299 | - ? $input_types[ $field_ID ]['label_b4'] |
|
298 | + $label_b4 = isset($input_types[$field_ID]['label_b4']) |
|
299 | + ? $input_types[$field_ID]['label_b4'] |
|
300 | 300 | : false; |
301 | 301 | // whether to apply htmlentities to answer |
302 | - $use_desc_4_label = isset($input_types[ $field_ID ]['use_desc_4_label']) |
|
303 | - ? $input_types[ $field_ID ]['use_desc_4_label'] |
|
302 | + $use_desc_4_label = isset($input_types[$field_ID]['use_desc_4_label']) |
|
303 | + ? $input_types[$field_ID]['use_desc_4_label'] |
|
304 | 304 | : false; |
305 | 305 | // whether input is disabled |
306 | - $disabled = isset($input_types[ $field_ID ]['disabled']) |
|
307 | - ? $input_types[ $field_ID ]['disabled'] |
|
306 | + $disabled = isset($input_types[$field_ID]['disabled']) |
|
307 | + ? $input_types[$field_ID]['disabled'] |
|
308 | 308 | : false; |
309 | 309 | |
310 | 310 | // create EE_Question_Form_Input object |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | ) |
326 | 326 | ), |
327 | 327 | array( |
328 | - 'input_id' => $field_ID . '-' . $object->ID(), |
|
328 | + 'input_id' => $field_ID.'-'.$object->ID(), |
|
329 | 329 | 'input_name' => $input_name, |
330 | - 'input_class' => $field_ID . $class, |
|
330 | + 'input_class' => $field_ID.$class, |
|
331 | 331 | 'input_prefix' => '', |
332 | 332 | 'append_qstn_id' => false, |
333 | 333 | 'htmlentities' => $htmlentities, |
@@ -337,10 +337,10 @@ discard block |
||
337 | 337 | ); |
338 | 338 | // does question type have options ? |
339 | 339 | if (in_array($type, array('DROPDOWN', 'RADIO_BTN', 'CHECKBOX')) |
340 | - && isset($input_types[ $field_ID ]) |
|
341 | - && isset($input_types[ $field_ID ]['options']) |
|
340 | + && isset($input_types[$field_ID]) |
|
341 | + && isset($input_types[$field_ID]['options']) |
|
342 | 342 | ) { |
343 | - foreach ($input_types[ $field_ID ]['options'] as $option) { |
|
343 | + foreach ($input_types[$field_ID]['options'] as $option) { |
|
344 | 344 | $option = stripslashes_deep($option); |
345 | 345 | $option_id = ! empty($option['id']) ? $option['id'] : 0; |
346 | 346 | $QSO = EE_Question_Option::new_instance( |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | $QFI->set('QST_disabled', true); |
360 | 360 | } |
361 | 361 | // EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
362 | - $inputs[ $field_ID ] = $QFI; |
|
362 | + $inputs[$field_ID] = $QFI; |
|
363 | 363 | // if ( $field_ID == 'CNT_active' ) { |
364 | 364 | // EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
365 | 365 | // } |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | */ |
394 | 394 | public function set($property = null, $value = null) |
395 | 395 | { |
396 | - if (! empty($property)) { |
|
396 | + if ( ! empty($property)) { |
|
397 | 397 | if (EEM_Question::instance()->has_field($property)) { |
398 | 398 | $this->_QST->set($property, $value); |
399 | 399 | } elseif (EEM_Answer::instance()->has_field($property)) { |
@@ -442,6 +442,6 @@ discard block |
||
442 | 442 | */ |
443 | 443 | public function get_meta($key = false) |
444 | 444 | { |
445 | - return $key && isset($this->_QST_meta[ $key ]) ? $this->_QST_meta[ $key ] : false; |
|
445 | + return $key && isset($this->_QST_meta[$key]) ? $this->_QST_meta[$key] : false; |
|
446 | 446 | } |
447 | 447 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * Adds the question to this question group |
216 | 216 | * |
217 | 217 | * @param EE_Question || int $question object or ID |
218 | - * @return boolean if successful |
|
218 | + * @return EE_Base_Class if successful |
|
219 | 219 | */ |
220 | 220 | public function add_question($questionObjectOrID) |
221 | 221 | { |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * Removes the question from this question group |
228 | 228 | * |
229 | 229 | * @param EE_Question || int $question object or ID |
230 | - * @return boolean of success |
|
230 | + * @return EE_Base_Class of success |
|
231 | 231 | */ |
232 | 232 | public function remove_question($questionObjectOrID) |
233 | 233 | { |
@@ -12,280 +12,280 @@ |
||
12 | 12 | class EE_Question_Group extends EE_Soft_Delete_Base_Class |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @param array $props_n_values |
|
17 | - * @return EE_Question_Group|mixed |
|
18 | - */ |
|
19 | - public static function new_instance($props_n_values = array()) |
|
20 | - { |
|
21 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
22 | - return $has_object ? $has_object : new self($props_n_values); |
|
23 | - } |
|
24 | - |
|
25 | - |
|
26 | - /** |
|
27 | - * @param array $props_n_values |
|
28 | - * @return EE_Question_Group |
|
29 | - */ |
|
30 | - public static function new_instance_from_db($props_n_values = array()) |
|
31 | - { |
|
32 | - return new self($props_n_values, true); |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * gets the question group's name |
|
38 | - * |
|
39 | - * @access public |
|
40 | - * @param bool $pretty |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function name($pretty = false) |
|
44 | - { |
|
45 | - return $pretty ? $this->get_pretty('QSG_name') : $this->get('QSG_name'); |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * Gets the question group's internal name |
|
51 | - * |
|
52 | - * @access public |
|
53 | - * @return string |
|
54 | - */ |
|
55 | - public function identifier() |
|
56 | - { |
|
57 | - return $this->get('QSG_identifier'); |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * Gets the question group's description |
|
63 | - * |
|
64 | - * @access public |
|
65 | - * @param bool $pretty |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function desc($pretty = false) |
|
69 | - { |
|
70 | - return $pretty ? $this->get_pretty('QSG_desc') : $this->get('QSG_desc'); |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * Gets the question group's order number in a sequence |
|
76 | - * of other question groups |
|
77 | - * |
|
78 | - * @access public |
|
79 | - * @return int |
|
80 | - */ |
|
81 | - public function order() |
|
82 | - { |
|
83 | - return $this->get('QSG_order'); |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * Returns whether to show the group's name on the frontend |
|
89 | - * |
|
90 | - * @access public |
|
91 | - * @return boolean |
|
92 | - */ |
|
93 | - public function show_group_name() |
|
94 | - { |
|
95 | - return $this->get('QSG_show_group_name'); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * Returns whether to show the group's description |
|
101 | - * on the frontend |
|
102 | - * |
|
103 | - * @access public |
|
104 | - * @return boolean |
|
105 | - */ |
|
106 | - public function show_group_desc() |
|
107 | - { |
|
108 | - return $this->get('QSG_show_group_desc'); |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * Returns whether this is a 'system group' (meaning |
|
114 | - * a question group integral to the system, whose questions |
|
115 | - * relate to the attendee table) |
|
116 | - * |
|
117 | - * @access public |
|
118 | - * @return int |
|
119 | - */ |
|
120 | - public function system_group() |
|
121 | - { |
|
122 | - return $this->get('QSG_system'); |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * get the author of the question group. |
|
128 | - * |
|
129 | - * @since 4.5.0 |
|
130 | - * |
|
131 | - * @return int |
|
132 | - */ |
|
133 | - public function wp_user() |
|
134 | - { |
|
135 | - return $this->get('QSG_wp_user'); |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * Returns whether this question group has |
|
141 | - * been deleted |
|
142 | - * |
|
143 | - * @access public |
|
144 | - * @return boolean |
|
145 | - */ |
|
146 | - public function deleted() |
|
147 | - { |
|
148 | - return $this->get('QST_deleted'); |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * Gets an array of questions with questions IN the group at the start of the array and questions NOT in the group |
|
154 | - * at the end of the array. Questions in the group are ordered by Question_Group_Question.QGQ_order and questions |
|
155 | - * NOT in the group are ordered by Question.QGQ_order |
|
156 | - * |
|
157 | - * @return EE_Question[] |
|
158 | - */ |
|
159 | - public function questions_in_and_not_in_group() |
|
160 | - { |
|
161 | - $questions_in_group = $this->questions(); |
|
162 | - $exclude_question_ids = ! empty($questions_in_group) ? array_keys($questions_in_group) : array(); |
|
163 | - $questions_not_in_group = $this->questions_not_in_group($exclude_question_ids); |
|
164 | - return $questions_in_group + $questions_not_in_group; |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - /** |
|
169 | - * Gets all the questions which are part of this question group (ordered Question_Group_Question.QGQ_order) |
|
170 | - * |
|
171 | - * @param array $query_params |
|
172 | - * @return EE_Question[] |
|
173 | - */ |
|
174 | - public function questions($query_params = array()) |
|
175 | - { |
|
176 | - $query_params = ! empty($query_params) ? $query_params |
|
177 | - : array('order_by' => array('Question_Group_Question.QGQ_order' => 'ASC')); |
|
178 | - return $this->ID() ? $this->get_many_related('Question', $query_params) : array(); |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * Gets all the questions which are NOT part of this question group. |
|
184 | - * |
|
185 | - * @param mixed $question_IDS_in_group if empty array then all questions returned. if FALSE then we first get |
|
186 | - * questions in this group and exclude them from questions get all. IF empty |
|
187 | - * array then we just return all questions. |
|
188 | - * @return EE_Question[] |
|
189 | - */ |
|
190 | - public function questions_not_in_group($question_IDS_in_group = false) |
|
191 | - { |
|
192 | - if ($question_IDS_in_group === false) { |
|
193 | - $questions = $this->questions(); |
|
194 | - $question_IDS_in_group = ! empty($questions) ? array_keys($questions) : array(); |
|
195 | - } |
|
196 | - $_where = ! empty($question_IDS_in_group) ? array('QST_ID' => array('not_in', $question_IDS_in_group)) |
|
197 | - : array(); |
|
198 | - |
|
199 | - return EEM_Question::instance()->get_all(array($_where, 'order_by' => array('QST_ID' => 'ASC'))); |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * Gets all events which are related to this question group |
|
205 | - * |
|
206 | - * @return EE_Event[] |
|
207 | - */ |
|
208 | - public function events() |
|
209 | - { |
|
210 | - return $this->get_many_related('Event'); |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * Adds the question to this question group |
|
216 | - * |
|
217 | - * @param EE_Question || int $question object or ID |
|
218 | - * @return boolean if successful |
|
219 | - */ |
|
220 | - public function add_question($questionObjectOrID) |
|
221 | - { |
|
222 | - return $this->_add_relation_to($questionObjectOrID, 'Question'); |
|
223 | - } |
|
224 | - |
|
225 | - |
|
226 | - /** |
|
227 | - * Removes the question from this question group |
|
228 | - * |
|
229 | - * @param EE_Question || int $question object or ID |
|
230 | - * @return boolean of success |
|
231 | - */ |
|
232 | - public function remove_question($questionObjectOrID) |
|
233 | - { |
|
234 | - return $this->_remove_relation_to($questionObjectOrID, 'Question'); |
|
235 | - } |
|
236 | - |
|
237 | - |
|
238 | - /** |
|
239 | - * @param $questionObjectOrID |
|
240 | - * @param $qst_order |
|
241 | - * @return int |
|
242 | - */ |
|
243 | - public function update_question_order($questionObjectOrID, $qst_order) |
|
244 | - { |
|
245 | - $qst_ID = $questionObjectOrID instanceof EE_Question ? $questionObjectOrID->ID() : (int) $questionObjectOrID; |
|
246 | - return EEM_Question_Group_Question::instance()->update( |
|
247 | - array('QGQ_order' => $qst_order), |
|
248 | - array( |
|
249 | - array( |
|
250 | - 'QST_ID' => $qst_ID, |
|
251 | - 'QSG_ID' => $this->ID(), |
|
252 | - ), |
|
253 | - ) |
|
254 | - ); |
|
255 | - } |
|
256 | - |
|
257 | - |
|
258 | - /** |
|
259 | - * Basically this is method just returns whether the question group has any questions with answers. This is used |
|
260 | - * by the admin currently to determine whether we should display the ui for deleting permanently or not b/c |
|
261 | - * question groups with questions that have answers should not be possible to delete permanently |
|
262 | - * |
|
263 | - * @return boolean true if has questions with answers, false if not. |
|
264 | - */ |
|
265 | - public function has_questions_with_answers() |
|
266 | - { |
|
267 | - $has_answers = false; |
|
268 | - $questions = $this->get_many_related('Question'); |
|
269 | - foreach ($questions as $question) { |
|
270 | - if ($question->count_related('Answer') > 0) { |
|
271 | - $has_answers = true; |
|
272 | - } |
|
273 | - } |
|
274 | - return $has_answers; |
|
275 | - } |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * The purpose of this method is set the question group order for this question group to be the max out of all |
|
280 | - * question groups |
|
281 | - * |
|
282 | - * @access public |
|
283 | - * @return void |
|
284 | - */ |
|
285 | - public function set_order_to_latest() |
|
286 | - { |
|
287 | - $latest_order = $this->get_model()->get_latest_question_group_order(); |
|
288 | - $latest_order++; |
|
289 | - $this->set('QSG_order', $latest_order); |
|
290 | - } |
|
15 | + /** |
|
16 | + * @param array $props_n_values |
|
17 | + * @return EE_Question_Group|mixed |
|
18 | + */ |
|
19 | + public static function new_instance($props_n_values = array()) |
|
20 | + { |
|
21 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
22 | + return $has_object ? $has_object : new self($props_n_values); |
|
23 | + } |
|
24 | + |
|
25 | + |
|
26 | + /** |
|
27 | + * @param array $props_n_values |
|
28 | + * @return EE_Question_Group |
|
29 | + */ |
|
30 | + public static function new_instance_from_db($props_n_values = array()) |
|
31 | + { |
|
32 | + return new self($props_n_values, true); |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * gets the question group's name |
|
38 | + * |
|
39 | + * @access public |
|
40 | + * @param bool $pretty |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function name($pretty = false) |
|
44 | + { |
|
45 | + return $pretty ? $this->get_pretty('QSG_name') : $this->get('QSG_name'); |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * Gets the question group's internal name |
|
51 | + * |
|
52 | + * @access public |
|
53 | + * @return string |
|
54 | + */ |
|
55 | + public function identifier() |
|
56 | + { |
|
57 | + return $this->get('QSG_identifier'); |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * Gets the question group's description |
|
63 | + * |
|
64 | + * @access public |
|
65 | + * @param bool $pretty |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function desc($pretty = false) |
|
69 | + { |
|
70 | + return $pretty ? $this->get_pretty('QSG_desc') : $this->get('QSG_desc'); |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * Gets the question group's order number in a sequence |
|
76 | + * of other question groups |
|
77 | + * |
|
78 | + * @access public |
|
79 | + * @return int |
|
80 | + */ |
|
81 | + public function order() |
|
82 | + { |
|
83 | + return $this->get('QSG_order'); |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * Returns whether to show the group's name on the frontend |
|
89 | + * |
|
90 | + * @access public |
|
91 | + * @return boolean |
|
92 | + */ |
|
93 | + public function show_group_name() |
|
94 | + { |
|
95 | + return $this->get('QSG_show_group_name'); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * Returns whether to show the group's description |
|
101 | + * on the frontend |
|
102 | + * |
|
103 | + * @access public |
|
104 | + * @return boolean |
|
105 | + */ |
|
106 | + public function show_group_desc() |
|
107 | + { |
|
108 | + return $this->get('QSG_show_group_desc'); |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * Returns whether this is a 'system group' (meaning |
|
114 | + * a question group integral to the system, whose questions |
|
115 | + * relate to the attendee table) |
|
116 | + * |
|
117 | + * @access public |
|
118 | + * @return int |
|
119 | + */ |
|
120 | + public function system_group() |
|
121 | + { |
|
122 | + return $this->get('QSG_system'); |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * get the author of the question group. |
|
128 | + * |
|
129 | + * @since 4.5.0 |
|
130 | + * |
|
131 | + * @return int |
|
132 | + */ |
|
133 | + public function wp_user() |
|
134 | + { |
|
135 | + return $this->get('QSG_wp_user'); |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * Returns whether this question group has |
|
141 | + * been deleted |
|
142 | + * |
|
143 | + * @access public |
|
144 | + * @return boolean |
|
145 | + */ |
|
146 | + public function deleted() |
|
147 | + { |
|
148 | + return $this->get('QST_deleted'); |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * Gets an array of questions with questions IN the group at the start of the array and questions NOT in the group |
|
154 | + * at the end of the array. Questions in the group are ordered by Question_Group_Question.QGQ_order and questions |
|
155 | + * NOT in the group are ordered by Question.QGQ_order |
|
156 | + * |
|
157 | + * @return EE_Question[] |
|
158 | + */ |
|
159 | + public function questions_in_and_not_in_group() |
|
160 | + { |
|
161 | + $questions_in_group = $this->questions(); |
|
162 | + $exclude_question_ids = ! empty($questions_in_group) ? array_keys($questions_in_group) : array(); |
|
163 | + $questions_not_in_group = $this->questions_not_in_group($exclude_question_ids); |
|
164 | + return $questions_in_group + $questions_not_in_group; |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + /** |
|
169 | + * Gets all the questions which are part of this question group (ordered Question_Group_Question.QGQ_order) |
|
170 | + * |
|
171 | + * @param array $query_params |
|
172 | + * @return EE_Question[] |
|
173 | + */ |
|
174 | + public function questions($query_params = array()) |
|
175 | + { |
|
176 | + $query_params = ! empty($query_params) ? $query_params |
|
177 | + : array('order_by' => array('Question_Group_Question.QGQ_order' => 'ASC')); |
|
178 | + return $this->ID() ? $this->get_many_related('Question', $query_params) : array(); |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * Gets all the questions which are NOT part of this question group. |
|
184 | + * |
|
185 | + * @param mixed $question_IDS_in_group if empty array then all questions returned. if FALSE then we first get |
|
186 | + * questions in this group and exclude them from questions get all. IF empty |
|
187 | + * array then we just return all questions. |
|
188 | + * @return EE_Question[] |
|
189 | + */ |
|
190 | + public function questions_not_in_group($question_IDS_in_group = false) |
|
191 | + { |
|
192 | + if ($question_IDS_in_group === false) { |
|
193 | + $questions = $this->questions(); |
|
194 | + $question_IDS_in_group = ! empty($questions) ? array_keys($questions) : array(); |
|
195 | + } |
|
196 | + $_where = ! empty($question_IDS_in_group) ? array('QST_ID' => array('not_in', $question_IDS_in_group)) |
|
197 | + : array(); |
|
198 | + |
|
199 | + return EEM_Question::instance()->get_all(array($_where, 'order_by' => array('QST_ID' => 'ASC'))); |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * Gets all events which are related to this question group |
|
205 | + * |
|
206 | + * @return EE_Event[] |
|
207 | + */ |
|
208 | + public function events() |
|
209 | + { |
|
210 | + return $this->get_many_related('Event'); |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * Adds the question to this question group |
|
216 | + * |
|
217 | + * @param EE_Question || int $question object or ID |
|
218 | + * @return boolean if successful |
|
219 | + */ |
|
220 | + public function add_question($questionObjectOrID) |
|
221 | + { |
|
222 | + return $this->_add_relation_to($questionObjectOrID, 'Question'); |
|
223 | + } |
|
224 | + |
|
225 | + |
|
226 | + /** |
|
227 | + * Removes the question from this question group |
|
228 | + * |
|
229 | + * @param EE_Question || int $question object or ID |
|
230 | + * @return boolean of success |
|
231 | + */ |
|
232 | + public function remove_question($questionObjectOrID) |
|
233 | + { |
|
234 | + return $this->_remove_relation_to($questionObjectOrID, 'Question'); |
|
235 | + } |
|
236 | + |
|
237 | + |
|
238 | + /** |
|
239 | + * @param $questionObjectOrID |
|
240 | + * @param $qst_order |
|
241 | + * @return int |
|
242 | + */ |
|
243 | + public function update_question_order($questionObjectOrID, $qst_order) |
|
244 | + { |
|
245 | + $qst_ID = $questionObjectOrID instanceof EE_Question ? $questionObjectOrID->ID() : (int) $questionObjectOrID; |
|
246 | + return EEM_Question_Group_Question::instance()->update( |
|
247 | + array('QGQ_order' => $qst_order), |
|
248 | + array( |
|
249 | + array( |
|
250 | + 'QST_ID' => $qst_ID, |
|
251 | + 'QSG_ID' => $this->ID(), |
|
252 | + ), |
|
253 | + ) |
|
254 | + ); |
|
255 | + } |
|
256 | + |
|
257 | + |
|
258 | + /** |
|
259 | + * Basically this is method just returns whether the question group has any questions with answers. This is used |
|
260 | + * by the admin currently to determine whether we should display the ui for deleting permanently or not b/c |
|
261 | + * question groups with questions that have answers should not be possible to delete permanently |
|
262 | + * |
|
263 | + * @return boolean true if has questions with answers, false if not. |
|
264 | + */ |
|
265 | + public function has_questions_with_answers() |
|
266 | + { |
|
267 | + $has_answers = false; |
|
268 | + $questions = $this->get_many_related('Question'); |
|
269 | + foreach ($questions as $question) { |
|
270 | + if ($question->count_related('Answer') > 0) { |
|
271 | + $has_answers = true; |
|
272 | + } |
|
273 | + } |
|
274 | + return $has_answers; |
|
275 | + } |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * The purpose of this method is set the question group order for this question group to be the max out of all |
|
280 | + * question groups |
|
281 | + * |
|
282 | + * @access public |
|
283 | + * @return void |
|
284 | + */ |
|
285 | + public function set_order_to_latest() |
|
286 | + { |
|
287 | + $latest_order = $this->get_model()->get_latest_question_group_order(); |
|
288 | + $latest_order++; |
|
289 | + $this->set('QSG_order', $latest_order); |
|
290 | + } |
|
291 | 291 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param array $props_n_values incoming values from the database |
40 | 40 | * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
41 | 41 | * the website will be used. |
42 | - * @return EE_Attendee |
|
42 | + * @return EE_Question_Option |
|
43 | 43 | */ |
44 | 44 | public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
45 | 45 | { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * Sets the option's key value |
52 | 52 | * |
53 | 53 | * @param string $value |
54 | - * @return bool success |
|
54 | + * @return boolean|null success |
|
55 | 55 | */ |
56 | 56 | public function set_value($value) |
57 | 57 | { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * Sets the option's Display Text |
64 | 64 | * |
65 | 65 | * @param string $text |
66 | - * @return bool success |
|
66 | + * @return boolean|null success |
|
67 | 67 | */ |
68 | 68 | public function set_desc($text) |
69 | 69 | { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @access public |
78 | 78 | * @param integer $order |
79 | - * @return bool $success |
|
79 | + * @return boolean|null $success |
|
80 | 80 | */ |
81 | 81 | public function set_order($order) |
82 | 82 | { |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * Sets the ID of the related question |
89 | 89 | * |
90 | 90 | * @param int $question_ID |
91 | - * @return bool success |
|
91 | + * @return boolean|null success |
|
92 | 92 | */ |
93 | 93 | public function set_question_ID($question_ID) |
94 | 94 | { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * Sets the option's opt_group |
101 | 101 | * |
102 | 102 | * @param string $text |
103 | - * @return bool success |
|
103 | + * @return string success |
|
104 | 104 | */ |
105 | 105 | public function set_opt_group($text) |
106 | 106 | { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * Sets QSO_system |
221 | 221 | * |
222 | 222 | * @param string $QSO_system |
223 | - * @return bool |
|
223 | + * @return boolean|null |
|
224 | 224 | */ |
225 | 225 | public function set_system($QSO_system) |
226 | 226 | { |
@@ -10,220 +10,220 @@ |
||
10 | 10 | class EE_Question_Option extends EE_Soft_Delete_Base_Class implements EEI_Duplicatable |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * Question Option Opt Group Name |
|
15 | - * |
|
16 | - * @access protected |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - protected $_QSO_opt_group = null; |
|
20 | - |
|
21 | - |
|
22 | - /** |
|
23 | - * |
|
24 | - * @param array $props_n_values incoming values |
|
25 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
26 | - * used.) |
|
27 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
28 | - * date_format and the second value is the time format |
|
29 | - * @return EE_Attendee |
|
30 | - */ |
|
31 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
32 | - { |
|
33 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
34 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @param array $props_n_values incoming values from the database |
|
40 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
41 | - * the website will be used. |
|
42 | - * @return EE_Attendee |
|
43 | - */ |
|
44 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
45 | - { |
|
46 | - return new self($props_n_values, true, $timezone); |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * Sets the option's key value |
|
52 | - * |
|
53 | - * @param string $value |
|
54 | - * @return bool success |
|
55 | - */ |
|
56 | - public function set_value($value) |
|
57 | - { |
|
58 | - $this->set('QSO_value', $value); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * Sets the option's Display Text |
|
64 | - * |
|
65 | - * @param string $text |
|
66 | - * @return bool success |
|
67 | - */ |
|
68 | - public function set_desc($text) |
|
69 | - { |
|
70 | - $this->set('QSO_desc', $text); |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * Sets the order for this option |
|
76 | - * |
|
77 | - * @access public |
|
78 | - * @param integer $order |
|
79 | - * @return bool $success |
|
80 | - */ |
|
81 | - public function set_order($order) |
|
82 | - { |
|
83 | - $this->set('QSO_order', $order); |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * Sets the ID of the related question |
|
89 | - * |
|
90 | - * @param int $question_ID |
|
91 | - * @return bool success |
|
92 | - */ |
|
93 | - public function set_question_ID($question_ID) |
|
94 | - { |
|
95 | - $this->set('QST_ID', $question_ID); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * Sets the option's opt_group |
|
101 | - * |
|
102 | - * @param string $text |
|
103 | - * @return bool success |
|
104 | - */ |
|
105 | - public function set_opt_group($text) |
|
106 | - { |
|
107 | - return $this->_QSO_opt_group = $text; |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * Gets the option's key value |
|
113 | - * |
|
114 | - * @return string |
|
115 | - */ |
|
116 | - public function value() |
|
117 | - { |
|
118 | - return $this->get('QSO_value'); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * Gets the option's display text |
|
124 | - * |
|
125 | - * @return string |
|
126 | - */ |
|
127 | - public function desc() |
|
128 | - { |
|
129 | - return $this->get('QSO_desc'); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * Returns whether this option has been deleted or not |
|
135 | - * |
|
136 | - * @return boolean |
|
137 | - */ |
|
138 | - public function deleted() |
|
139 | - { |
|
140 | - return $this->get('QSO_deleted'); |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * Returns the order or the Question Option |
|
146 | - * |
|
147 | - * @access public |
|
148 | - * @return integer |
|
149 | - */ |
|
150 | - public function order() |
|
151 | - { |
|
152 | - return $this->get('QSO_option'); |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * Gets the related question's ID |
|
158 | - * |
|
159 | - * @return int |
|
160 | - */ |
|
161 | - public function question_ID() |
|
162 | - { |
|
163 | - return $this->get('QST_ID'); |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * Returns the question related to this question option |
|
169 | - * |
|
170 | - * @return EE_Question |
|
171 | - */ |
|
172 | - public function question() |
|
173 | - { |
|
174 | - return $this->get_first_related('Question'); |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * Gets the option's opt_group |
|
180 | - * |
|
181 | - * @return string |
|
182 | - */ |
|
183 | - public function opt_group() |
|
184 | - { |
|
185 | - return $this->_QSO_opt_group; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Duplicates this question option. By default the new question option will be for the same question, |
|
190 | - * but that can be overriden by setting the 'QST_ID' option |
|
191 | - * |
|
192 | - * @param array $options { |
|
193 | - * @type int $QST_ID the QST_ID attribute of this question option, otherwise it will be for the same question |
|
194 | - * as the original |
|
195 | - */ |
|
196 | - public function duplicate($options = array()) |
|
197 | - { |
|
198 | - $new_question_option = clone $this; |
|
199 | - $new_question_option->set('QSO_ID', null); |
|
200 | - if (array_key_exists( |
|
201 | - 'QST_ID', |
|
202 | - $options |
|
203 | - )) {// use array_key_exists instead of isset because NULL might be a valid value |
|
204 | - $new_question_option->set_question_ID($options['QST_ID']); |
|
205 | - } |
|
206 | - $new_question_option->save(); |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * Gets the QSO_system value |
|
211 | - * |
|
212 | - * @return string|null |
|
213 | - */ |
|
214 | - public function system() |
|
215 | - { |
|
216 | - return $this->get('QSO_system'); |
|
217 | - } |
|
218 | - |
|
219 | - /** |
|
220 | - * Sets QSO_system |
|
221 | - * |
|
222 | - * @param string $QSO_system |
|
223 | - * @return bool |
|
224 | - */ |
|
225 | - public function set_system($QSO_system) |
|
226 | - { |
|
227 | - return $this->set('QSO_system', $QSO_system); |
|
228 | - } |
|
13 | + /** |
|
14 | + * Question Option Opt Group Name |
|
15 | + * |
|
16 | + * @access protected |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + protected $_QSO_opt_group = null; |
|
20 | + |
|
21 | + |
|
22 | + /** |
|
23 | + * |
|
24 | + * @param array $props_n_values incoming values |
|
25 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
26 | + * used.) |
|
27 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
28 | + * date_format and the second value is the time format |
|
29 | + * @return EE_Attendee |
|
30 | + */ |
|
31 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
32 | + { |
|
33 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
34 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @param array $props_n_values incoming values from the database |
|
40 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
41 | + * the website will be used. |
|
42 | + * @return EE_Attendee |
|
43 | + */ |
|
44 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
45 | + { |
|
46 | + return new self($props_n_values, true, $timezone); |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * Sets the option's key value |
|
52 | + * |
|
53 | + * @param string $value |
|
54 | + * @return bool success |
|
55 | + */ |
|
56 | + public function set_value($value) |
|
57 | + { |
|
58 | + $this->set('QSO_value', $value); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * Sets the option's Display Text |
|
64 | + * |
|
65 | + * @param string $text |
|
66 | + * @return bool success |
|
67 | + */ |
|
68 | + public function set_desc($text) |
|
69 | + { |
|
70 | + $this->set('QSO_desc', $text); |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * Sets the order for this option |
|
76 | + * |
|
77 | + * @access public |
|
78 | + * @param integer $order |
|
79 | + * @return bool $success |
|
80 | + */ |
|
81 | + public function set_order($order) |
|
82 | + { |
|
83 | + $this->set('QSO_order', $order); |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * Sets the ID of the related question |
|
89 | + * |
|
90 | + * @param int $question_ID |
|
91 | + * @return bool success |
|
92 | + */ |
|
93 | + public function set_question_ID($question_ID) |
|
94 | + { |
|
95 | + $this->set('QST_ID', $question_ID); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * Sets the option's opt_group |
|
101 | + * |
|
102 | + * @param string $text |
|
103 | + * @return bool success |
|
104 | + */ |
|
105 | + public function set_opt_group($text) |
|
106 | + { |
|
107 | + return $this->_QSO_opt_group = $text; |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * Gets the option's key value |
|
113 | + * |
|
114 | + * @return string |
|
115 | + */ |
|
116 | + public function value() |
|
117 | + { |
|
118 | + return $this->get('QSO_value'); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * Gets the option's display text |
|
124 | + * |
|
125 | + * @return string |
|
126 | + */ |
|
127 | + public function desc() |
|
128 | + { |
|
129 | + return $this->get('QSO_desc'); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * Returns whether this option has been deleted or not |
|
135 | + * |
|
136 | + * @return boolean |
|
137 | + */ |
|
138 | + public function deleted() |
|
139 | + { |
|
140 | + return $this->get('QSO_deleted'); |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * Returns the order or the Question Option |
|
146 | + * |
|
147 | + * @access public |
|
148 | + * @return integer |
|
149 | + */ |
|
150 | + public function order() |
|
151 | + { |
|
152 | + return $this->get('QSO_option'); |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * Gets the related question's ID |
|
158 | + * |
|
159 | + * @return int |
|
160 | + */ |
|
161 | + public function question_ID() |
|
162 | + { |
|
163 | + return $this->get('QST_ID'); |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * Returns the question related to this question option |
|
169 | + * |
|
170 | + * @return EE_Question |
|
171 | + */ |
|
172 | + public function question() |
|
173 | + { |
|
174 | + return $this->get_first_related('Question'); |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * Gets the option's opt_group |
|
180 | + * |
|
181 | + * @return string |
|
182 | + */ |
|
183 | + public function opt_group() |
|
184 | + { |
|
185 | + return $this->_QSO_opt_group; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Duplicates this question option. By default the new question option will be for the same question, |
|
190 | + * but that can be overriden by setting the 'QST_ID' option |
|
191 | + * |
|
192 | + * @param array $options { |
|
193 | + * @type int $QST_ID the QST_ID attribute of this question option, otherwise it will be for the same question |
|
194 | + * as the original |
|
195 | + */ |
|
196 | + public function duplicate($options = array()) |
|
197 | + { |
|
198 | + $new_question_option = clone $this; |
|
199 | + $new_question_option->set('QSO_ID', null); |
|
200 | + if (array_key_exists( |
|
201 | + 'QST_ID', |
|
202 | + $options |
|
203 | + )) {// use array_key_exists instead of isset because NULL might be a valid value |
|
204 | + $new_question_option->set_question_ID($options['QST_ID']); |
|
205 | + } |
|
206 | + $new_question_option->save(); |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * Gets the QSO_system value |
|
211 | + * |
|
212 | + * @return string|null |
|
213 | + */ |
|
214 | + public function system() |
|
215 | + { |
|
216 | + return $this->get('QSO_system'); |
|
217 | + } |
|
218 | + |
|
219 | + /** |
|
220 | + * Sets QSO_system |
|
221 | + * |
|
222 | + * @param string $QSO_system |
|
223 | + * @return bool |
|
224 | + */ |
|
225 | + public function set_system($QSO_system) |
|
226 | + { |
|
227 | + return $this->set('QSO_system', $QSO_system); |
|
228 | + } |
|
229 | 229 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * Sets code |
53 | 53 | * |
54 | 54 | * @param string $code |
55 | - * @return boolean |
|
55 | + * @return boolean|null |
|
56 | 56 | */ |
57 | 57 | public function set_code($code) |
58 | 58 | { |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * Sets desc |
76 | 76 | * |
77 | 77 | * @param string $desc |
78 | - * @return boolean |
|
78 | + * @return boolean|null |
|
79 | 79 | */ |
80 | 80 | public function set_desc($desc) |
81 | 81 | { |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * Sets type |
99 | 99 | * |
100 | 100 | * @param string $type |
101 | - * @return boolean |
|
101 | + * @return boolean|null |
|
102 | 102 | */ |
103 | 103 | public function set_type($type) |
104 | 104 | { |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * Sets can_edit |
122 | 122 | * |
123 | 123 | * @param boolean $can_edit |
124 | - * @return boolean |
|
124 | + * @return boolean|null |
|
125 | 125 | */ |
126 | 126 | public function set_can_edit($can_edit) |
127 | 127 | { |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * Sets open |
145 | 145 | * |
146 | 146 | * @param boolean $open |
147 | - * @return boolean |
|
147 | + * @return boolean|null |
|
148 | 148 | */ |
149 | 149 | public function set_open($open) |
150 | 150 | { |
@@ -12,142 +12,142 @@ |
||
12 | 12 | class EE_Status extends EE_Base_Class |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @param array $props_n_values |
|
17 | - * @return EE_Status |
|
18 | - */ |
|
19 | - public static function new_instance($props_n_values = array()) |
|
20 | - { |
|
21 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
22 | - return $has_object ? $has_object : new self($props_n_values); |
|
23 | - } |
|
24 | - |
|
25 | - |
|
26 | - /** |
|
27 | - * @param array $props_n_values |
|
28 | - * @return EE_Status |
|
29 | - */ |
|
30 | - public static function new_instance_from_db($props_n_values = array()) |
|
31 | - { |
|
32 | - return new self($props_n_values, true); |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * Gets code |
|
38 | - * |
|
39 | - * @param bool $plural |
|
40 | - * @param string $schema |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function code($plural = false, $schema = 'upper') |
|
44 | - { |
|
45 | - $id = $this->get('STS_ID'); |
|
46 | - $code = EEM_Status::instance()->localized_status(array($id => $this->get('STS_code')), $plural, $schema); |
|
47 | - return $code[ $id ]; |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * Sets code |
|
53 | - * |
|
54 | - * @param string $code |
|
55 | - * @return boolean |
|
56 | - */ |
|
57 | - public function set_code($code) |
|
58 | - { |
|
59 | - $this->set('STS_code', $code); |
|
60 | - } |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * Gets desc |
|
65 | - * |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function desc() |
|
69 | - { |
|
70 | - return $this->get('STS_desc'); |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * Sets desc |
|
76 | - * |
|
77 | - * @param string $desc |
|
78 | - * @return boolean |
|
79 | - */ |
|
80 | - public function set_desc($desc) |
|
81 | - { |
|
82 | - $this->set('STS_desc', $desc); |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * Gets type |
|
88 | - * |
|
89 | - * @return string |
|
90 | - */ |
|
91 | - public function type() |
|
92 | - { |
|
93 | - return $this->get('STS_type'); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * Sets type |
|
99 | - * |
|
100 | - * @param string $type |
|
101 | - * @return boolean |
|
102 | - */ |
|
103 | - public function set_type($type) |
|
104 | - { |
|
105 | - $this->set('STS_type', $type); |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * Gets can_edit |
|
111 | - * |
|
112 | - * @return boolean |
|
113 | - */ |
|
114 | - public function can_edit() |
|
115 | - { |
|
116 | - return $this->get('STS_can_edit'); |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - /** |
|
121 | - * Sets can_edit |
|
122 | - * |
|
123 | - * @param boolean $can_edit |
|
124 | - * @return boolean |
|
125 | - */ |
|
126 | - public function set_can_edit($can_edit) |
|
127 | - { |
|
128 | - $this->set('STS_can_edit', $can_edit); |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * Gets open |
|
134 | - * |
|
135 | - * @return boolean |
|
136 | - */ |
|
137 | - public function open() |
|
138 | - { |
|
139 | - return $this->get('STS_open'); |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * Sets open |
|
145 | - * |
|
146 | - * @param boolean $open |
|
147 | - * @return boolean |
|
148 | - */ |
|
149 | - public function set_open($open) |
|
150 | - { |
|
151 | - $this->set('STS_open', $open); |
|
152 | - } |
|
15 | + /** |
|
16 | + * @param array $props_n_values |
|
17 | + * @return EE_Status |
|
18 | + */ |
|
19 | + public static function new_instance($props_n_values = array()) |
|
20 | + { |
|
21 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
22 | + return $has_object ? $has_object : new self($props_n_values); |
|
23 | + } |
|
24 | + |
|
25 | + |
|
26 | + /** |
|
27 | + * @param array $props_n_values |
|
28 | + * @return EE_Status |
|
29 | + */ |
|
30 | + public static function new_instance_from_db($props_n_values = array()) |
|
31 | + { |
|
32 | + return new self($props_n_values, true); |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * Gets code |
|
38 | + * |
|
39 | + * @param bool $plural |
|
40 | + * @param string $schema |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function code($plural = false, $schema = 'upper') |
|
44 | + { |
|
45 | + $id = $this->get('STS_ID'); |
|
46 | + $code = EEM_Status::instance()->localized_status(array($id => $this->get('STS_code')), $plural, $schema); |
|
47 | + return $code[ $id ]; |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * Sets code |
|
53 | + * |
|
54 | + * @param string $code |
|
55 | + * @return boolean |
|
56 | + */ |
|
57 | + public function set_code($code) |
|
58 | + { |
|
59 | + $this->set('STS_code', $code); |
|
60 | + } |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * Gets desc |
|
65 | + * |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function desc() |
|
69 | + { |
|
70 | + return $this->get('STS_desc'); |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * Sets desc |
|
76 | + * |
|
77 | + * @param string $desc |
|
78 | + * @return boolean |
|
79 | + */ |
|
80 | + public function set_desc($desc) |
|
81 | + { |
|
82 | + $this->set('STS_desc', $desc); |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * Gets type |
|
88 | + * |
|
89 | + * @return string |
|
90 | + */ |
|
91 | + public function type() |
|
92 | + { |
|
93 | + return $this->get('STS_type'); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * Sets type |
|
99 | + * |
|
100 | + * @param string $type |
|
101 | + * @return boolean |
|
102 | + */ |
|
103 | + public function set_type($type) |
|
104 | + { |
|
105 | + $this->set('STS_type', $type); |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * Gets can_edit |
|
111 | + * |
|
112 | + * @return boolean |
|
113 | + */ |
|
114 | + public function can_edit() |
|
115 | + { |
|
116 | + return $this->get('STS_can_edit'); |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + /** |
|
121 | + * Sets can_edit |
|
122 | + * |
|
123 | + * @param boolean $can_edit |
|
124 | + * @return boolean |
|
125 | + */ |
|
126 | + public function set_can_edit($can_edit) |
|
127 | + { |
|
128 | + $this->set('STS_can_edit', $can_edit); |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * Gets open |
|
134 | + * |
|
135 | + * @return boolean |
|
136 | + */ |
|
137 | + public function open() |
|
138 | + { |
|
139 | + return $this->get('STS_open'); |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * Sets open |
|
145 | + * |
|
146 | + * @param boolean $open |
|
147 | + * @return boolean |
|
148 | + */ |
|
149 | + public function set_open($open) |
|
150 | + { |
|
151 | + $this->set('STS_open', $open); |
|
152 | + } |
|
153 | 153 | } |
@@ -44,7 +44,7 @@ |
||
44 | 44 | { |
45 | 45 | $id = $this->get('STS_ID'); |
46 | 46 | $code = EEM_Status::instance()->localized_status(array($id => $this->get('STS_code')), $plural, $schema); |
47 | - return $code[ $id ]; |
|
47 | + return $code[$id]; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * Sets name |
67 | 67 | * |
68 | 68 | * @param string $name |
69 | - * @return boolean |
|
69 | + * @return boolean|null |
|
70 | 70 | */ |
71 | 71 | public function set_name($name) |
72 | 72 | { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * Sets slug |
90 | 90 | * |
91 | 91 | * @param string $slug |
92 | - * @return boolean |
|
92 | + * @return boolean|null |
|
93 | 93 | */ |
94 | 94 | public function set_slug($slug) |
95 | 95 | { |
@@ -12,87 +12,87 @@ |
||
12 | 12 | class EE_Term extends EE_Base_Class |
13 | 13 | { |
14 | 14 | |
15 | - public $post_type; |
|
15 | + public $post_type; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Sets some dynamic defaults |
|
19 | - * |
|
20 | - * @param array $fieldValues |
|
21 | - * @param bool $bydb |
|
22 | - * @param string $timezone |
|
23 | - */ |
|
24 | - protected function __construct($fieldValues = array(), $bydb = false, $timezone = '') |
|
25 | - { |
|
26 | - if (! isset($fieldValues['slug'])) { |
|
27 | - $fieldValues['slug'] = $fieldValues['name']; |
|
28 | - } |
|
29 | - parent::__construct($fieldValues, $bydb, $timezone); |
|
30 | - } |
|
17 | + /** |
|
18 | + * Sets some dynamic defaults |
|
19 | + * |
|
20 | + * @param array $fieldValues |
|
21 | + * @param bool $bydb |
|
22 | + * @param string $timezone |
|
23 | + */ |
|
24 | + protected function __construct($fieldValues = array(), $bydb = false, $timezone = '') |
|
25 | + { |
|
26 | + if (! isset($fieldValues['slug'])) { |
|
27 | + $fieldValues['slug'] = $fieldValues['name']; |
|
28 | + } |
|
29 | + parent::__construct($fieldValues, $bydb, $timezone); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @param array $props_n_values |
|
35 | - * @return EE_Term|mixed |
|
36 | - */ |
|
37 | - public static function new_instance($props_n_values = array()) |
|
38 | - { |
|
39 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
40 | - return $has_object ? $has_object : new self($props_n_values); |
|
41 | - } |
|
33 | + /** |
|
34 | + * @param array $props_n_values |
|
35 | + * @return EE_Term|mixed |
|
36 | + */ |
|
37 | + public static function new_instance($props_n_values = array()) |
|
38 | + { |
|
39 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
40 | + return $has_object ? $has_object : new self($props_n_values); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @param array $props_n_values |
|
46 | - * @return EE_Term |
|
47 | - */ |
|
48 | - public static function new_instance_from_db($props_n_values = array()) |
|
49 | - { |
|
50 | - return new self($props_n_values, true); |
|
51 | - } |
|
44 | + /** |
|
45 | + * @param array $props_n_values |
|
46 | + * @return EE_Term |
|
47 | + */ |
|
48 | + public static function new_instance_from_db($props_n_values = array()) |
|
49 | + { |
|
50 | + return new self($props_n_values, true); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * Gets name |
|
56 | - * |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - public function name() |
|
60 | - { |
|
61 | - return $this->get('name'); |
|
62 | - } |
|
54 | + /** |
|
55 | + * Gets name |
|
56 | + * |
|
57 | + * @return string |
|
58 | + */ |
|
59 | + public function name() |
|
60 | + { |
|
61 | + return $this->get('name'); |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * Sets name |
|
67 | - * |
|
68 | - * @param string $name |
|
69 | - * @return boolean |
|
70 | - */ |
|
71 | - public function set_name($name) |
|
72 | - { |
|
73 | - $this->set('name', $name); |
|
74 | - } |
|
65 | + /** |
|
66 | + * Sets name |
|
67 | + * |
|
68 | + * @param string $name |
|
69 | + * @return boolean |
|
70 | + */ |
|
71 | + public function set_name($name) |
|
72 | + { |
|
73 | + $this->set('name', $name); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * Gets slug |
|
79 | - * |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - public function slug() |
|
83 | - { |
|
84 | - return $this->get('slug'); |
|
85 | - } |
|
77 | + /** |
|
78 | + * Gets slug |
|
79 | + * |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + public function slug() |
|
83 | + { |
|
84 | + return $this->get('slug'); |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | - /** |
|
89 | - * Sets slug |
|
90 | - * |
|
91 | - * @param string $slug |
|
92 | - * @return boolean |
|
93 | - */ |
|
94 | - public function set_slug($slug) |
|
95 | - { |
|
96 | - $this->set('slug', $slug); |
|
97 | - } |
|
88 | + /** |
|
89 | + * Sets slug |
|
90 | + * |
|
91 | + * @param string $slug |
|
92 | + * @return boolean |
|
93 | + */ |
|
94 | + public function set_slug($slug) |
|
95 | + { |
|
96 | + $this->set('slug', $slug); |
|
97 | + } |
|
98 | 98 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | protected function __construct($fieldValues = array(), $bydb = false, $timezone = '') |
25 | 25 | { |
26 | - if (! isset($fieldValues['slug'])) { |
|
26 | + if ( ! isset($fieldValues['slug'])) { |
|
27 | 27 | $fieldValues['slug'] = $fieldValues['name']; |
28 | 28 | } |
29 | 29 | parent::__construct($fieldValues, $bydb, $timezone); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * Sets taxonomy |
48 | 48 | * |
49 | 49 | * @param string $taxonomy |
50 | - * @return boolean |
|
50 | + * @return boolean|null |
|
51 | 51 | */ |
52 | 52 | public function set_taxonomy($taxonomy) |
53 | 53 | { |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * Sets term_count |
71 | 71 | * |
72 | 72 | * @param int $term_count |
73 | - * @return boolean |
|
73 | + * @return boolean|null |
|
74 | 74 | */ |
75 | 75 | public function set_count($term_count) |
76 | 76 | { |
@@ -11,80 +11,80 @@ |
||
11 | 11 | class EE_Term_Taxonomy extends EE_Base_Class |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @param array $props_n_values |
|
16 | - * @return EE_Term_Taxonomy |
|
17 | - */ |
|
18 | - public static function new_instance($props_n_values = array()) |
|
19 | - { |
|
20 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
21 | - return $has_object ? $has_object : new self($props_n_values); |
|
22 | - } |
|
14 | + /** |
|
15 | + * @param array $props_n_values |
|
16 | + * @return EE_Term_Taxonomy |
|
17 | + */ |
|
18 | + public static function new_instance($props_n_values = array()) |
|
19 | + { |
|
20 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
21 | + return $has_object ? $has_object : new self($props_n_values); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * @param array $props_n_values |
|
27 | - * @return EE_Term_Taxonomy |
|
28 | - */ |
|
29 | - public static function new_instance_from_db($props_n_values = array()) |
|
30 | - { |
|
31 | - return new self($props_n_values, true); |
|
32 | - } |
|
25 | + /** |
|
26 | + * @param array $props_n_values |
|
27 | + * @return EE_Term_Taxonomy |
|
28 | + */ |
|
29 | + public static function new_instance_from_db($props_n_values = array()) |
|
30 | + { |
|
31 | + return new self($props_n_values, true); |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Gets taxonomy |
|
37 | - * |
|
38 | - * @return string |
|
39 | - */ |
|
40 | - public function taxonomy() |
|
41 | - { |
|
42 | - return $this->get('taxonomy'); |
|
43 | - } |
|
35 | + /** |
|
36 | + * Gets taxonomy |
|
37 | + * |
|
38 | + * @return string |
|
39 | + */ |
|
40 | + public function taxonomy() |
|
41 | + { |
|
42 | + return $this->get('taxonomy'); |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * Sets taxonomy |
|
48 | - * |
|
49 | - * @param string $taxonomy |
|
50 | - * @return boolean |
|
51 | - */ |
|
52 | - public function set_taxonomy($taxonomy) |
|
53 | - { |
|
54 | - $this->set('taxonomy', $taxonomy); |
|
55 | - } |
|
46 | + /** |
|
47 | + * Sets taxonomy |
|
48 | + * |
|
49 | + * @param string $taxonomy |
|
50 | + * @return boolean |
|
51 | + */ |
|
52 | + public function set_taxonomy($taxonomy) |
|
53 | + { |
|
54 | + $this->set('taxonomy', $taxonomy); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * Gets term_count |
|
60 | - * |
|
61 | - * @return int |
|
62 | - */ |
|
63 | - public function count() |
|
64 | - { |
|
65 | - return $this->get('term_count'); |
|
66 | - } |
|
58 | + /** |
|
59 | + * Gets term_count |
|
60 | + * |
|
61 | + * @return int |
|
62 | + */ |
|
63 | + public function count() |
|
64 | + { |
|
65 | + return $this->get('term_count'); |
|
66 | + } |
|
67 | 67 | |
68 | 68 | |
69 | - /** |
|
70 | - * Sets term_count |
|
71 | - * |
|
72 | - * @param int $term_count |
|
73 | - * @return boolean |
|
74 | - */ |
|
75 | - public function set_count($term_count) |
|
76 | - { |
|
77 | - $this->set('term_count', $term_count); |
|
78 | - } |
|
69 | + /** |
|
70 | + * Sets term_count |
|
71 | + * |
|
72 | + * @param int $term_count |
|
73 | + * @return boolean |
|
74 | + */ |
|
75 | + public function set_count($term_count) |
|
76 | + { |
|
77 | + $this->set('term_count', $term_count); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * Gets the term for this term taxonomy |
|
83 | - * |
|
84 | - * @return EE_Term |
|
85 | - */ |
|
86 | - public function term() |
|
87 | - { |
|
88 | - return $this->get_first_related('Term'); |
|
89 | - } |
|
81 | + /** |
|
82 | + * Gets the term for this term taxonomy |
|
83 | + * |
|
84 | + * @return EE_Term |
|
85 | + */ |
|
86 | + public function term() |
|
87 | + { |
|
88 | + return $this->get_first_related('Term'); |
|
89 | + } |
|
90 | 90 | } |
@@ -30,7 +30,7 @@ |
||
30 | 30 | * @param array $props_n_values incoming values from the database |
31 | 31 | * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
32 | 32 | * the website will be used. |
33 | - * @return EE_Attendee |
|
33 | + * @return EE_Venue |
|
34 | 34 | */ |
35 | 35 | public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
36 | 36 | { |
@@ -10,564 +10,564 @@ |
||
10 | 10 | class EE_Venue extends EE_CPT_Base implements EEI_Address |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * |
|
15 | - * @param array $props_n_values incoming values |
|
16 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
17 | - * used.) |
|
18 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
19 | - * date_format and the second value is the time format |
|
20 | - * @return EE_Attendee |
|
21 | - */ |
|
22 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
23 | - { |
|
24 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
25 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
26 | - } |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * @param array $props_n_values incoming values from the database |
|
31 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
32 | - * the website will be used. |
|
33 | - * @return EE_Attendee |
|
34 | - */ |
|
35 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
36 | - { |
|
37 | - return new self($props_n_values, true, $timezone); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * Gets name |
|
43 | - * |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - public function name() |
|
47 | - { |
|
48 | - return $this->get('VNU_name'); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * Gets phone |
|
54 | - * |
|
55 | - * @return string |
|
56 | - */ |
|
57 | - public function phone() |
|
58 | - { |
|
59 | - return $this->get('VNU_phone'); |
|
60 | - } |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * venue_url |
|
65 | - * |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function venue_url() |
|
69 | - { |
|
70 | - return $this->get('VNU_url'); |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * Gets desc |
|
76 | - * |
|
77 | - * @return string |
|
78 | - */ |
|
79 | - public function description() |
|
80 | - { |
|
81 | - return $this->get('VNU_desc'); |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * Gets short description (AKA: the excerpt) |
|
87 | - * |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function excerpt() |
|
91 | - { |
|
92 | - return $this->get('VNU_short_desc'); |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * Gets identifier |
|
98 | - * |
|
99 | - * @return string |
|
100 | - */ |
|
101 | - public function identifier() |
|
102 | - { |
|
103 | - return $this->get('VNU_identifier'); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * Gets address |
|
109 | - * |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function address() |
|
113 | - { |
|
114 | - return $this->get('VNU_address'); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * Gets address2 |
|
120 | - * |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function address2() |
|
124 | - { |
|
125 | - return $this->get('VNU_address2'); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * Gets city |
|
131 | - * |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public function city() |
|
135 | - { |
|
136 | - return $this->get('VNU_city'); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Gets state |
|
141 | - * |
|
142 | - * @return int |
|
143 | - */ |
|
144 | - public function state_ID() |
|
145 | - { |
|
146 | - return $this->get('STA_ID'); |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * @return string |
|
152 | - */ |
|
153 | - public function state_abbrev() |
|
154 | - { |
|
155 | - return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * @return string |
|
161 | - */ |
|
162 | - public function state_name() |
|
163 | - { |
|
164 | - return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : ''; |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - /** |
|
169 | - * Gets the state for this venue |
|
170 | - * |
|
171 | - * @return EE_State |
|
172 | - */ |
|
173 | - public function state_obj() |
|
174 | - { |
|
175 | - return $this->get_first_related('State'); |
|
176 | - } |
|
177 | - |
|
178 | - |
|
179 | - /** |
|
180 | - * either displays the state abbreviation or the state name, as determined |
|
181 | - * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
182 | - * defaults to abbreviation |
|
183 | - * |
|
184 | - * @return string |
|
185 | - */ |
|
186 | - public function state() |
|
187 | - { |
|
188 | - if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
189 | - return $this->state_abbrev(); |
|
190 | - } else { |
|
191 | - return $this->state_name(); |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - /** |
|
197 | - * country_ID |
|
198 | - * |
|
199 | - * @return string |
|
200 | - */ |
|
201 | - public function country_ID() |
|
202 | - { |
|
203 | - return $this->get('CNT_ISO'); |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * @return string |
|
209 | - */ |
|
210 | - public function country_name() |
|
211 | - { |
|
212 | - return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : ''; |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - /** |
|
217 | - * Gets the country of this venue |
|
218 | - * |
|
219 | - * @return EE_Country |
|
220 | - */ |
|
221 | - public function country_obj() |
|
222 | - { |
|
223 | - return $this->get_first_related('Country'); |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - /** |
|
228 | - * either displays the country ISO2 code or the country name, as determined |
|
229 | - * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
230 | - * defaults to abbreviation |
|
231 | - * |
|
232 | - * @return string |
|
233 | - */ |
|
234 | - public function country() |
|
235 | - { |
|
236 | - if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
237 | - return $this->country_ID(); |
|
238 | - } else { |
|
239 | - return $this->country_name(); |
|
240 | - } |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - /** |
|
245 | - * Gets zip |
|
246 | - * |
|
247 | - * @return string |
|
248 | - */ |
|
249 | - public function zip() |
|
250 | - { |
|
251 | - return $this->get('VNU_zip'); |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * Gets capacity |
|
257 | - * |
|
258 | - * @return int |
|
259 | - */ |
|
260 | - public function capacity() |
|
261 | - { |
|
262 | - return $this->get_pretty('VNU_capacity', 'symbol'); |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * Gets created |
|
268 | - * |
|
269 | - * @return string |
|
270 | - */ |
|
271 | - public function created() |
|
272 | - { |
|
273 | - return $this->get('VNU_created'); |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - /** |
|
278 | - * Gets modified |
|
279 | - * |
|
280 | - * @return string |
|
281 | - */ |
|
282 | - public function modified() |
|
283 | - { |
|
284 | - return $this->get('VNU_modified'); |
|
285 | - } |
|
286 | - |
|
287 | - |
|
288 | - /** |
|
289 | - * Gets order |
|
290 | - * |
|
291 | - * @return int |
|
292 | - */ |
|
293 | - public function order() |
|
294 | - { |
|
295 | - return $this->get('VNU_order'); |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * Gets wp_user |
|
301 | - * |
|
302 | - * @return int |
|
303 | - */ |
|
304 | - public function wp_user() |
|
305 | - { |
|
306 | - return $this->get('VNU_wp_user'); |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - /** |
|
311 | - * @return string |
|
312 | - */ |
|
313 | - public function virtual_phone() |
|
314 | - { |
|
315 | - return $this->get('VNU_virtual_phone'); |
|
316 | - } |
|
317 | - |
|
318 | - |
|
319 | - /** |
|
320 | - * @return string |
|
321 | - */ |
|
322 | - public function virtual_url() |
|
323 | - { |
|
324 | - return $this->get('VNU_virtual_url'); |
|
325 | - } |
|
326 | - |
|
327 | - |
|
328 | - /** |
|
329 | - * @return bool |
|
330 | - */ |
|
331 | - public function enable_for_gmap() |
|
332 | - { |
|
333 | - return $this->get('VNU_enable_for_gmap'); |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - /** |
|
338 | - * @return string |
|
339 | - */ |
|
340 | - public function google_map_link() |
|
341 | - { |
|
342 | - return $this->get('VNU_google_map_link'); |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * Gets all events happening at this venue. Query parameters can be added to |
|
348 | - * fetch a subset of those events. |
|
349 | - * |
|
350 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
351 | - * @param bool $upcoming |
|
352 | - * @return EE_Event[] |
|
353 | - */ |
|
354 | - public function events($query_params = array(), $upcoming = false) |
|
355 | - { |
|
356 | - if ($upcoming) { |
|
357 | - $query_params = array( |
|
358 | - array( |
|
359 | - 'status' => 'publish', |
|
360 | - 'Datetime.DTT_EVT_start' => array( |
|
361 | - '>', |
|
362 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
363 | - ), |
|
364 | - ), |
|
365 | - ); |
|
366 | - } |
|
367 | - return $this->get_many_related('Event', $query_params); |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * Sets address |
|
373 | - */ |
|
374 | - public function set_address($address = '') |
|
375 | - { |
|
376 | - $this->set('VNU_address', $address); |
|
377 | - } |
|
378 | - |
|
379 | - |
|
380 | - /** |
|
381 | - * @param string $address2 |
|
382 | - */ |
|
383 | - public function set_address2($address2 = '') |
|
384 | - { |
|
385 | - $this->set('VNU_address2', $address2); |
|
386 | - } |
|
387 | - |
|
388 | - |
|
389 | - /** |
|
390 | - * @param string $city |
|
391 | - */ |
|
392 | - public function set_city($city = '') |
|
393 | - { |
|
394 | - $this->set('VNU_city', $city); |
|
395 | - } |
|
396 | - |
|
397 | - |
|
398 | - /** |
|
399 | - * @param int $state |
|
400 | - */ |
|
401 | - public function set_state_ID($state = 0) |
|
402 | - { |
|
403 | - $this->set('STA_ID', $state); |
|
404 | - } |
|
405 | - |
|
406 | - |
|
407 | - /** |
|
408 | - * Sets the state, given either a state id or state object |
|
409 | - * |
|
410 | - * @param EE_State /int $state_id_or_obj |
|
411 | - * @return EE_State |
|
412 | - */ |
|
413 | - public function set_state_obj($state_id_or_obj) |
|
414 | - { |
|
415 | - return $this->_add_relation_to($state_id_or_obj, 'State'); |
|
416 | - } |
|
417 | - |
|
418 | - |
|
419 | - /** |
|
420 | - * @param int $country_ID |
|
421 | - */ |
|
422 | - public function set_country_ID($country_ID = 0) |
|
423 | - { |
|
424 | - $this->set('CNT_ISO', $country_ID); |
|
425 | - } |
|
426 | - |
|
427 | - |
|
428 | - /** |
|
429 | - * Sets the country on the venue |
|
430 | - * |
|
431 | - * @param EE_Country /string $country_id_or_obj |
|
432 | - * @return EE_Country |
|
433 | - */ |
|
434 | - public function set_country_obj($country_id_or_obj) |
|
435 | - { |
|
436 | - return $this->_add_relation_to($country_id_or_obj, 'Country'); |
|
437 | - } |
|
438 | - |
|
439 | - |
|
440 | - /** |
|
441 | - * @param string $zip |
|
442 | - */ |
|
443 | - public function set_zip($zip = '') |
|
444 | - { |
|
445 | - $this->set('VNU_zip', $zip); |
|
446 | - } |
|
447 | - |
|
448 | - |
|
449 | - /** |
|
450 | - * @param int $capacity |
|
451 | - */ |
|
452 | - public function set_capacity($capacity = 0) |
|
453 | - { |
|
454 | - $this->set('VNU_capacity', $capacity); |
|
455 | - } |
|
456 | - |
|
457 | - |
|
458 | - /** |
|
459 | - * @param string $created |
|
460 | - */ |
|
461 | - public function set_created($created = '') |
|
462 | - { |
|
463 | - $this->set('VNU_created', $created); |
|
464 | - } |
|
465 | - |
|
466 | - |
|
467 | - /** |
|
468 | - * @param string $desc |
|
469 | - */ |
|
470 | - public function set_description($desc = '') |
|
471 | - { |
|
472 | - $this->set('VNU_desc', $desc); |
|
473 | - } |
|
474 | - |
|
475 | - |
|
476 | - /** |
|
477 | - * @param string $identifier |
|
478 | - */ |
|
479 | - public function set_identifier($identifier = '') |
|
480 | - { |
|
481 | - $this->set('VNU_identifier', $identifier); |
|
482 | - } |
|
483 | - |
|
484 | - |
|
485 | - /** |
|
486 | - * @param string $modified |
|
487 | - */ |
|
488 | - public function set_modified($modified = '') |
|
489 | - { |
|
490 | - $this->set('VNU_modified', $modified); |
|
491 | - } |
|
492 | - |
|
493 | - |
|
494 | - /** |
|
495 | - * @param string $name |
|
496 | - */ |
|
497 | - public function set_name($name = '') |
|
498 | - { |
|
499 | - $this->set('VNU_name', $name); |
|
500 | - } |
|
501 | - |
|
502 | - |
|
503 | - /** |
|
504 | - * @param int $order |
|
505 | - */ |
|
506 | - public function set_order($order = 0) |
|
507 | - { |
|
508 | - $this->set('VNU_order', $order); |
|
509 | - } |
|
510 | - |
|
511 | - |
|
512 | - /** |
|
513 | - * @param string $phone |
|
514 | - */ |
|
515 | - public function set_phone($phone = '') |
|
516 | - { |
|
517 | - $this->set('VNU_phone', $phone); |
|
518 | - } |
|
519 | - |
|
520 | - |
|
521 | - /** |
|
522 | - * @param int $wp_user |
|
523 | - */ |
|
524 | - public function set_wp_user($wp_user = 1) |
|
525 | - { |
|
526 | - $this->set('VNU_wp_user', $wp_user); |
|
527 | - } |
|
528 | - |
|
529 | - |
|
530 | - /** |
|
531 | - * @param string $url |
|
532 | - */ |
|
533 | - public function set_venue_url($url = '') |
|
534 | - { |
|
535 | - $this->set('VNU_url', $url); |
|
536 | - } |
|
537 | - |
|
538 | - |
|
539 | - /** |
|
540 | - * @param string $phone |
|
541 | - */ |
|
542 | - public function set_virtual_phone($phone = '') |
|
543 | - { |
|
544 | - $this->set('VNU_virtual_phone', $phone); |
|
545 | - } |
|
546 | - |
|
547 | - |
|
548 | - /** |
|
549 | - * @param string $url |
|
550 | - */ |
|
551 | - public function set_virtual_url($url = '') |
|
552 | - { |
|
553 | - $this->set('VNU_virtual_url', $url); |
|
554 | - } |
|
555 | - |
|
556 | - |
|
557 | - /** |
|
558 | - * @param string $enable |
|
559 | - */ |
|
560 | - public function set_enable_for_gmap($enable = '') |
|
561 | - { |
|
562 | - $this->set('VNU_enable_for_gmap', $enable); |
|
563 | - } |
|
564 | - |
|
565 | - |
|
566 | - /** |
|
567 | - * @param string $google_map_link |
|
568 | - */ |
|
569 | - public function set_google_map_link($google_map_link = '') |
|
570 | - { |
|
571 | - $this->set('VNU_google_map_link', $google_map_link); |
|
572 | - } |
|
13 | + /** |
|
14 | + * |
|
15 | + * @param array $props_n_values incoming values |
|
16 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
17 | + * used.) |
|
18 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
19 | + * date_format and the second value is the time format |
|
20 | + * @return EE_Attendee |
|
21 | + */ |
|
22 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
23 | + { |
|
24 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
25 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
26 | + } |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * @param array $props_n_values incoming values from the database |
|
31 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
32 | + * the website will be used. |
|
33 | + * @return EE_Attendee |
|
34 | + */ |
|
35 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
36 | + { |
|
37 | + return new self($props_n_values, true, $timezone); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * Gets name |
|
43 | + * |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + public function name() |
|
47 | + { |
|
48 | + return $this->get('VNU_name'); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * Gets phone |
|
54 | + * |
|
55 | + * @return string |
|
56 | + */ |
|
57 | + public function phone() |
|
58 | + { |
|
59 | + return $this->get('VNU_phone'); |
|
60 | + } |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * venue_url |
|
65 | + * |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function venue_url() |
|
69 | + { |
|
70 | + return $this->get('VNU_url'); |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * Gets desc |
|
76 | + * |
|
77 | + * @return string |
|
78 | + */ |
|
79 | + public function description() |
|
80 | + { |
|
81 | + return $this->get('VNU_desc'); |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * Gets short description (AKA: the excerpt) |
|
87 | + * |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function excerpt() |
|
91 | + { |
|
92 | + return $this->get('VNU_short_desc'); |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * Gets identifier |
|
98 | + * |
|
99 | + * @return string |
|
100 | + */ |
|
101 | + public function identifier() |
|
102 | + { |
|
103 | + return $this->get('VNU_identifier'); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * Gets address |
|
109 | + * |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function address() |
|
113 | + { |
|
114 | + return $this->get('VNU_address'); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * Gets address2 |
|
120 | + * |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function address2() |
|
124 | + { |
|
125 | + return $this->get('VNU_address2'); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * Gets city |
|
131 | + * |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public function city() |
|
135 | + { |
|
136 | + return $this->get('VNU_city'); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Gets state |
|
141 | + * |
|
142 | + * @return int |
|
143 | + */ |
|
144 | + public function state_ID() |
|
145 | + { |
|
146 | + return $this->get('STA_ID'); |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * @return string |
|
152 | + */ |
|
153 | + public function state_abbrev() |
|
154 | + { |
|
155 | + return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * @return string |
|
161 | + */ |
|
162 | + public function state_name() |
|
163 | + { |
|
164 | + return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : ''; |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + /** |
|
169 | + * Gets the state for this venue |
|
170 | + * |
|
171 | + * @return EE_State |
|
172 | + */ |
|
173 | + public function state_obj() |
|
174 | + { |
|
175 | + return $this->get_first_related('State'); |
|
176 | + } |
|
177 | + |
|
178 | + |
|
179 | + /** |
|
180 | + * either displays the state abbreviation or the state name, as determined |
|
181 | + * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
182 | + * defaults to abbreviation |
|
183 | + * |
|
184 | + * @return string |
|
185 | + */ |
|
186 | + public function state() |
|
187 | + { |
|
188 | + if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
189 | + return $this->state_abbrev(); |
|
190 | + } else { |
|
191 | + return $this->state_name(); |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + /** |
|
197 | + * country_ID |
|
198 | + * |
|
199 | + * @return string |
|
200 | + */ |
|
201 | + public function country_ID() |
|
202 | + { |
|
203 | + return $this->get('CNT_ISO'); |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * @return string |
|
209 | + */ |
|
210 | + public function country_name() |
|
211 | + { |
|
212 | + return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : ''; |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + /** |
|
217 | + * Gets the country of this venue |
|
218 | + * |
|
219 | + * @return EE_Country |
|
220 | + */ |
|
221 | + public function country_obj() |
|
222 | + { |
|
223 | + return $this->get_first_related('Country'); |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + /** |
|
228 | + * either displays the country ISO2 code or the country name, as determined |
|
229 | + * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
230 | + * defaults to abbreviation |
|
231 | + * |
|
232 | + * @return string |
|
233 | + */ |
|
234 | + public function country() |
|
235 | + { |
|
236 | + if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
237 | + return $this->country_ID(); |
|
238 | + } else { |
|
239 | + return $this->country_name(); |
|
240 | + } |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + /** |
|
245 | + * Gets zip |
|
246 | + * |
|
247 | + * @return string |
|
248 | + */ |
|
249 | + public function zip() |
|
250 | + { |
|
251 | + return $this->get('VNU_zip'); |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * Gets capacity |
|
257 | + * |
|
258 | + * @return int |
|
259 | + */ |
|
260 | + public function capacity() |
|
261 | + { |
|
262 | + return $this->get_pretty('VNU_capacity', 'symbol'); |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * Gets created |
|
268 | + * |
|
269 | + * @return string |
|
270 | + */ |
|
271 | + public function created() |
|
272 | + { |
|
273 | + return $this->get('VNU_created'); |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + /** |
|
278 | + * Gets modified |
|
279 | + * |
|
280 | + * @return string |
|
281 | + */ |
|
282 | + public function modified() |
|
283 | + { |
|
284 | + return $this->get('VNU_modified'); |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + /** |
|
289 | + * Gets order |
|
290 | + * |
|
291 | + * @return int |
|
292 | + */ |
|
293 | + public function order() |
|
294 | + { |
|
295 | + return $this->get('VNU_order'); |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * Gets wp_user |
|
301 | + * |
|
302 | + * @return int |
|
303 | + */ |
|
304 | + public function wp_user() |
|
305 | + { |
|
306 | + return $this->get('VNU_wp_user'); |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * @return string |
|
312 | + */ |
|
313 | + public function virtual_phone() |
|
314 | + { |
|
315 | + return $this->get('VNU_virtual_phone'); |
|
316 | + } |
|
317 | + |
|
318 | + |
|
319 | + /** |
|
320 | + * @return string |
|
321 | + */ |
|
322 | + public function virtual_url() |
|
323 | + { |
|
324 | + return $this->get('VNU_virtual_url'); |
|
325 | + } |
|
326 | + |
|
327 | + |
|
328 | + /** |
|
329 | + * @return bool |
|
330 | + */ |
|
331 | + public function enable_for_gmap() |
|
332 | + { |
|
333 | + return $this->get('VNU_enable_for_gmap'); |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + /** |
|
338 | + * @return string |
|
339 | + */ |
|
340 | + public function google_map_link() |
|
341 | + { |
|
342 | + return $this->get('VNU_google_map_link'); |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * Gets all events happening at this venue. Query parameters can be added to |
|
348 | + * fetch a subset of those events. |
|
349 | + * |
|
350 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
351 | + * @param bool $upcoming |
|
352 | + * @return EE_Event[] |
|
353 | + */ |
|
354 | + public function events($query_params = array(), $upcoming = false) |
|
355 | + { |
|
356 | + if ($upcoming) { |
|
357 | + $query_params = array( |
|
358 | + array( |
|
359 | + 'status' => 'publish', |
|
360 | + 'Datetime.DTT_EVT_start' => array( |
|
361 | + '>', |
|
362 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
363 | + ), |
|
364 | + ), |
|
365 | + ); |
|
366 | + } |
|
367 | + return $this->get_many_related('Event', $query_params); |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * Sets address |
|
373 | + */ |
|
374 | + public function set_address($address = '') |
|
375 | + { |
|
376 | + $this->set('VNU_address', $address); |
|
377 | + } |
|
378 | + |
|
379 | + |
|
380 | + /** |
|
381 | + * @param string $address2 |
|
382 | + */ |
|
383 | + public function set_address2($address2 = '') |
|
384 | + { |
|
385 | + $this->set('VNU_address2', $address2); |
|
386 | + } |
|
387 | + |
|
388 | + |
|
389 | + /** |
|
390 | + * @param string $city |
|
391 | + */ |
|
392 | + public function set_city($city = '') |
|
393 | + { |
|
394 | + $this->set('VNU_city', $city); |
|
395 | + } |
|
396 | + |
|
397 | + |
|
398 | + /** |
|
399 | + * @param int $state |
|
400 | + */ |
|
401 | + public function set_state_ID($state = 0) |
|
402 | + { |
|
403 | + $this->set('STA_ID', $state); |
|
404 | + } |
|
405 | + |
|
406 | + |
|
407 | + /** |
|
408 | + * Sets the state, given either a state id or state object |
|
409 | + * |
|
410 | + * @param EE_State /int $state_id_or_obj |
|
411 | + * @return EE_State |
|
412 | + */ |
|
413 | + public function set_state_obj($state_id_or_obj) |
|
414 | + { |
|
415 | + return $this->_add_relation_to($state_id_or_obj, 'State'); |
|
416 | + } |
|
417 | + |
|
418 | + |
|
419 | + /** |
|
420 | + * @param int $country_ID |
|
421 | + */ |
|
422 | + public function set_country_ID($country_ID = 0) |
|
423 | + { |
|
424 | + $this->set('CNT_ISO', $country_ID); |
|
425 | + } |
|
426 | + |
|
427 | + |
|
428 | + /** |
|
429 | + * Sets the country on the venue |
|
430 | + * |
|
431 | + * @param EE_Country /string $country_id_or_obj |
|
432 | + * @return EE_Country |
|
433 | + */ |
|
434 | + public function set_country_obj($country_id_or_obj) |
|
435 | + { |
|
436 | + return $this->_add_relation_to($country_id_or_obj, 'Country'); |
|
437 | + } |
|
438 | + |
|
439 | + |
|
440 | + /** |
|
441 | + * @param string $zip |
|
442 | + */ |
|
443 | + public function set_zip($zip = '') |
|
444 | + { |
|
445 | + $this->set('VNU_zip', $zip); |
|
446 | + } |
|
447 | + |
|
448 | + |
|
449 | + /** |
|
450 | + * @param int $capacity |
|
451 | + */ |
|
452 | + public function set_capacity($capacity = 0) |
|
453 | + { |
|
454 | + $this->set('VNU_capacity', $capacity); |
|
455 | + } |
|
456 | + |
|
457 | + |
|
458 | + /** |
|
459 | + * @param string $created |
|
460 | + */ |
|
461 | + public function set_created($created = '') |
|
462 | + { |
|
463 | + $this->set('VNU_created', $created); |
|
464 | + } |
|
465 | + |
|
466 | + |
|
467 | + /** |
|
468 | + * @param string $desc |
|
469 | + */ |
|
470 | + public function set_description($desc = '') |
|
471 | + { |
|
472 | + $this->set('VNU_desc', $desc); |
|
473 | + } |
|
474 | + |
|
475 | + |
|
476 | + /** |
|
477 | + * @param string $identifier |
|
478 | + */ |
|
479 | + public function set_identifier($identifier = '') |
|
480 | + { |
|
481 | + $this->set('VNU_identifier', $identifier); |
|
482 | + } |
|
483 | + |
|
484 | + |
|
485 | + /** |
|
486 | + * @param string $modified |
|
487 | + */ |
|
488 | + public function set_modified($modified = '') |
|
489 | + { |
|
490 | + $this->set('VNU_modified', $modified); |
|
491 | + } |
|
492 | + |
|
493 | + |
|
494 | + /** |
|
495 | + * @param string $name |
|
496 | + */ |
|
497 | + public function set_name($name = '') |
|
498 | + { |
|
499 | + $this->set('VNU_name', $name); |
|
500 | + } |
|
501 | + |
|
502 | + |
|
503 | + /** |
|
504 | + * @param int $order |
|
505 | + */ |
|
506 | + public function set_order($order = 0) |
|
507 | + { |
|
508 | + $this->set('VNU_order', $order); |
|
509 | + } |
|
510 | + |
|
511 | + |
|
512 | + /** |
|
513 | + * @param string $phone |
|
514 | + */ |
|
515 | + public function set_phone($phone = '') |
|
516 | + { |
|
517 | + $this->set('VNU_phone', $phone); |
|
518 | + } |
|
519 | + |
|
520 | + |
|
521 | + /** |
|
522 | + * @param int $wp_user |
|
523 | + */ |
|
524 | + public function set_wp_user($wp_user = 1) |
|
525 | + { |
|
526 | + $this->set('VNU_wp_user', $wp_user); |
|
527 | + } |
|
528 | + |
|
529 | + |
|
530 | + /** |
|
531 | + * @param string $url |
|
532 | + */ |
|
533 | + public function set_venue_url($url = '') |
|
534 | + { |
|
535 | + $this->set('VNU_url', $url); |
|
536 | + } |
|
537 | + |
|
538 | + |
|
539 | + /** |
|
540 | + * @param string $phone |
|
541 | + */ |
|
542 | + public function set_virtual_phone($phone = '') |
|
543 | + { |
|
544 | + $this->set('VNU_virtual_phone', $phone); |
|
545 | + } |
|
546 | + |
|
547 | + |
|
548 | + /** |
|
549 | + * @param string $url |
|
550 | + */ |
|
551 | + public function set_virtual_url($url = '') |
|
552 | + { |
|
553 | + $this->set('VNU_virtual_url', $url); |
|
554 | + } |
|
555 | + |
|
556 | + |
|
557 | + /** |
|
558 | + * @param string $enable |
|
559 | + */ |
|
560 | + public function set_enable_for_gmap($enable = '') |
|
561 | + { |
|
562 | + $this->set('VNU_enable_for_gmap', $enable); |
|
563 | + } |
|
564 | + |
|
565 | + |
|
566 | + /** |
|
567 | + * @param string $google_map_link |
|
568 | + */ |
|
569 | + public function set_google_map_link($google_map_link = '') |
|
570 | + { |
|
571 | + $this->set('VNU_google_map_link', $google_map_link); |
|
572 | + } |
|
573 | 573 | } |