Completed
Branch BUG/11252/payment-method-regis... (ef7b02)
by
unknown
52:18 queued 38:58
created
core/domain/entities/contexts/Context.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -17,64 +17,64 @@
 block discarded – undo
17 17
 class Context implements ContextInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @var string $slug
22
-     */
23
-    private $slug;
24
-
25
-    /**
26
-     * @var string $description
27
-     */
28
-    private $description;
29
-
30
-
31
-    /**
32
-     * Context constructor.
33
-     *
34
-     * @param string $slug
35
-     * @param string $description
36
-     */
37
-    public function __construct($slug, $description)
38
-    {
39
-        $this->setSlug($slug);
40
-        $this->setDescription($description);
41
-    }
42
-
43
-
44
-    /**
45
-     * @return string
46
-     */
47
-    public function slug()
48
-    {
49
-        return $this->slug;
50
-    }
51
-
52
-
53
-    /**
54
-     * @param string $slug
55
-     */
56
-    private function setSlug($slug)
57
-    {
58
-        $this->slug = sanitize_key($slug);
59
-    }
60
-
61
-
62
-    /**
63
-     * @return string
64
-     */
65
-    public function description()
66
-    {
67
-        return $this->description;
68
-    }
69
-
70
-
71
-    /**
72
-     * @param string $description
73
-     */
74
-    private function setDescription($description)
75
-    {
76
-        $this->description = sanitize_text_field($description);
77
-    }
20
+	/**
21
+	 * @var string $slug
22
+	 */
23
+	private $slug;
24
+
25
+	/**
26
+	 * @var string $description
27
+	 */
28
+	private $description;
29
+
30
+
31
+	/**
32
+	 * Context constructor.
33
+	 *
34
+	 * @param string $slug
35
+	 * @param string $description
36
+	 */
37
+	public function __construct($slug, $description)
38
+	{
39
+		$this->setSlug($slug);
40
+		$this->setDescription($description);
41
+	}
42
+
43
+
44
+	/**
45
+	 * @return string
46
+	 */
47
+	public function slug()
48
+	{
49
+		return $this->slug;
50
+	}
51
+
52
+
53
+	/**
54
+	 * @param string $slug
55
+	 */
56
+	private function setSlug($slug)
57
+	{
58
+		$this->slug = sanitize_key($slug);
59
+	}
60
+
61
+
62
+	/**
63
+	 * @return string
64
+	 */
65
+	public function description()
66
+	{
67
+		return $this->description;
68
+	}
69
+
70
+
71
+	/**
72
+	 * @param string $description
73
+	 */
74
+	private function setDescription($description)
75
+	{
76
+		$this->description = sanitize_text_field($description);
77
+	}
78 78
 
79 79
 }
80 80
 // Location: Context.php
Please login to merge, or discard this patch.
core/db_models/EEM_Question.model.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
      * Gets an array for converting between QST_system and QST_IDs for system questions. Eg, if you want to know
365 365
      * which system question QST_ID corresponds to the QST_system 'city', use EEM_Question::instance()->get_Question_ID_from_system_string('city');
366 366
      * @param $QST_system
367
-     * @return int of QST_ID for the question that corresponds to that QST_system
367
+     * @return string of QST_ID for the question that corresponds to that QST_system
368 368
      */
369 369
     public function get_Question_ID_from_system_string($QST_system)
370 370
     {
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 
426 426
 
427 427
     /**
428
-     * @return array
428
+     * @return EEM_Question
429 429
      */
430 430
     public function question_descriptions()
431 431
     {
Please login to merge, or discard this patch.
Indentation   +401 added lines, -401 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (!defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 require_once(EE_MODELS . 'EEM_Soft_Delete_Base.model.php');
5 5
 require_once(EE_CLASSES . 'EE_Question.class.php');
@@ -16,406 +16,406 @@  discard block
 block discarded – undo
16 16
 class EEM_Question extends EEM_Soft_Delete_Base
17 17
 {
18 18
 
19
-    // constant used to indicate that the question type is COUNTRY
20
-    const QST_type_country = 'COUNTRY';
21
-
22
-    // constant used to indicate that the question type is DATE
23
-    const QST_type_date = 'DATE';
24
-
25
-    // constant used to indicate that the question type is DROPDOWN
26
-    const QST_type_dropdown = 'DROPDOWN';
27
-
28
-    // constant used to indicate that the question type is CHECKBOX
29
-    const QST_type_checkbox = 'CHECKBOX';
30
-
31
-    // constant used to indicate that the question type is RADIO_BTN
32
-    const QST_type_radio = 'RADIO_BTN';
33
-
34
-    // constant used to indicate that the question type is STATE
35
-    const QST_type_state = 'STATE';
36
-
37
-    // constant used to indicate that the question type is TEXT
38
-    const QST_type_text = 'TEXT';
39
-
40
-    // constant used to indicate that the question type is TEXTAREA
41
-    const QST_type_textarea = 'TEXTAREA';
42
-
43
-    // constant used to indicate that the question type is a TEXTAREA that allows simple html
44
-    const QST_type_html_textarea = 'HTML_TEXTAREA';
45
-
46
-    // constant used to indicate that the question type is an email input
47
-    const QST_type_email = 'EMAIL';
48
-
49
-    // constant used to indicate that the question type is a US-formatted phone number
50
-    const QST_type_us_phone = 'US_PHONE';
51
-
52
-    // constant used to indicate that the question type is an integer (whole number)
53
-    const QST_type_int = 'INTEGER';
54
-
55
-    // constant used to indicate that the question type is a decimal (float)
56
-    const QST_type_decimal = 'DECIMAL';
57
-
58
-    // constant used to indicate that the question type is a valid URL
59
-    const QST_type_url = 'URL';
60
-
61
-    // constant used to indicate that the question type is a YEAR
62
-    const QST_type_year = 'YEAR';
63
-
64
-    // constant used to indicate that the question type is a multi-select
65
-    const QST_type_multi_select = 'MULTI_SELECT';
66
-
67
-    /**
68
-     * Question types that are interchangeable, even after answers have been provided for them.
69
-     * Top-level keys are category slugs, next level is an array of question types. If question types
70
-     * aren't in this array, it is assumed they AREN'T interchangeable with any other question types.
71
-     *
72
-     * @access protected
73
-     * @var array $_question_type_categories {
74
-     * @type string $text
75
-     * @type string $single -answer-enum
76
-     * @type string $multi -answer-enum
77
-     *                    }
78
-     */
79
-    protected $_question_type_categories = array();
80
-
81
-    /**
82
-     * lists all the question types which should be allowed. Ideally, this will be extensible.
83
-     *
84
-     * @access protected
85
-     * @var array $_allowed_question_types
86
-     */
87
-    protected $_allowed_question_types = array();
88
-
89
-    /**
90
-     * brief descriptions for all the question types
91
-     *
92
-     * @access protected
93
-     * @var EEM_Question $_instance
94
-     */
95
-    protected $_question_descriptions;
96
-
97
-
98
-    // private instance of the Attendee object
99
-    protected static $_instance = NULL;
100
-
101
-
102
-    /**
103
-     * EEM_Question constructor.
104
-     *
105
-     * @param null $timezone
106
-     */
107
-    protected function __construct($timezone = NULL)
108
-    {
109
-        $this->singular_item = __('Question', 'event_espresso');
110
-        $this->plural_item = __('Questions', 'event_espresso');
111
-        $this->_allowed_question_types = apply_filters(
112
-            'FHEE__EEM_Question__construct__allowed_question_types',
113
-            array(
114
-                EEM_Question::QST_type_text => __('Text', 'event_espresso'),
115
-                EEM_Question::QST_type_textarea => __('Textarea', 'event_espresso'),
116
-                EEM_Question::QST_type_checkbox => __('Checkboxes', 'event_espresso'),
117
-                EEM_Question::QST_type_radio => __('Radio Buttons', 'event_espresso'),
118
-                EEM_Question::QST_type_dropdown => __('Dropdown', 'event_espresso'),
119
-                EEM_Question::QST_type_state => __('State/Province Dropdown', 'event_espresso'),
120
-                EEM_Question::QST_type_country => __('Country Dropdown', 'event_espresso'),
121
-                EEM_Question::QST_type_date => __('Date Picker', 'event_espresso'),
122
-                EEM_Question::QST_type_html_textarea => __('HTML Textarea', 'event_espresso'),
123
-                EEM_Question::QST_type_email => __('Email', 'event_espresso'),
124
-                EEM_Question::QST_type_us_phone => __('USA - Format Phone', 'event_espresso'),
125
-                EEM_Question::QST_type_decimal => __('Number', 'event_espresso'),
126
-                EEM_Question::QST_type_int => __('Whole Number', 'event_espresso'),
127
-                EEM_Question::QST_type_url => __('URL', 'event_espresso'),
128
-                EEM_Question::QST_type_year => __('Year', 'event_espresso'),
129
-                EEM_Question::QST_type_multi_select => __('Multi Select', 'event_espresso')
130
-            )
131
-        );
132
-        $this->_question_descriptions = apply_filters(
133
-            'FHEE__EEM_Question__construct__allowed_question_types',
134
-            array(
135
-                EEM_Question::QST_type_text => __('A single line text input field', 'event_espresso'),
136
-                EEM_Question::QST_type_textarea => __('A multi line text input field', 'event_espresso'),
137
-                EEM_Question::QST_type_checkbox => __('Allows multiple preset options to be selected', 'event_espresso'),
138
-                EEM_Question::QST_type_radio => __('Allows a single preset option to be selected', 'event_espresso'),
139
-                EEM_Question::QST_type_dropdown => __('A dropdown that allows a single selection', 'event_espresso'),
140
-                EEM_Question::QST_type_state => __('A dropdown that lists states/provinces', 'event_espresso'),
141
-                EEM_Question::QST_type_country => __('A dropdown that lists countries', 'event_espresso'),
142
-                EEM_Question::QST_type_date => __('A popup calendar that allows date selections', 'event_espresso'),
143
-                EEM_Question::QST_type_html_textarea => __('A multi line text input field that allows HTML', 'event_espresso'),
144
-                EEM_Question::QST_type_email => __('A text field that must contain a valid Email address', 'event_espresso'),
145
-                EEM_Question::QST_type_us_phone => __('A text field that must contain a valid US phone number', 'event_espresso'),
146
-                EEM_Question::QST_type_decimal => __('A text field that allows number values with decimals', 'event_espresso'),
147
-                EEM_Question::QST_type_int => __('A text field that only allows whole numbers (no decimals)', 'event_espresso'),
148
-                EEM_Question::QST_type_url => __('A text field that must contain a valid URL', 'event_espresso'),
149
-                EEM_Question::QST_type_year => __('A dropdown that lists the last 100 years', 'event_espresso'),
150
-                EEM_Question::QST_type_multi_select => __('A dropdown that allows multiple selections', 'event_espresso')
151
-            )
152
-        );
153
-        $this->_question_type_categories = (array)apply_filters(
154
-            'FHEE__EEM_Question__construct__question_type_categories',
155
-            array(
156
-                'text' => array(
157
-                    EEM_Question::QST_type_text,
158
-                    EEM_Question::QST_type_textarea,
159
-                    EEM_Question::QST_type_date,
160
-                    EEM_Question::QST_type_html_textarea,
161
-                    EEM_Question::QST_type_email,
162
-                    EEM_Question::QST_type_us_phone,
163
-                    EEM_Question::QST_type_decimal,
164
-                    EEM_Question::QST_type_int,
165
-                    EEM_Question::QST_type_url,
166
-                    EEM_Question::QST_type_year
167
-                ),
168
-                'single-answer-enum' => array(
169
-                    EEM_Question::QST_type_radio,
170
-                    EEM_Question::QST_type_dropdown
171
-                ),
172
-                'multi-answer-enum' => array(
173
-                    EEM_Question::QST_type_checkbox,
174
-                    EEM_Question::QST_type_multi_select
175
-                )
176
-            )
177
-        );
178
-
179
-        $this->_tables = array(
180
-            'Question' => new EE_Primary_Table('esp_question', 'QST_ID')
181
-        );
182
-        $this->_fields = array(
183
-            'Question' => array(
184
-                'QST_ID' => new EE_Primary_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso')),
185
-                'QST_display_text' => new EE_Post_Content_Field('QST_display_text', __('Question Text', 'event_espresso'), true, ''),
186
-                'QST_admin_label' => new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)', 'event_espresso'), true, ''),
187
-                'QST_system' => new EE_Plain_Text_Field('QST_system', __('Internal string ID for question', 'event_espresso'), false, ''),
188
-                'QST_type' => new EE_Enum_Text_Field('QST_type', __('Question Type', 'event_espresso'), false, 'TEXT', $this->_allowed_question_types),
189
-                'QST_required' => new EE_Boolean_Field('QST_required', __('Required Question?', 'event_espresso'), false, false),
190
-                'QST_required_text' => new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided', 'event_espresso'), true, ''),
191
-                'QST_order' => new EE_Integer_Field('QST_order', __('Question Order', 'event_espresso'), false, 0),
192
-                'QST_admin_only' => new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?', 'event_espresso'), false, false),
193
-                'QST_max' => new EE_Infinite_Integer_Field('QST_max', __('Max Size', 'event_espresso'), false, EE_INF),
194
-                'QST_wp_user' => new EE_WP_User_Field('QST_wp_user', __('Question Creator ID', 'event_espresso'), false),
195
-                'QST_deleted' => new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted', 'event_espresso'), false, false)
196
-            )
197
-        );
198
-        $this->_model_relations = array(
199
-            'Question_Group' => new EE_HABTM_Relation('Question_Group_Question'),
200
-            'Question_Option' => new EE_Has_Many_Relation(),
201
-            'Answer' => new EE_Has_Many_Relation(),
202
-            'WP_User' => new EE_Belongs_To_Relation(),
203
-            //for QST_order column
204
-            'Question_Group_Question' => new EE_Has_Many_Relation()
205
-        );
206
-        //this model is generally available for reading
207
-        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
208
-        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('QST_system');
209
-        $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('QST_system');
210
-        $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('QST_system');
211
-        parent::__construct($timezone);
212
-    }
213
-
214
-    /**
215
-     * Returns the list of allowed question types, which are normally: 'TEXT','TEXTAREA','RADIO_BTN','DROPDOWN','CHECKBOX','DATE'
216
-     * but they can be extended
217
-     * @return string[]
218
-     */
219
-    public function allowed_question_types()
220
-    {
221
-        return $this->_allowed_question_types;
222
-    }
223
-
224
-    /**
225
-     * Gets all the question types in the same category
226
-     * @param string $question_type one of EEM_Question::allowed_question_types(
227
-     * @return string[] like EEM_Question::allowed_question_types()
228
-     */
229
-    public function question_types_in_same_category($question_type)
230
-    {
231
-        $question_types = array($question_type);
232
-        foreach ($this->_question_type_categories as $category => $question_types_in_category) {
233
-            if (in_array($question_type, $question_types_in_category)) {
234
-                $question_types = $question_types_in_category;
235
-                break;
236
-            }
237
-        }
238
-
239
-        return array_intersect_key($this->allowed_question_types(), array_flip($question_types));
240
-    }
241
-
242
-    /**
243
-     * Determines if the given question type is in the given question type category
244
-     * @param string $question_type one of EEM_Question::allowed_question_types()
245
-     * @param string $category one of the top-level keys of EEM_Question::question_type_categories()
246
-     * @return boolean
247
-     */
248
-    public function question_type_is_in_category($question_type, $category)
249
-    {
250
-        if (!isset($this->_question_type_categories[$category])) {
251
-            return false;
252
-        }
253
-        return in_array($question_type, $this->_question_type_categories[$category]);
254
-    }
255
-
256
-
257
-    /**
258
-     * Returns all the question types in the given category
259
-     * @param string $category
260
-     * @return array|mixed
261
-     */
262
-    public function question_types_in_category($category)
263
-    {
264
-        if (isset($this->_question_type_categories[$category])) {
265
-            return $this->_question_type_categories[$category];
266
-        }
267
-        return array();
268
-    }
269
-
270
-
271
-    /**
272
-     * Returns all the question types that should have question options
273
-     * @return array
274
-     */
275
-    public function question_types_with_options()
276
-    {
277
-        return array_merge(
278
-            $this->question_types_in_category('single-answer-enum'),
279
-            $this->question_types_in_category('multi-answer-enum')
280
-        );
281
-    }
282
-
283
-    /**
284
-     * Returns the question type categories 2d array
285
-     * @return array see EEM_Question::_question_type_categories
286
-     */
287
-    public function question_type_categories()
288
-    {
289
-        return $this->_question_type_categories;
290
-    }
291
-
292
-    /**
293
-     * Returns an array of all the QST_system values that can be allowed in the system question group
294
-     * identified by $system_question_group_id
295
-     * @param string $system_question_group_id QSG_system
296
-     * @return array of system question names (QST_system)
297
-     */
298
-    public function allowed_system_questions_in_system_question_group($system_question_group_id)
299
-    {
300
-        $question_system_ids = array();
301
-        switch ($system_question_group_id) {
302
-            case EEM_Question_Group::system_personal:
303
-                $question_system_ids = array(
304
-                    EEM_Attendee::system_question_fname,
305
-                    EEM_Attendee::system_question_lname,
306
-                    EEM_Attendee::system_question_email,
307
-                    EEM_Attendee::system_question_phone
308
-                );
309
-                break;
310
-            case EEM_Question_Group::system_address:
311
-                $question_system_ids = array(
312
-                    EEM_Attendee::system_question_address,
313
-                    EEM_Attendee::system_question_address2,
314
-                    EEM_Attendee::system_question_city,
315
-                    EEM_Attendee::system_question_state,
316
-                    EEM_Attendee::system_question_country,
317
-                    EEM_Attendee::system_question_zip,
318
-                    EEM_Attendee::system_question_phone
319
-                );
320
-                break;
321
-        }
322
-        return apply_filters('FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id);
323
-    }
324
-
325
-    /**
326
-     * Returns an array of all the QST_system values that are required in the system question group
327
-     * identified by $system_question_group_id
328
-     * @param string $system_question_group_id QSG_system
329
-     * @return array of system question names (QST_system)
330
-     */
331
-    public function required_system_questions_in_system_question_group($system_question_group_id)
332
-    {
333
-        $question_system_ids = null;
334
-        switch ($system_question_group_id) {
335
-            case EEM_Question_Group::system_personal:
336
-                $question_system_ids = array(
337
-                    EEM_Attendee::system_question_fname,
338
-                    EEM_Attendee::system_question_email,
339
-                );
340
-                break;
341
-            default:
342
-                $question_system_ids = array();
343
-        }
344
-        return apply_filters('FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id);
345
-    }
346
-
347
-
348
-    /**
349
-     * Gets an array for converting between QST_system and QST_IDs for system questions. Eg, if you want to know
350
-     * which system question QST_ID corresponds to the QST_system 'city', use EEM_Question::instance()->get_Question_ID_from_system_string('city');
351
-     * @param $QST_system
352
-     * @return int of QST_ID for the question that corresponds to that QST_system
353
-     */
354
-    public function get_Question_ID_from_system_string($QST_system)
355
-    {
356
-        return $this->get_var(array(array('QST_system' => $QST_system)));
357
-    }
358
-
359
-
360
-    /**
361
-     * searches the db for the question with the latest question order and returns that value.
362
-     * @access public
363
-     * @return int
364
-     */
365
-    public function get_latest_question_order()
366
-    {
367
-        $columns_to_select = array(
368
-            'max_order' => array("MAX(QST_order)", "%d")
369
-        );
370
-        $max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select);
371
-        return isset($max[0], $max[0]['max_order']) ? $max[0]['max_order'] : 0;
372
-    }
373
-
374
-    /**
375
-     * Returns an array where keys are system question QST_system values,
376
-     * and values are the highest question max the admin can set on the question
377
-     * (aka the "max max"; eg, a site admin can change the zip question to have a max
378
-     * of 5, but no larger than 12)
379
-     * @return array
380
-     */
381
-    public function system_question_maxes()
382
-    {
383
-        return array(
384
-            'fname' => 45,
385
-            'lname' => 45,
386
-            'address' => 255,
387
-            'address2' => 255,
388
-            'city' => 45,
389
-            'zip' => 12,
390
-            'email' => 255,
391
-            'phone' => 45,
392
-        );
393
-    }
394
-
395
-    /**
396
-     * Given a QST_system value, gets the question's largest allowable max input.
397
-     * @see Registration_Form_Admin_Page::system_question_maxes()
398
-     * @param string $system_question_value
399
-     * @return int|float
400
-     */
401
-    public function absolute_max_for_system_question($system_question_value)
402
-    {
403
-        $maxes = $this->system_question_maxes();
404
-        if (isset($maxes[$system_question_value])) {
405
-            return $maxes[$system_question_value];
406
-        } else {
407
-            return EE_INF;
408
-        }
409
-    }
410
-
411
-
412
-    /**
413
-     * @return array
414
-     */
415
-    public function question_descriptions()
416
-    {
417
-        return $this->_question_descriptions;
418
-    }
19
+	// constant used to indicate that the question type is COUNTRY
20
+	const QST_type_country = 'COUNTRY';
21
+
22
+	// constant used to indicate that the question type is DATE
23
+	const QST_type_date = 'DATE';
24
+
25
+	// constant used to indicate that the question type is DROPDOWN
26
+	const QST_type_dropdown = 'DROPDOWN';
27
+
28
+	// constant used to indicate that the question type is CHECKBOX
29
+	const QST_type_checkbox = 'CHECKBOX';
30
+
31
+	// constant used to indicate that the question type is RADIO_BTN
32
+	const QST_type_radio = 'RADIO_BTN';
33
+
34
+	// constant used to indicate that the question type is STATE
35
+	const QST_type_state = 'STATE';
36
+
37
+	// constant used to indicate that the question type is TEXT
38
+	const QST_type_text = 'TEXT';
39
+
40
+	// constant used to indicate that the question type is TEXTAREA
41
+	const QST_type_textarea = 'TEXTAREA';
42
+
43
+	// constant used to indicate that the question type is a TEXTAREA that allows simple html
44
+	const QST_type_html_textarea = 'HTML_TEXTAREA';
45
+
46
+	// constant used to indicate that the question type is an email input
47
+	const QST_type_email = 'EMAIL';
48
+
49
+	// constant used to indicate that the question type is a US-formatted phone number
50
+	const QST_type_us_phone = 'US_PHONE';
51
+
52
+	// constant used to indicate that the question type is an integer (whole number)
53
+	const QST_type_int = 'INTEGER';
54
+
55
+	// constant used to indicate that the question type is a decimal (float)
56
+	const QST_type_decimal = 'DECIMAL';
57
+
58
+	// constant used to indicate that the question type is a valid URL
59
+	const QST_type_url = 'URL';
60
+
61
+	// constant used to indicate that the question type is a YEAR
62
+	const QST_type_year = 'YEAR';
63
+
64
+	// constant used to indicate that the question type is a multi-select
65
+	const QST_type_multi_select = 'MULTI_SELECT';
66
+
67
+	/**
68
+	 * Question types that are interchangeable, even after answers have been provided for them.
69
+	 * Top-level keys are category slugs, next level is an array of question types. If question types
70
+	 * aren't in this array, it is assumed they AREN'T interchangeable with any other question types.
71
+	 *
72
+	 * @access protected
73
+	 * @var array $_question_type_categories {
74
+	 * @type string $text
75
+	 * @type string $single -answer-enum
76
+	 * @type string $multi -answer-enum
77
+	 *                    }
78
+	 */
79
+	protected $_question_type_categories = array();
80
+
81
+	/**
82
+	 * lists all the question types which should be allowed. Ideally, this will be extensible.
83
+	 *
84
+	 * @access protected
85
+	 * @var array $_allowed_question_types
86
+	 */
87
+	protected $_allowed_question_types = array();
88
+
89
+	/**
90
+	 * brief descriptions for all the question types
91
+	 *
92
+	 * @access protected
93
+	 * @var EEM_Question $_instance
94
+	 */
95
+	protected $_question_descriptions;
96
+
97
+
98
+	// private instance of the Attendee object
99
+	protected static $_instance = NULL;
100
+
101
+
102
+	/**
103
+	 * EEM_Question constructor.
104
+	 *
105
+	 * @param null $timezone
106
+	 */
107
+	protected function __construct($timezone = NULL)
108
+	{
109
+		$this->singular_item = __('Question', 'event_espresso');
110
+		$this->plural_item = __('Questions', 'event_espresso');
111
+		$this->_allowed_question_types = apply_filters(
112
+			'FHEE__EEM_Question__construct__allowed_question_types',
113
+			array(
114
+				EEM_Question::QST_type_text => __('Text', 'event_espresso'),
115
+				EEM_Question::QST_type_textarea => __('Textarea', 'event_espresso'),
116
+				EEM_Question::QST_type_checkbox => __('Checkboxes', 'event_espresso'),
117
+				EEM_Question::QST_type_radio => __('Radio Buttons', 'event_espresso'),
118
+				EEM_Question::QST_type_dropdown => __('Dropdown', 'event_espresso'),
119
+				EEM_Question::QST_type_state => __('State/Province Dropdown', 'event_espresso'),
120
+				EEM_Question::QST_type_country => __('Country Dropdown', 'event_espresso'),
121
+				EEM_Question::QST_type_date => __('Date Picker', 'event_espresso'),
122
+				EEM_Question::QST_type_html_textarea => __('HTML Textarea', 'event_espresso'),
123
+				EEM_Question::QST_type_email => __('Email', 'event_espresso'),
124
+				EEM_Question::QST_type_us_phone => __('USA - Format Phone', 'event_espresso'),
125
+				EEM_Question::QST_type_decimal => __('Number', 'event_espresso'),
126
+				EEM_Question::QST_type_int => __('Whole Number', 'event_espresso'),
127
+				EEM_Question::QST_type_url => __('URL', 'event_espresso'),
128
+				EEM_Question::QST_type_year => __('Year', 'event_espresso'),
129
+				EEM_Question::QST_type_multi_select => __('Multi Select', 'event_espresso')
130
+			)
131
+		);
132
+		$this->_question_descriptions = apply_filters(
133
+			'FHEE__EEM_Question__construct__allowed_question_types',
134
+			array(
135
+				EEM_Question::QST_type_text => __('A single line text input field', 'event_espresso'),
136
+				EEM_Question::QST_type_textarea => __('A multi line text input field', 'event_espresso'),
137
+				EEM_Question::QST_type_checkbox => __('Allows multiple preset options to be selected', 'event_espresso'),
138
+				EEM_Question::QST_type_radio => __('Allows a single preset option to be selected', 'event_espresso'),
139
+				EEM_Question::QST_type_dropdown => __('A dropdown that allows a single selection', 'event_espresso'),
140
+				EEM_Question::QST_type_state => __('A dropdown that lists states/provinces', 'event_espresso'),
141
+				EEM_Question::QST_type_country => __('A dropdown that lists countries', 'event_espresso'),
142
+				EEM_Question::QST_type_date => __('A popup calendar that allows date selections', 'event_espresso'),
143
+				EEM_Question::QST_type_html_textarea => __('A multi line text input field that allows HTML', 'event_espresso'),
144
+				EEM_Question::QST_type_email => __('A text field that must contain a valid Email address', 'event_espresso'),
145
+				EEM_Question::QST_type_us_phone => __('A text field that must contain a valid US phone number', 'event_espresso'),
146
+				EEM_Question::QST_type_decimal => __('A text field that allows number values with decimals', 'event_espresso'),
147
+				EEM_Question::QST_type_int => __('A text field that only allows whole numbers (no decimals)', 'event_espresso'),
148
+				EEM_Question::QST_type_url => __('A text field that must contain a valid URL', 'event_espresso'),
149
+				EEM_Question::QST_type_year => __('A dropdown that lists the last 100 years', 'event_espresso'),
150
+				EEM_Question::QST_type_multi_select => __('A dropdown that allows multiple selections', 'event_espresso')
151
+			)
152
+		);
153
+		$this->_question_type_categories = (array)apply_filters(
154
+			'FHEE__EEM_Question__construct__question_type_categories',
155
+			array(
156
+				'text' => array(
157
+					EEM_Question::QST_type_text,
158
+					EEM_Question::QST_type_textarea,
159
+					EEM_Question::QST_type_date,
160
+					EEM_Question::QST_type_html_textarea,
161
+					EEM_Question::QST_type_email,
162
+					EEM_Question::QST_type_us_phone,
163
+					EEM_Question::QST_type_decimal,
164
+					EEM_Question::QST_type_int,
165
+					EEM_Question::QST_type_url,
166
+					EEM_Question::QST_type_year
167
+				),
168
+				'single-answer-enum' => array(
169
+					EEM_Question::QST_type_radio,
170
+					EEM_Question::QST_type_dropdown
171
+				),
172
+				'multi-answer-enum' => array(
173
+					EEM_Question::QST_type_checkbox,
174
+					EEM_Question::QST_type_multi_select
175
+				)
176
+			)
177
+		);
178
+
179
+		$this->_tables = array(
180
+			'Question' => new EE_Primary_Table('esp_question', 'QST_ID')
181
+		);
182
+		$this->_fields = array(
183
+			'Question' => array(
184
+				'QST_ID' => new EE_Primary_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso')),
185
+				'QST_display_text' => new EE_Post_Content_Field('QST_display_text', __('Question Text', 'event_espresso'), true, ''),
186
+				'QST_admin_label' => new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)', 'event_espresso'), true, ''),
187
+				'QST_system' => new EE_Plain_Text_Field('QST_system', __('Internal string ID for question', 'event_espresso'), false, ''),
188
+				'QST_type' => new EE_Enum_Text_Field('QST_type', __('Question Type', 'event_espresso'), false, 'TEXT', $this->_allowed_question_types),
189
+				'QST_required' => new EE_Boolean_Field('QST_required', __('Required Question?', 'event_espresso'), false, false),
190
+				'QST_required_text' => new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided', 'event_espresso'), true, ''),
191
+				'QST_order' => new EE_Integer_Field('QST_order', __('Question Order', 'event_espresso'), false, 0),
192
+				'QST_admin_only' => new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?', 'event_espresso'), false, false),
193
+				'QST_max' => new EE_Infinite_Integer_Field('QST_max', __('Max Size', 'event_espresso'), false, EE_INF),
194
+				'QST_wp_user' => new EE_WP_User_Field('QST_wp_user', __('Question Creator ID', 'event_espresso'), false),
195
+				'QST_deleted' => new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted', 'event_espresso'), false, false)
196
+			)
197
+		);
198
+		$this->_model_relations = array(
199
+			'Question_Group' => new EE_HABTM_Relation('Question_Group_Question'),
200
+			'Question_Option' => new EE_Has_Many_Relation(),
201
+			'Answer' => new EE_Has_Many_Relation(),
202
+			'WP_User' => new EE_Belongs_To_Relation(),
203
+			//for QST_order column
204
+			'Question_Group_Question' => new EE_Has_Many_Relation()
205
+		);
206
+		//this model is generally available for reading
207
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
208
+		$this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('QST_system');
209
+		$this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('QST_system');
210
+		$this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('QST_system');
211
+		parent::__construct($timezone);
212
+	}
213
+
214
+	/**
215
+	 * Returns the list of allowed question types, which are normally: 'TEXT','TEXTAREA','RADIO_BTN','DROPDOWN','CHECKBOX','DATE'
216
+	 * but they can be extended
217
+	 * @return string[]
218
+	 */
219
+	public function allowed_question_types()
220
+	{
221
+		return $this->_allowed_question_types;
222
+	}
223
+
224
+	/**
225
+	 * Gets all the question types in the same category
226
+	 * @param string $question_type one of EEM_Question::allowed_question_types(
227
+	 * @return string[] like EEM_Question::allowed_question_types()
228
+	 */
229
+	public function question_types_in_same_category($question_type)
230
+	{
231
+		$question_types = array($question_type);
232
+		foreach ($this->_question_type_categories as $category => $question_types_in_category) {
233
+			if (in_array($question_type, $question_types_in_category)) {
234
+				$question_types = $question_types_in_category;
235
+				break;
236
+			}
237
+		}
238
+
239
+		return array_intersect_key($this->allowed_question_types(), array_flip($question_types));
240
+	}
241
+
242
+	/**
243
+	 * Determines if the given question type is in the given question type category
244
+	 * @param string $question_type one of EEM_Question::allowed_question_types()
245
+	 * @param string $category one of the top-level keys of EEM_Question::question_type_categories()
246
+	 * @return boolean
247
+	 */
248
+	public function question_type_is_in_category($question_type, $category)
249
+	{
250
+		if (!isset($this->_question_type_categories[$category])) {
251
+			return false;
252
+		}
253
+		return in_array($question_type, $this->_question_type_categories[$category]);
254
+	}
255
+
256
+
257
+	/**
258
+	 * Returns all the question types in the given category
259
+	 * @param string $category
260
+	 * @return array|mixed
261
+	 */
262
+	public function question_types_in_category($category)
263
+	{
264
+		if (isset($this->_question_type_categories[$category])) {
265
+			return $this->_question_type_categories[$category];
266
+		}
267
+		return array();
268
+	}
269
+
270
+
271
+	/**
272
+	 * Returns all the question types that should have question options
273
+	 * @return array
274
+	 */
275
+	public function question_types_with_options()
276
+	{
277
+		return array_merge(
278
+			$this->question_types_in_category('single-answer-enum'),
279
+			$this->question_types_in_category('multi-answer-enum')
280
+		);
281
+	}
282
+
283
+	/**
284
+	 * Returns the question type categories 2d array
285
+	 * @return array see EEM_Question::_question_type_categories
286
+	 */
287
+	public function question_type_categories()
288
+	{
289
+		return $this->_question_type_categories;
290
+	}
291
+
292
+	/**
293
+	 * Returns an array of all the QST_system values that can be allowed in the system question group
294
+	 * identified by $system_question_group_id
295
+	 * @param string $system_question_group_id QSG_system
296
+	 * @return array of system question names (QST_system)
297
+	 */
298
+	public function allowed_system_questions_in_system_question_group($system_question_group_id)
299
+	{
300
+		$question_system_ids = array();
301
+		switch ($system_question_group_id) {
302
+			case EEM_Question_Group::system_personal:
303
+				$question_system_ids = array(
304
+					EEM_Attendee::system_question_fname,
305
+					EEM_Attendee::system_question_lname,
306
+					EEM_Attendee::system_question_email,
307
+					EEM_Attendee::system_question_phone
308
+				);
309
+				break;
310
+			case EEM_Question_Group::system_address:
311
+				$question_system_ids = array(
312
+					EEM_Attendee::system_question_address,
313
+					EEM_Attendee::system_question_address2,
314
+					EEM_Attendee::system_question_city,
315
+					EEM_Attendee::system_question_state,
316
+					EEM_Attendee::system_question_country,
317
+					EEM_Attendee::system_question_zip,
318
+					EEM_Attendee::system_question_phone
319
+				);
320
+				break;
321
+		}
322
+		return apply_filters('FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id);
323
+	}
324
+
325
+	/**
326
+	 * Returns an array of all the QST_system values that are required in the system question group
327
+	 * identified by $system_question_group_id
328
+	 * @param string $system_question_group_id QSG_system
329
+	 * @return array of system question names (QST_system)
330
+	 */
331
+	public function required_system_questions_in_system_question_group($system_question_group_id)
332
+	{
333
+		$question_system_ids = null;
334
+		switch ($system_question_group_id) {
335
+			case EEM_Question_Group::system_personal:
336
+				$question_system_ids = array(
337
+					EEM_Attendee::system_question_fname,
338
+					EEM_Attendee::system_question_email,
339
+				);
340
+				break;
341
+			default:
342
+				$question_system_ids = array();
343
+		}
344
+		return apply_filters('FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id);
345
+	}
346
+
347
+
348
+	/**
349
+	 * Gets an array for converting between QST_system and QST_IDs for system questions. Eg, if you want to know
350
+	 * which system question QST_ID corresponds to the QST_system 'city', use EEM_Question::instance()->get_Question_ID_from_system_string('city');
351
+	 * @param $QST_system
352
+	 * @return int of QST_ID for the question that corresponds to that QST_system
353
+	 */
354
+	public function get_Question_ID_from_system_string($QST_system)
355
+	{
356
+		return $this->get_var(array(array('QST_system' => $QST_system)));
357
+	}
358
+
359
+
360
+	/**
361
+	 * searches the db for the question with the latest question order and returns that value.
362
+	 * @access public
363
+	 * @return int
364
+	 */
365
+	public function get_latest_question_order()
366
+	{
367
+		$columns_to_select = array(
368
+			'max_order' => array("MAX(QST_order)", "%d")
369
+		);
370
+		$max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select);
371
+		return isset($max[0], $max[0]['max_order']) ? $max[0]['max_order'] : 0;
372
+	}
373
+
374
+	/**
375
+	 * Returns an array where keys are system question QST_system values,
376
+	 * and values are the highest question max the admin can set on the question
377
+	 * (aka the "max max"; eg, a site admin can change the zip question to have a max
378
+	 * of 5, but no larger than 12)
379
+	 * @return array
380
+	 */
381
+	public function system_question_maxes()
382
+	{
383
+		return array(
384
+			'fname' => 45,
385
+			'lname' => 45,
386
+			'address' => 255,
387
+			'address2' => 255,
388
+			'city' => 45,
389
+			'zip' => 12,
390
+			'email' => 255,
391
+			'phone' => 45,
392
+		);
393
+	}
394
+
395
+	/**
396
+	 * Given a QST_system value, gets the question's largest allowable max input.
397
+	 * @see Registration_Form_Admin_Page::system_question_maxes()
398
+	 * @param string $system_question_value
399
+	 * @return int|float
400
+	 */
401
+	public function absolute_max_for_system_question($system_question_value)
402
+	{
403
+		$maxes = $this->system_question_maxes();
404
+		if (isset($maxes[$system_question_value])) {
405
+			return $maxes[$system_question_value];
406
+		} else {
407
+			return EE_INF;
408
+		}
409
+	}
410
+
411
+
412
+	/**
413
+	 * @return array
414
+	 */
415
+	public function question_descriptions()
416
+	{
417
+		return $this->_question_descriptions;
418
+	}
419 419
 
420 420
 
421 421
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4
-require_once(EE_MODELS . 'EEM_Soft_Delete_Base.model.php');
5
-require_once(EE_CLASSES . 'EE_Question.class.php');
4
+require_once(EE_MODELS.'EEM_Soft_Delete_Base.model.php');
5
+require_once(EE_CLASSES.'EE_Question.class.php');
6 6
 
7 7
 
8 8
 /**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
                 EEM_Question::QST_type_multi_select => __('A dropdown that allows multiple selections', 'event_espresso')
151 151
             )
152 152
         );
153
-        $this->_question_type_categories = (array)apply_filters(
153
+        $this->_question_type_categories = (array) apply_filters(
154 154
             'FHEE__EEM_Question__construct__question_type_categories',
155 155
             array(
156 156
                 'text' => array(
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
      */
248 248
     public function question_type_is_in_category($question_type, $category)
249 249
     {
250
-        if (!isset($this->_question_type_categories[$category])) {
250
+        if ( ! isset($this->_question_type_categories[$category])) {
251 251
             return false;
252 252
         }
253 253
         return in_array($question_type, $this->_question_type_categories[$category]);
Please login to merge, or discard this patch.
core/libraries/payment_methods/EE_PMT_Base.lib.php 2 patches
Indentation   +718 added lines, -718 removed lines patch added patch discarded remove patch
@@ -21,724 +21,724 @@
 block discarded – undo
21 21
 abstract class EE_PMT_Base
22 22
 {
23 23
 
24
-    const onsite = 'on-site';
25
-    const offsite = 'off-site';
26
-    const offline = 'off-line';
27
-
28
-    /**
29
-     * @var EE_Payment_Method
30
-     */
31
-    protected $_pm_instance = NULL;
32
-
33
-    /**
34
-     * @var boolean
35
-     */
36
-    protected $_requires_https = FALSE;
37
-
38
-    /**
39
-     * @var boolean
40
-     */
41
-    protected $_has_billing_form;
42
-
43
-    /**
44
-     * @var EE_Gateway
45
-     */
46
-    protected $_gateway = NULL;
47
-
48
-    /**
49
-     * @var EE_Payment_Method_Form
50
-     */
51
-    protected $_settings_form = NULL;
52
-
53
-    /**
54
-     * @var EE_Form_Section_Proper
55
-     */
56
-    protected $_billing_form = NULL;
57
-
58
-    /**
59
-     * @var boolean
60
-     */
61
-    protected $_cache_billing_form = TRUE;
62
-
63
-    /**
64
-     * String of the absolute path to the folder containing this file, with a trailing slash.
65
-     * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/'
66
-     * @var string
67
-     */
68
-    protected $_file_folder = NULL;
69
-
70
-    /**
71
-     * String to the absolute URL to this file (useful for getting its web-accessible resources
72
-     * like images, js, or css)
73
-     * @var string
74
-     */
75
-    protected $_file_url = NULL;
76
-
77
-    /**
78
-     * Pretty name for the payment method
79
-     * @var string
80
-     */
81
-    protected $_pretty_name = NULL;
82
-
83
-    /**
84
-     *
85
-     * @var string
86
-     */
87
-    protected $_default_button_url = NULL;
88
-
89
-    /**
90
-     *
91
-     * @var string
92
-     */
93
-    protected $_default_description = NULL;
94
-
95
-
96
-    /**
97
-     *
98
-     * @param EE_Payment_Method $pm_instance
99
-     * @throws EE_Error
100
-     * @return EE_PMT_Base
101
-     */
102
-    function __construct($pm_instance = NULL)
103
-    {
104
-        if ($pm_instance instanceof EE_Payment_Method) {
105
-            $this->set_instance($pm_instance);
106
-        }
107
-        if ($this->_gateway) {
108
-            $this->_gateway->set_payment_model(EEM_Payment::instance());
109
-            $this->_gateway->set_payment_log(EEM_Change_Log::instance());
110
-            $this->_gateway->set_template_helper(new EEH_Template());
111
-            $this->_gateway->set_line_item_helper(new EEH_Line_Item());
112
-            $this->_gateway->set_money_helper(new EEH_Money());
113
-            $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter());
114
-            $this->_gateway->set_unsupported_character_remover(new AsciiOnly());
115
-            do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway);
116
-        }
117
-        if (!isset($this->_has_billing_form)) {
118
-            // by default, On Site gateways have a billing form
119
-            if ($this->payment_occurs() == EE_PMT_Base::onsite) {
120
-                $this->set_has_billing_form(true);
121
-            } else {
122
-                $this->set_has_billing_form(false);
123
-            }
124
-        }
125
-
126
-        if (!$this->_pretty_name) {
127
-            throw new EE_Error(sprintf(__("You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", "event_espresso")));
128
-        }
129
-        //if the child didn't specify a default button, use the credit card one
130
-        if ($this->_default_button_url === NULL) {
131
-            $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods' . DS . 'pay-by-credit-card.png';
132
-        }
133
-    }
134
-
135
-
136
-    /**
137
-     * @param boolean $has_billing_form
138
-     */
139
-    public function set_has_billing_form($has_billing_form)
140
-    {
141
-        $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN);
142
-    }
143
-
144
-
145
-    /**
146
-     * sets the file_folder property
147
-     */
148
-    protected function _set_file_folder()
149
-    {
150
-        $reflector = new ReflectionClass(get_class($this));
151
-        $fn = $reflector->getFileName();
152
-        $this->_file_folder = dirname($fn) . DS;
153
-    }
154
-
155
-
156
-    /**
157
-     * sets the file URL with a trailing slash for this PMT
158
-     */
159
-    protected function _set_file_url()
160
-    {
161
-        $plugins_dir_fixed = str_replace('\\', DS, WP_PLUGIN_DIR);
162
-        $file_folder_fixed = str_replace('\\', DS, $this->file_folder());
163
-        $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed);
164
-        $this->_file_url = $file_path;
165
-    }
166
-
167
-    /**
168
-     * Gets the default description on all payment methods of this type
169
-     * @return string
170
-     */
171
-    public function default_description()
172
-    {
173
-        return $this->_default_description;
174
-    }
175
-
176
-
177
-    /**
178
-     * Returns the folder containing the PMT child class, with a trailing slash
179
-     * @return string
180
-     */
181
-    public function file_folder()
182
-    {
183
-        if (!$this->_file_folder) {
184
-            $this->_set_file_folder();
185
-        }
186
-        return $this->_file_folder;
187
-    }
188
-
189
-
190
-    /**
191
-     * @return string
192
-     */
193
-    public function file_url()
194
-    {
195
-        if (!$this->_file_url) {
196
-            $this->_set_file_url();
197
-        }
198
-        return $this->_file_url;
199
-    }
200
-
201
-
202
-    /**
203
-     * Sets the payment method instance this payment method type is for.
204
-     * Its important teh payment method instance is set before
205
-     * @param EE_Payment_Method $payment_method_instance
206
-     */
207
-    function set_instance($payment_method_instance)
208
-    {
209
-        $this->_pm_instance = $payment_method_instance;
210
-        //if they have already requested the settings form, make sure its
211
-        //data matches this model object
212
-        if ($this->_settings_form) {
213
-            $this->settings_form()->populate_model_obj($payment_method_instance);
214
-        }
215
-        if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
216
-            $this->_gateway->set_settings($payment_method_instance->settings_array());
217
-        }
218
-    }
219
-
220
-
221
-    /**
222
-     * Gets teh form for displaying to admins where they setup the payment method
223
-     * @return EE_Payment_Method_Form
224
-     */
225
-    function settings_form()
226
-    {
227
-        if (!$this->_settings_form) {
228
-            $this->_settings_form = $this->generate_new_settings_form();
229
-            $this->_settings_form->set_payment_method_type($this);
230
-            //if we have already assigned a model object to this pmt, make
231
-            //sure its reflected in teh form we just generated
232
-            if ($this->_pm_instance) {
233
-                $this->_settings_form->populate_model_obj($this->_pm_instance);
234
-            }
235
-        }
236
-        return $this->_settings_form;
237
-    }
238
-
239
-
240
-    /**
241
-     * Gets the form for all the settings related to this payment method type
242
-     * @return EE_Payment_Method_Form
243
-     */
244
-    abstract function generate_new_settings_form();
245
-
246
-
247
-    /**
248
-     * Sets the form for settings. This may be useful if we have already received
249
-     * a form submission and have form data it in, and want to use it anytime we're showing
250
-     * this payment method type's settings form later in the request
251
-     * @param EE_Payment_Method_Form $form
252
-     */
253
-    public function set_settings_form($form)
254
-    {
255
-        $this->_settings_form = $form;
256
-    }
257
-
258
-
259
-    /**
260
-     * @return boolean
261
-     */
262
-    public function has_billing_form()
263
-    {
264
-        return $this->_has_billing_form;
265
-    }
266
-
267
-
268
-    /**
269
-     * Gets the form for displaying to attendees where they can enter their billing info
270
-     * which will be sent to teh gateway (can be null)
271
-     *
272
-     * @param \EE_Transaction $transaction
273
-     * @param array $extra_args
274
-     * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null
275
-     */
276
-    public function billing_form(EE_Transaction $transaction = NULL, $extra_args = array())
277
-    {
278
-        // has billing form already been regenerated ? or overwrite cache?
279
-        if (!$this->_billing_form instanceof EE_Billing_Info_Form || !$this->_cache_billing_form) {
280
-            $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args);
281
-        }
282
-        //if we know who the attendee is, and this is a billing form
283
-        //that uses attendee info, populate it
284
-        if (
285
-        apply_filters(
286
-            'FHEE__populate_billing_form_fields_from_attendee',
287
-            (
288
-                $this->_billing_form instanceof EE_Billing_Attendee_Info_Form
289
-                && $transaction instanceof EE_Transaction
290
-                && $transaction->primary_registration() instanceof EE_Registration
291
-                && $transaction->primary_registration()->attendee() instanceof EE_Attendee
292
-            ),
293
-            $this->_billing_form,
294
-            $transaction
295
-        )
296
-        ) {
297
-            $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee());
298
-        }
299
-        return $this->_billing_form;
300
-    }
301
-
302
-
303
-    /**
304
-     * Creates the billing form for this payment method type
305
-     * @param \EE_Transaction $transaction
306
-     * @return \EE_Billing_Info_Form
307
-     */
308
-    abstract function generate_new_billing_form(EE_Transaction $transaction = NULL);
309
-
310
-
311
-    /**
312
-     * apply_billing_form_debug_settings
313
-     * applies debug data to the form
314
-     *
315
-     * @param \EE_Billing_Info_Form $billing_form
316
-     * @return \EE_Billing_Info_Form
317
-     */
318
-    public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
319
-    {
320
-        return $billing_form;
321
-    }
322
-
323
-
324
-    /**
325
-     * Sets the billing form for this payment method type. You may want to use this
326
-     * if you have form
327
-     * @param EE_Payment_Method $form
328
-     */
329
-    public function set_billing_form($form)
330
-    {
331
-        $this->_billing_form = $form;
332
-    }
333
-
334
-
335
-    /**
336
-     * Returns whether or not this payment method requires HTTPS to be used
337
-     * @return boolean
338
-     */
339
-    function requires_https()
340
-    {
341
-        return $this->_requires_https;
342
-    }
343
-
344
-
345
-    /**
346
-     *
347
-     * @param EE_Transaction $transaction
348
-     * @param float $amount
349
-     * @param EE_Billing_Info_Form $billing_info
350
-     * @param string $return_url
351
-     * @param string $fail_url
352
-     * @param string $method
353
-     * @param bool $by_admin
354
-     * @return EE_Payment
355
-     * @throws EE_Error
356
-     */
357
-    function process_payment(EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null, $fail_url = '', $method = 'CART', $by_admin = false)
358
-    {
359
-        // @todo: add surcharge for the payment method, if any
360
-        if ($this->_gateway) {
361
-            //there is a gateway, so we're going to make a payment object
362
-            //but wait! do they already have a payment in progress that we thought was failed?
363
-            $duplicate_properties = array(
364
-                'STS_ID' => EEM_Payment::status_id_failed,
365
-                'TXN_ID' => $transaction->ID(),
366
-                'PMD_ID' => $this->_pm_instance->ID(),
367
-                'PAY_source' => $method,
368
-                'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(),
369
-                'PAY_gateway_response' => null,
370
-            );
371
-            $payment = EEM_Payment::instance()->get_one(array($duplicate_properties));
372
-            //if we didn't already have a payment in progress for the same thing,
373
-            //then we actually want to make a new payment
374
-            if (!$payment instanceof EE_Payment) {
375
-                $payment = EE_Payment::new_instance(
376
-                    array_merge(
377
-                        $duplicate_properties,
378
-                        array(
379
-                            'PAY_timestamp' => time(),
380
-                            'PAY_txn_id_chq_nmbr' => null,
381
-                            'PAY_po_number' => null,
382
-                            'PAY_extra_accntng' => null,
383
-                            'PAY_details' => null,
384
-                        )
385
-                    )
386
-                );
387
-            }
388
-            //make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it
389
-            $payment->save();
390
-            $billing_values = $this->_get_billing_values_from_form($billing_info);
391
-
392
-            //  Offsite Gateway
393
-            if ($this->_gateway instanceof EE_Offsite_Gateway) {
394
-
395
-                $payment = $this->_gateway->set_redirection_info(
396
-                    $payment,
397
-                    $billing_values,
398
-                    $return_url,
399
-                    EE_Config::instance()->core->txn_page_url(
400
-                        array(
401
-                            'e_reg_url_link' => $transaction->primary_registration()->reg_url_link(),
402
-                            'ee_payment_method' => $this->_pm_instance->slug()
403
-                        )
404
-                    ),
405
-                    $fail_url
406
-                );
407
-                $payment->save();
408
-                //  Onsite Gateway
409
-            } elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
410
-
411
-                $payment = $this->_gateway->do_direct_payment($payment, $billing_values);
412
-                $payment->save();
413
-
414
-            } else {
415
-                throw new EE_Error(
416
-                    sprintf(
417
-                        __('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso'),
418
-                        get_class($this),
419
-                        gettype($this->_gateway)
420
-                    )
421
-                );
422
-            }
423
-
424
-        } else {
425
-            // no gateway provided
426
-            // there is no payment. Must be an offline gateway
427
-            // create a payment object anyways, but dont save it
428
-            $payment = EE_Payment::new_instance(
429
-                array(
430
-                    'STS_ID' => EEM_Payment::status_id_pending,
431
-                    'TXN_ID' => $transaction->ID(),
432
-                    'PMD_ID' => $transaction->payment_method_ID(),
433
-                    'PAY_amount' => 0.00,
434
-                    'PAY_timestamp' => time(),
435
-                )
436
-            );
437
-
438
-        }
439
-
440
-        // if there is billing info, clean it and save it now
441
-        if ($billing_info instanceof EE_Billing_Attendee_Info_Form) {
442
-            $this->_save_billing_info_to_attendee($billing_info, $transaction);
443
-        }
444
-
445
-        return $payment;
446
-    }
447
-
448
-    /**
449
-     * Gets the values we want to pass onto the gateway. Normally these
450
-     * are just the 'pretty' values, but there may be times the data may need
451
-     * a  little massaging. Proper subsections will become arrays of inputs
452
-     * @param EE_Billing_Info_Form $billing_form
453
-     * @return array
454
-     */
455
-    protected function _get_billing_values_from_form($billing_form)
456
-    {
457
-        if ($billing_form instanceof EE_Form_Section_Proper) {
458
-            return $billing_form->input_pretty_values(true);
459
-        } else {
460
-            return NULL;
461
-        }
462
-    }
463
-
464
-
465
-    /**
466
-     * Handles an instant payment notification when the transaction is known (by default).
467
-     * @param array $req_data
468
-     * @param EE_Transaction $transaction
469
-     * @return EE_Payment
470
-     * @throws EE_Error
471
-     */
472
-    public function handle_ipn($req_data, $transaction)
473
-    {
474
-        $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
475
-        if (!$this->_gateway instanceof EE_Offsite_Gateway) {
476
-            throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r($this->_gateway, TRUE)));
477
-
478
-        }
479
-        $payment = $this->_gateway->handle_payment_update($req_data, $transaction);
480
-        return $payment;
481
-    }
482
-
483
-
484
-    /**
485
-     * Saves the billing info onto the attendee of the primary registrant on this transaction, and
486
-     * cleans it first.
487
-     * @param EE_Billing_Attendee_Info_Form $billing_form
488
-     * @param EE_Transaction $transaction
489
-     * @return boolean success
490
-     */
491
-    protected function _save_billing_info_to_attendee($billing_form, $transaction)
492
-    {
493
-        if (!$transaction || !$transaction instanceof EE_Transaction) {
494
-            EE_Error::add_error(__("Cannot save billing info because no transaction was specified", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
495
-            return false;
496
-        }
497
-        $primary_reg = $transaction->primary_registration();
498
-        if (!$primary_reg) {
499
-            EE_Error::add_error(__("Cannot save billing info because the transaction has no primary registration", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
500
-            return false;
501
-        }
502
-        $attendee = $primary_reg->attendee();
503
-        if (!$attendee) {
504
-            EE_Error::add_error(__("Cannot save billing info because the transaction's primary registration has no attendee!", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
505
-            return false;
506
-        }
507
-        return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method());
508
-
509
-    }
510
-
511
-
512
-    /**
513
-     * Gets the payment this IPN is for. Children may often want to
514
-     * override this to inspect the request
515
-     * @param EE_Transaction $transaction
516
-     * @param array $req_data
517
-     * @return EE_Payment
518
-     */
519
-    protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array())
520
-    {
521
-        return $transaction->last_payment();
522
-    }
523
-
524
-
525
-    /**
526
-     * In case generic code cannot provide the payment processor with a specific payment method
527
-     * and transaction, it will try calling this method on each activate payment method.
528
-     * If the payment method is able to identify the request as being for it, it should fetch
529
-     * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot
530
-     * handle the IPN
531
-     * @param array $req_data
532
-     * @return EE_Payment only if this payment method can find the info its needs from $req_data
533
-     * and identifies the IPN as being for this payment method (not just fo ra payment method of this type)
534
-     * @throws EE_Error
535
-     */
536
-    public function handle_unclaimed_ipn($req_data = array())
537
-    {
538
-        throw new EE_Error(sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this)));
539
-    }
540
-
541
-
542
-    /**
543
-     * Logic to be accomplished when the payment attempt is complete.
544
-     * Most payment methods don't need to do anything at this point; but some, like Mijireh, do.
545
-     * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from
546
-     * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status
547
-     * of the payment). Fed a transaction because it's always assumed to be the last payment that
548
-     * we're dealing with. Returns that last payment (if there is one)
549
-     *
550
-     * @param EE_Transaction $transaction
551
-     * @return EE_Payment
552
-     */
553
-    public function finalize_payment_for($transaction)
554
-    {
555
-        return $transaction->last_payment();
556
-    }
557
-
558
-
559
-    /**
560
-     * Whether or not this payment method's gateway supports sending refund requests
561
-     * @return boolean
562
-     */
563
-    public function supports_sending_refunds()
564
-    {
565
-        if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
566
-            return $this->_gateway->supports_sending_refunds();
567
-        } else {
568
-            return false;
569
-        }
570
-    }
571
-
572
-
573
-    /**
574
-     *
575
-     * @param EE_Payment $payment
576
-     * @param array $refund_info
577
-     * @throws EE_Error
578
-     * @return EE_Payment
579
-     */
580
-    public function process_refund(EE_Payment $payment, $refund_info = array())
581
-    {
582
-        if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
583
-            return $this->_gateway->do_direct_refund($payment, $refund_info);
584
-        } else {
585
-            throw new EE_Error(
586
-                sprintf(
587
-                    __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'),
588
-                    get_class($this)
589
-                )
590
-            );
591
-        }
592
-    }
593
-
594
-
595
-    /**
596
-     * Returns one the class's constants onsite,offsite, or offline, depending on this
597
-     * payment method's gateway.
598
-     * @return string
599
-     * @throws EE_Error
600
-     */
601
-    public function payment_occurs()
602
-    {
603
-        if (!$this->_gateway) {
604
-            return EE_PMT_Base::offline;
605
-        } elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
606
-            return EE_PMT_Base::onsite;
607
-        } elseif ($this->_gateway instanceof EE_Offsite_Gateway) {
608
-            return EE_PMT_Base::offsite;
609
-        } else {
610
-            throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"), get_class($this)));
611
-        }
612
-    }
613
-
614
-
615
-    /**
616
-     * For adding any html output ab ove the payment overview.
617
-     * Many gateways won't want ot display anything, so this function just returns an empty string.
618
-     * Other gateways may want to override this, such as offline gateways.
619
-     * @param EE_Payment $payment
620
-     * @return string
621
-     */
622
-    public function payment_overview_content(EE_Payment $payment)
623
-    {
624
-        return EEH_Template::display_template(EE_LIBRARIES . 'payment_methods' . DS . 'templates' . DS . 'payment_details_content.template.php', array('payment_method' => $this->_pm_instance, 'payment' => $payment), true);
625
-    }
626
-
627
-
628
-    /**
629
-     * @return array where keys are the help tab name,
630
-     * values are: array {
631
-     * @type string $title i18n name for the help tab
632
-     * @type string $filename name of the file located in ./help_tabs/ (ie, in a folder next to this file)
633
-     * @type array $template_args any arguments you want passed to the template file while rendering.
634
-     *                Keys will be variable names and values with be their values.
635
-     */
636
-    public function help_tabs_config()
637
-    {
638
-        return array();
639
-    }
640
-
641
-
642
-    /**
643
-     * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into
644
-     * the payment method's table's PMT_type column)
645
-     * @return string
646
-     */
647
-    public function system_name()
648
-    {
649
-        $classname = get_class($this);
650
-        return str_replace("EE_PMT_", '', $classname);
651
-    }
652
-
653
-
654
-    /**
655
-     * A pretty i18n version of the PMT name
656
-     * @return string
657
-     */
658
-    public function pretty_name()
659
-    {
660
-        return $this->_pretty_name;
661
-    }
662
-
663
-
664
-    /**
665
-     * Gets the default absolute URL to the payment method type's button
666
-     * @return string
667
-     */
668
-    public function default_button_url()
669
-    {
670
-        return $this->_default_button_url;
671
-    }
672
-
673
-
674
-    /**
675
-     * Gets the gateway used by this payment method (if any)
676
-     * @return EE_Gateway
677
-     */
678
-    public function get_gateway()
679
-    {
680
-        return $this->_gateway;
681
-    }
682
-
683
-
684
-    /**
685
-     * @return string html for the link to a help tab
686
-     */
687
-    public function get_help_tab_link()
688
-    {
689
-        return EEH_Template::get_help_tab_link($this->get_help_tab_name());
690
-    }
691
-
692
-
693
-    /**
694
-     * Returns the name of the help tab for this PMT
695
-     * @return string
696
-     */
697
-    public function get_help_tab_name()
698
-    {
699
-        return 'ee_' . strtolower($this->system_name()) . '_help_tab';
700
-    }
701
-
702
-    /**
703
-     * The name of the wp capability that should be associated with the usage of
704
-     * this PMT by an admin
705
-     * @return string
706
-     */
707
-    public function cap_name()
708
-    {
709
-        return 'ee_payment_method_' . strtolower($this->system_name());
710
-    }
711
-
712
-    /**
713
-     * Called by client code to tell the gateway that if it wants to change
714
-     * the transaction or line items or registrations related to teh payment it already
715
-     * processed (we think, but possibly not) that now's the time to do it.
716
-     * It is expected that gateways will store any info they need for this on the PAY_details,
717
-     * or maybe an extra meta value
718
-     * @param EE_Payment $payment
719
-     * @return void
720
-     */
721
-    public function update_txn_based_on_payment($payment)
722
-    {
723
-        if ($this->_gateway instanceof EE_Gateway) {
724
-            $this->_gateway->update_txn_based_on_payment($payment);
725
-        }
726
-    }
727
-
728
-    /**
729
-     * Returns a string of HTML describing this payment method type for an admin,
730
-     * primarily intended for them to read before activating it.
731
-     * The easiest way to set this is to create a folder 'templates' alongside
732
-     * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php".
733
-     * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php",
734
-     * then you'd create a file named "templates" in the same folder as it, and name the file
735
-     * "foo_bar_intro.template.php", and its content will be returned by this method
736
-     * @return string
737
-     */
738
-    public function introductory_html()
739
-    {
740
-        return EEH_Template::locate_template($this->file_folder() . 'templates' . DS . strtolower($this->system_name()) . '_intro.template.php', array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance));
741
-    }
24
+	const onsite = 'on-site';
25
+	const offsite = 'off-site';
26
+	const offline = 'off-line';
27
+
28
+	/**
29
+	 * @var EE_Payment_Method
30
+	 */
31
+	protected $_pm_instance = NULL;
32
+
33
+	/**
34
+	 * @var boolean
35
+	 */
36
+	protected $_requires_https = FALSE;
37
+
38
+	/**
39
+	 * @var boolean
40
+	 */
41
+	protected $_has_billing_form;
42
+
43
+	/**
44
+	 * @var EE_Gateway
45
+	 */
46
+	protected $_gateway = NULL;
47
+
48
+	/**
49
+	 * @var EE_Payment_Method_Form
50
+	 */
51
+	protected $_settings_form = NULL;
52
+
53
+	/**
54
+	 * @var EE_Form_Section_Proper
55
+	 */
56
+	protected $_billing_form = NULL;
57
+
58
+	/**
59
+	 * @var boolean
60
+	 */
61
+	protected $_cache_billing_form = TRUE;
62
+
63
+	/**
64
+	 * String of the absolute path to the folder containing this file, with a trailing slash.
65
+	 * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/'
66
+	 * @var string
67
+	 */
68
+	protected $_file_folder = NULL;
69
+
70
+	/**
71
+	 * String to the absolute URL to this file (useful for getting its web-accessible resources
72
+	 * like images, js, or css)
73
+	 * @var string
74
+	 */
75
+	protected $_file_url = NULL;
76
+
77
+	/**
78
+	 * Pretty name for the payment method
79
+	 * @var string
80
+	 */
81
+	protected $_pretty_name = NULL;
82
+
83
+	/**
84
+	 *
85
+	 * @var string
86
+	 */
87
+	protected $_default_button_url = NULL;
88
+
89
+	/**
90
+	 *
91
+	 * @var string
92
+	 */
93
+	protected $_default_description = NULL;
94
+
95
+
96
+	/**
97
+	 *
98
+	 * @param EE_Payment_Method $pm_instance
99
+	 * @throws EE_Error
100
+	 * @return EE_PMT_Base
101
+	 */
102
+	function __construct($pm_instance = NULL)
103
+	{
104
+		if ($pm_instance instanceof EE_Payment_Method) {
105
+			$this->set_instance($pm_instance);
106
+		}
107
+		if ($this->_gateway) {
108
+			$this->_gateway->set_payment_model(EEM_Payment::instance());
109
+			$this->_gateway->set_payment_log(EEM_Change_Log::instance());
110
+			$this->_gateway->set_template_helper(new EEH_Template());
111
+			$this->_gateway->set_line_item_helper(new EEH_Line_Item());
112
+			$this->_gateway->set_money_helper(new EEH_Money());
113
+			$this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter());
114
+			$this->_gateway->set_unsupported_character_remover(new AsciiOnly());
115
+			do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway);
116
+		}
117
+		if (!isset($this->_has_billing_form)) {
118
+			// by default, On Site gateways have a billing form
119
+			if ($this->payment_occurs() == EE_PMT_Base::onsite) {
120
+				$this->set_has_billing_form(true);
121
+			} else {
122
+				$this->set_has_billing_form(false);
123
+			}
124
+		}
125
+
126
+		if (!$this->_pretty_name) {
127
+			throw new EE_Error(sprintf(__("You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", "event_espresso")));
128
+		}
129
+		//if the child didn't specify a default button, use the credit card one
130
+		if ($this->_default_button_url === NULL) {
131
+			$this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods' . DS . 'pay-by-credit-card.png';
132
+		}
133
+	}
134
+
135
+
136
+	/**
137
+	 * @param boolean $has_billing_form
138
+	 */
139
+	public function set_has_billing_form($has_billing_form)
140
+	{
141
+		$this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN);
142
+	}
143
+
144
+
145
+	/**
146
+	 * sets the file_folder property
147
+	 */
148
+	protected function _set_file_folder()
149
+	{
150
+		$reflector = new ReflectionClass(get_class($this));
151
+		$fn = $reflector->getFileName();
152
+		$this->_file_folder = dirname($fn) . DS;
153
+	}
154
+
155
+
156
+	/**
157
+	 * sets the file URL with a trailing slash for this PMT
158
+	 */
159
+	protected function _set_file_url()
160
+	{
161
+		$plugins_dir_fixed = str_replace('\\', DS, WP_PLUGIN_DIR);
162
+		$file_folder_fixed = str_replace('\\', DS, $this->file_folder());
163
+		$file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed);
164
+		$this->_file_url = $file_path;
165
+	}
166
+
167
+	/**
168
+	 * Gets the default description on all payment methods of this type
169
+	 * @return string
170
+	 */
171
+	public function default_description()
172
+	{
173
+		return $this->_default_description;
174
+	}
175
+
176
+
177
+	/**
178
+	 * Returns the folder containing the PMT child class, with a trailing slash
179
+	 * @return string
180
+	 */
181
+	public function file_folder()
182
+	{
183
+		if (!$this->_file_folder) {
184
+			$this->_set_file_folder();
185
+		}
186
+		return $this->_file_folder;
187
+	}
188
+
189
+
190
+	/**
191
+	 * @return string
192
+	 */
193
+	public function file_url()
194
+	{
195
+		if (!$this->_file_url) {
196
+			$this->_set_file_url();
197
+		}
198
+		return $this->_file_url;
199
+	}
200
+
201
+
202
+	/**
203
+	 * Sets the payment method instance this payment method type is for.
204
+	 * Its important teh payment method instance is set before
205
+	 * @param EE_Payment_Method $payment_method_instance
206
+	 */
207
+	function set_instance($payment_method_instance)
208
+	{
209
+		$this->_pm_instance = $payment_method_instance;
210
+		//if they have already requested the settings form, make sure its
211
+		//data matches this model object
212
+		if ($this->_settings_form) {
213
+			$this->settings_form()->populate_model_obj($payment_method_instance);
214
+		}
215
+		if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
216
+			$this->_gateway->set_settings($payment_method_instance->settings_array());
217
+		}
218
+	}
219
+
220
+
221
+	/**
222
+	 * Gets teh form for displaying to admins where they setup the payment method
223
+	 * @return EE_Payment_Method_Form
224
+	 */
225
+	function settings_form()
226
+	{
227
+		if (!$this->_settings_form) {
228
+			$this->_settings_form = $this->generate_new_settings_form();
229
+			$this->_settings_form->set_payment_method_type($this);
230
+			//if we have already assigned a model object to this pmt, make
231
+			//sure its reflected in teh form we just generated
232
+			if ($this->_pm_instance) {
233
+				$this->_settings_form->populate_model_obj($this->_pm_instance);
234
+			}
235
+		}
236
+		return $this->_settings_form;
237
+	}
238
+
239
+
240
+	/**
241
+	 * Gets the form for all the settings related to this payment method type
242
+	 * @return EE_Payment_Method_Form
243
+	 */
244
+	abstract function generate_new_settings_form();
245
+
246
+
247
+	/**
248
+	 * Sets the form for settings. This may be useful if we have already received
249
+	 * a form submission and have form data it in, and want to use it anytime we're showing
250
+	 * this payment method type's settings form later in the request
251
+	 * @param EE_Payment_Method_Form $form
252
+	 */
253
+	public function set_settings_form($form)
254
+	{
255
+		$this->_settings_form = $form;
256
+	}
257
+
258
+
259
+	/**
260
+	 * @return boolean
261
+	 */
262
+	public function has_billing_form()
263
+	{
264
+		return $this->_has_billing_form;
265
+	}
266
+
267
+
268
+	/**
269
+	 * Gets the form for displaying to attendees where they can enter their billing info
270
+	 * which will be sent to teh gateway (can be null)
271
+	 *
272
+	 * @param \EE_Transaction $transaction
273
+	 * @param array $extra_args
274
+	 * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null
275
+	 */
276
+	public function billing_form(EE_Transaction $transaction = NULL, $extra_args = array())
277
+	{
278
+		// has billing form already been regenerated ? or overwrite cache?
279
+		if (!$this->_billing_form instanceof EE_Billing_Info_Form || !$this->_cache_billing_form) {
280
+			$this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args);
281
+		}
282
+		//if we know who the attendee is, and this is a billing form
283
+		//that uses attendee info, populate it
284
+		if (
285
+		apply_filters(
286
+			'FHEE__populate_billing_form_fields_from_attendee',
287
+			(
288
+				$this->_billing_form instanceof EE_Billing_Attendee_Info_Form
289
+				&& $transaction instanceof EE_Transaction
290
+				&& $transaction->primary_registration() instanceof EE_Registration
291
+				&& $transaction->primary_registration()->attendee() instanceof EE_Attendee
292
+			),
293
+			$this->_billing_form,
294
+			$transaction
295
+		)
296
+		) {
297
+			$this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee());
298
+		}
299
+		return $this->_billing_form;
300
+	}
301
+
302
+
303
+	/**
304
+	 * Creates the billing form for this payment method type
305
+	 * @param \EE_Transaction $transaction
306
+	 * @return \EE_Billing_Info_Form
307
+	 */
308
+	abstract function generate_new_billing_form(EE_Transaction $transaction = NULL);
309
+
310
+
311
+	/**
312
+	 * apply_billing_form_debug_settings
313
+	 * applies debug data to the form
314
+	 *
315
+	 * @param \EE_Billing_Info_Form $billing_form
316
+	 * @return \EE_Billing_Info_Form
317
+	 */
318
+	public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
319
+	{
320
+		return $billing_form;
321
+	}
322
+
323
+
324
+	/**
325
+	 * Sets the billing form for this payment method type. You may want to use this
326
+	 * if you have form
327
+	 * @param EE_Payment_Method $form
328
+	 */
329
+	public function set_billing_form($form)
330
+	{
331
+		$this->_billing_form = $form;
332
+	}
333
+
334
+
335
+	/**
336
+	 * Returns whether or not this payment method requires HTTPS to be used
337
+	 * @return boolean
338
+	 */
339
+	function requires_https()
340
+	{
341
+		return $this->_requires_https;
342
+	}
343
+
344
+
345
+	/**
346
+	 *
347
+	 * @param EE_Transaction $transaction
348
+	 * @param float $amount
349
+	 * @param EE_Billing_Info_Form $billing_info
350
+	 * @param string $return_url
351
+	 * @param string $fail_url
352
+	 * @param string $method
353
+	 * @param bool $by_admin
354
+	 * @return EE_Payment
355
+	 * @throws EE_Error
356
+	 */
357
+	function process_payment(EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null, $fail_url = '', $method = 'CART', $by_admin = false)
358
+	{
359
+		// @todo: add surcharge for the payment method, if any
360
+		if ($this->_gateway) {
361
+			//there is a gateway, so we're going to make a payment object
362
+			//but wait! do they already have a payment in progress that we thought was failed?
363
+			$duplicate_properties = array(
364
+				'STS_ID' => EEM_Payment::status_id_failed,
365
+				'TXN_ID' => $transaction->ID(),
366
+				'PMD_ID' => $this->_pm_instance->ID(),
367
+				'PAY_source' => $method,
368
+				'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(),
369
+				'PAY_gateway_response' => null,
370
+			);
371
+			$payment = EEM_Payment::instance()->get_one(array($duplicate_properties));
372
+			//if we didn't already have a payment in progress for the same thing,
373
+			//then we actually want to make a new payment
374
+			if (!$payment instanceof EE_Payment) {
375
+				$payment = EE_Payment::new_instance(
376
+					array_merge(
377
+						$duplicate_properties,
378
+						array(
379
+							'PAY_timestamp' => time(),
380
+							'PAY_txn_id_chq_nmbr' => null,
381
+							'PAY_po_number' => null,
382
+							'PAY_extra_accntng' => null,
383
+							'PAY_details' => null,
384
+						)
385
+					)
386
+				);
387
+			}
388
+			//make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it
389
+			$payment->save();
390
+			$billing_values = $this->_get_billing_values_from_form($billing_info);
391
+
392
+			//  Offsite Gateway
393
+			if ($this->_gateway instanceof EE_Offsite_Gateway) {
394
+
395
+				$payment = $this->_gateway->set_redirection_info(
396
+					$payment,
397
+					$billing_values,
398
+					$return_url,
399
+					EE_Config::instance()->core->txn_page_url(
400
+						array(
401
+							'e_reg_url_link' => $transaction->primary_registration()->reg_url_link(),
402
+							'ee_payment_method' => $this->_pm_instance->slug()
403
+						)
404
+					),
405
+					$fail_url
406
+				);
407
+				$payment->save();
408
+				//  Onsite Gateway
409
+			} elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
410
+
411
+				$payment = $this->_gateway->do_direct_payment($payment, $billing_values);
412
+				$payment->save();
413
+
414
+			} else {
415
+				throw new EE_Error(
416
+					sprintf(
417
+						__('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso'),
418
+						get_class($this),
419
+						gettype($this->_gateway)
420
+					)
421
+				);
422
+			}
423
+
424
+		} else {
425
+			// no gateway provided
426
+			// there is no payment. Must be an offline gateway
427
+			// create a payment object anyways, but dont save it
428
+			$payment = EE_Payment::new_instance(
429
+				array(
430
+					'STS_ID' => EEM_Payment::status_id_pending,
431
+					'TXN_ID' => $transaction->ID(),
432
+					'PMD_ID' => $transaction->payment_method_ID(),
433
+					'PAY_amount' => 0.00,
434
+					'PAY_timestamp' => time(),
435
+				)
436
+			);
437
+
438
+		}
439
+
440
+		// if there is billing info, clean it and save it now
441
+		if ($billing_info instanceof EE_Billing_Attendee_Info_Form) {
442
+			$this->_save_billing_info_to_attendee($billing_info, $transaction);
443
+		}
444
+
445
+		return $payment;
446
+	}
447
+
448
+	/**
449
+	 * Gets the values we want to pass onto the gateway. Normally these
450
+	 * are just the 'pretty' values, but there may be times the data may need
451
+	 * a  little massaging. Proper subsections will become arrays of inputs
452
+	 * @param EE_Billing_Info_Form $billing_form
453
+	 * @return array
454
+	 */
455
+	protected function _get_billing_values_from_form($billing_form)
456
+	{
457
+		if ($billing_form instanceof EE_Form_Section_Proper) {
458
+			return $billing_form->input_pretty_values(true);
459
+		} else {
460
+			return NULL;
461
+		}
462
+	}
463
+
464
+
465
+	/**
466
+	 * Handles an instant payment notification when the transaction is known (by default).
467
+	 * @param array $req_data
468
+	 * @param EE_Transaction $transaction
469
+	 * @return EE_Payment
470
+	 * @throws EE_Error
471
+	 */
472
+	public function handle_ipn($req_data, $transaction)
473
+	{
474
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
475
+		if (!$this->_gateway instanceof EE_Offsite_Gateway) {
476
+			throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r($this->_gateway, TRUE)));
477
+
478
+		}
479
+		$payment = $this->_gateway->handle_payment_update($req_data, $transaction);
480
+		return $payment;
481
+	}
482
+
483
+
484
+	/**
485
+	 * Saves the billing info onto the attendee of the primary registrant on this transaction, and
486
+	 * cleans it first.
487
+	 * @param EE_Billing_Attendee_Info_Form $billing_form
488
+	 * @param EE_Transaction $transaction
489
+	 * @return boolean success
490
+	 */
491
+	protected function _save_billing_info_to_attendee($billing_form, $transaction)
492
+	{
493
+		if (!$transaction || !$transaction instanceof EE_Transaction) {
494
+			EE_Error::add_error(__("Cannot save billing info because no transaction was specified", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
495
+			return false;
496
+		}
497
+		$primary_reg = $transaction->primary_registration();
498
+		if (!$primary_reg) {
499
+			EE_Error::add_error(__("Cannot save billing info because the transaction has no primary registration", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
500
+			return false;
501
+		}
502
+		$attendee = $primary_reg->attendee();
503
+		if (!$attendee) {
504
+			EE_Error::add_error(__("Cannot save billing info because the transaction's primary registration has no attendee!", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
505
+			return false;
506
+		}
507
+		return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method());
508
+
509
+	}
510
+
511
+
512
+	/**
513
+	 * Gets the payment this IPN is for. Children may often want to
514
+	 * override this to inspect the request
515
+	 * @param EE_Transaction $transaction
516
+	 * @param array $req_data
517
+	 * @return EE_Payment
518
+	 */
519
+	protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array())
520
+	{
521
+		return $transaction->last_payment();
522
+	}
523
+
524
+
525
+	/**
526
+	 * In case generic code cannot provide the payment processor with a specific payment method
527
+	 * and transaction, it will try calling this method on each activate payment method.
528
+	 * If the payment method is able to identify the request as being for it, it should fetch
529
+	 * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot
530
+	 * handle the IPN
531
+	 * @param array $req_data
532
+	 * @return EE_Payment only if this payment method can find the info its needs from $req_data
533
+	 * and identifies the IPN as being for this payment method (not just fo ra payment method of this type)
534
+	 * @throws EE_Error
535
+	 */
536
+	public function handle_unclaimed_ipn($req_data = array())
537
+	{
538
+		throw new EE_Error(sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this)));
539
+	}
540
+
541
+
542
+	/**
543
+	 * Logic to be accomplished when the payment attempt is complete.
544
+	 * Most payment methods don't need to do anything at this point; but some, like Mijireh, do.
545
+	 * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from
546
+	 * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status
547
+	 * of the payment). Fed a transaction because it's always assumed to be the last payment that
548
+	 * we're dealing with. Returns that last payment (if there is one)
549
+	 *
550
+	 * @param EE_Transaction $transaction
551
+	 * @return EE_Payment
552
+	 */
553
+	public function finalize_payment_for($transaction)
554
+	{
555
+		return $transaction->last_payment();
556
+	}
557
+
558
+
559
+	/**
560
+	 * Whether or not this payment method's gateway supports sending refund requests
561
+	 * @return boolean
562
+	 */
563
+	public function supports_sending_refunds()
564
+	{
565
+		if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
566
+			return $this->_gateway->supports_sending_refunds();
567
+		} else {
568
+			return false;
569
+		}
570
+	}
571
+
572
+
573
+	/**
574
+	 *
575
+	 * @param EE_Payment $payment
576
+	 * @param array $refund_info
577
+	 * @throws EE_Error
578
+	 * @return EE_Payment
579
+	 */
580
+	public function process_refund(EE_Payment $payment, $refund_info = array())
581
+	{
582
+		if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
583
+			return $this->_gateway->do_direct_refund($payment, $refund_info);
584
+		} else {
585
+			throw new EE_Error(
586
+				sprintf(
587
+					__('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'),
588
+					get_class($this)
589
+				)
590
+			);
591
+		}
592
+	}
593
+
594
+
595
+	/**
596
+	 * Returns one the class's constants onsite,offsite, or offline, depending on this
597
+	 * payment method's gateway.
598
+	 * @return string
599
+	 * @throws EE_Error
600
+	 */
601
+	public function payment_occurs()
602
+	{
603
+		if (!$this->_gateway) {
604
+			return EE_PMT_Base::offline;
605
+		} elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
606
+			return EE_PMT_Base::onsite;
607
+		} elseif ($this->_gateway instanceof EE_Offsite_Gateway) {
608
+			return EE_PMT_Base::offsite;
609
+		} else {
610
+			throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"), get_class($this)));
611
+		}
612
+	}
613
+
614
+
615
+	/**
616
+	 * For adding any html output ab ove the payment overview.
617
+	 * Many gateways won't want ot display anything, so this function just returns an empty string.
618
+	 * Other gateways may want to override this, such as offline gateways.
619
+	 * @param EE_Payment $payment
620
+	 * @return string
621
+	 */
622
+	public function payment_overview_content(EE_Payment $payment)
623
+	{
624
+		return EEH_Template::display_template(EE_LIBRARIES . 'payment_methods' . DS . 'templates' . DS . 'payment_details_content.template.php', array('payment_method' => $this->_pm_instance, 'payment' => $payment), true);
625
+	}
626
+
627
+
628
+	/**
629
+	 * @return array where keys are the help tab name,
630
+	 * values are: array {
631
+	 * @type string $title i18n name for the help tab
632
+	 * @type string $filename name of the file located in ./help_tabs/ (ie, in a folder next to this file)
633
+	 * @type array $template_args any arguments you want passed to the template file while rendering.
634
+	 *                Keys will be variable names and values with be their values.
635
+	 */
636
+	public function help_tabs_config()
637
+	{
638
+		return array();
639
+	}
640
+
641
+
642
+	/**
643
+	 * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into
644
+	 * the payment method's table's PMT_type column)
645
+	 * @return string
646
+	 */
647
+	public function system_name()
648
+	{
649
+		$classname = get_class($this);
650
+		return str_replace("EE_PMT_", '', $classname);
651
+	}
652
+
653
+
654
+	/**
655
+	 * A pretty i18n version of the PMT name
656
+	 * @return string
657
+	 */
658
+	public function pretty_name()
659
+	{
660
+		return $this->_pretty_name;
661
+	}
662
+
663
+
664
+	/**
665
+	 * Gets the default absolute URL to the payment method type's button
666
+	 * @return string
667
+	 */
668
+	public function default_button_url()
669
+	{
670
+		return $this->_default_button_url;
671
+	}
672
+
673
+
674
+	/**
675
+	 * Gets the gateway used by this payment method (if any)
676
+	 * @return EE_Gateway
677
+	 */
678
+	public function get_gateway()
679
+	{
680
+		return $this->_gateway;
681
+	}
682
+
683
+
684
+	/**
685
+	 * @return string html for the link to a help tab
686
+	 */
687
+	public function get_help_tab_link()
688
+	{
689
+		return EEH_Template::get_help_tab_link($this->get_help_tab_name());
690
+	}
691
+
692
+
693
+	/**
694
+	 * Returns the name of the help tab for this PMT
695
+	 * @return string
696
+	 */
697
+	public function get_help_tab_name()
698
+	{
699
+		return 'ee_' . strtolower($this->system_name()) . '_help_tab';
700
+	}
701
+
702
+	/**
703
+	 * The name of the wp capability that should be associated with the usage of
704
+	 * this PMT by an admin
705
+	 * @return string
706
+	 */
707
+	public function cap_name()
708
+	{
709
+		return 'ee_payment_method_' . strtolower($this->system_name());
710
+	}
711
+
712
+	/**
713
+	 * Called by client code to tell the gateway that if it wants to change
714
+	 * the transaction or line items or registrations related to teh payment it already
715
+	 * processed (we think, but possibly not) that now's the time to do it.
716
+	 * It is expected that gateways will store any info they need for this on the PAY_details,
717
+	 * or maybe an extra meta value
718
+	 * @param EE_Payment $payment
719
+	 * @return void
720
+	 */
721
+	public function update_txn_based_on_payment($payment)
722
+	{
723
+		if ($this->_gateway instanceof EE_Gateway) {
724
+			$this->_gateway->update_txn_based_on_payment($payment);
725
+		}
726
+	}
727
+
728
+	/**
729
+	 * Returns a string of HTML describing this payment method type for an admin,
730
+	 * primarily intended for them to read before activating it.
731
+	 * The easiest way to set this is to create a folder 'templates' alongside
732
+	 * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php".
733
+	 * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php",
734
+	 * then you'd create a file named "templates" in the same folder as it, and name the file
735
+	 * "foo_bar_intro.template.php", and its content will be returned by this method
736
+	 * @return string
737
+	 */
738
+	public function introductory_html()
739
+	{
740
+		return EEH_Template::locate_template($this->file_folder() . 'templates' . DS . strtolower($this->system_name()) . '_intro.template.php', array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance));
741
+	}
742 742
 
743 743
 
744 744
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             $this->_gateway->set_unsupported_character_remover(new AsciiOnly());
115 115
             do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway);
116 116
         }
117
-        if (!isset($this->_has_billing_form)) {
117
+        if ( ! isset($this->_has_billing_form)) {
118 118
             // by default, On Site gateways have a billing form
119 119
             if ($this->payment_occurs() == EE_PMT_Base::onsite) {
120 120
                 $this->set_has_billing_form(true);
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
             }
124 124
         }
125 125
 
126
-        if (!$this->_pretty_name) {
126
+        if ( ! $this->_pretty_name) {
127 127
             throw new EE_Error(sprintf(__("You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", "event_espresso")));
128 128
         }
129 129
         //if the child didn't specify a default button, use the credit card one
130 130
         if ($this->_default_button_url === NULL) {
131
-            $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods' . DS . 'pay-by-credit-card.png';
131
+            $this->_default_button_url = EE_PLUGIN_DIR_URL.'payment_methods'.DS.'pay-by-credit-card.png';
132 132
         }
133 133
     }
134 134
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     {
150 150
         $reflector = new ReflectionClass(get_class($this));
151 151
         $fn = $reflector->getFileName();
152
-        $this->_file_folder = dirname($fn) . DS;
152
+        $this->_file_folder = dirname($fn).DS;
153 153
     }
154 154
 
155 155
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      */
181 181
     public function file_folder()
182 182
     {
183
-        if (!$this->_file_folder) {
183
+        if ( ! $this->_file_folder) {
184 184
             $this->_set_file_folder();
185 185
         }
186 186
         return $this->_file_folder;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      */
193 193
     public function file_url()
194 194
     {
195
-        if (!$this->_file_url) {
195
+        if ( ! $this->_file_url) {
196 196
             $this->_set_file_url();
197 197
         }
198 198
         return $this->_file_url;
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      */
225 225
     function settings_form()
226 226
     {
227
-        if (!$this->_settings_form) {
227
+        if ( ! $this->_settings_form) {
228 228
             $this->_settings_form = $this->generate_new_settings_form();
229 229
             $this->_settings_form->set_payment_method_type($this);
230 230
             //if we have already assigned a model object to this pmt, make
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
     public function billing_form(EE_Transaction $transaction = NULL, $extra_args = array())
277 277
     {
278 278
         // has billing form already been regenerated ? or overwrite cache?
279
-        if (!$this->_billing_form instanceof EE_Billing_Info_Form || !$this->_cache_billing_form) {
279
+        if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
280 280
             $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args);
281 281
         }
282 282
         //if we know who the attendee is, and this is a billing form
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
             $payment = EEM_Payment::instance()->get_one(array($duplicate_properties));
372 372
             //if we didn't already have a payment in progress for the same thing,
373 373
             //then we actually want to make a new payment
374
-            if (!$payment instanceof EE_Payment) {
374
+            if ( ! $payment instanceof EE_Payment) {
375 375
                 $payment = EE_Payment::new_instance(
376 376
                     array_merge(
377 377
                         $duplicate_properties,
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
     public function handle_ipn($req_data, $transaction)
473 473
     {
474 474
         $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
475
-        if (!$this->_gateway instanceof EE_Offsite_Gateway) {
475
+        if ( ! $this->_gateway instanceof EE_Offsite_Gateway) {
476 476
             throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r($this->_gateway, TRUE)));
477 477
 
478 478
         }
@@ -490,17 +490,17 @@  discard block
 block discarded – undo
490 490
      */
491 491
     protected function _save_billing_info_to_attendee($billing_form, $transaction)
492 492
     {
493
-        if (!$transaction || !$transaction instanceof EE_Transaction) {
493
+        if ( ! $transaction || ! $transaction instanceof EE_Transaction) {
494 494
             EE_Error::add_error(__("Cannot save billing info because no transaction was specified", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
495 495
             return false;
496 496
         }
497 497
         $primary_reg = $transaction->primary_registration();
498
-        if (!$primary_reg) {
498
+        if ( ! $primary_reg) {
499 499
             EE_Error::add_error(__("Cannot save billing info because the transaction has no primary registration", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
500 500
             return false;
501 501
         }
502 502
         $attendee = $primary_reg->attendee();
503
-        if (!$attendee) {
503
+        if ( ! $attendee) {
504 504
             EE_Error::add_error(__("Cannot save billing info because the transaction's primary registration has no attendee!", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
505 505
             return false;
506 506
         }
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
      */
601 601
     public function payment_occurs()
602 602
     {
603
-        if (!$this->_gateway) {
603
+        if ( ! $this->_gateway) {
604 604
             return EE_PMT_Base::offline;
605 605
         } elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
606 606
             return EE_PMT_Base::onsite;
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
      */
622 622
     public function payment_overview_content(EE_Payment $payment)
623 623
     {
624
-        return EEH_Template::display_template(EE_LIBRARIES . 'payment_methods' . DS . 'templates' . DS . 'payment_details_content.template.php', array('payment_method' => $this->_pm_instance, 'payment' => $payment), true);
624
+        return EEH_Template::display_template(EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php', array('payment_method' => $this->_pm_instance, 'payment' => $payment), true);
625 625
     }
626 626
 
627 627
 
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
      */
697 697
     public function get_help_tab_name()
698 698
     {
699
-        return 'ee_' . strtolower($this->system_name()) . '_help_tab';
699
+        return 'ee_'.strtolower($this->system_name()).'_help_tab';
700 700
     }
701 701
 
702 702
     /**
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
      */
707 707
     public function cap_name()
708 708
     {
709
-        return 'ee_payment_method_' . strtolower($this->system_name());
709
+        return 'ee_payment_method_'.strtolower($this->system_name());
710 710
     }
711 711
 
712 712
     /**
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
      */
738 738
     public function introductory_html()
739 739
     {
740
-        return EEH_Template::locate_template($this->file_folder() . 'templates' . DS . strtolower($this->system_name()) . '_intro.template.php', array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance));
740
+        return EEH_Template::locate_template($this->file_folder().'templates'.DS.strtolower($this->system_name()).'_intro.template.php', array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance));
741 741
     }
742 742
 
743 743
 
Please login to merge, or discard this patch.
acceptance_tests/tests/b-TestRegistrationSummaryCept.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
 
15 15
 //need the MER plugin active for this test (we'll deactivate it after).
16 16
 $I->ensurePluginActive(
17
-    'event-espresso-mer-multi-event-registration',
18
-    'activated'
17
+	'event-espresso-mer-multi-event-registration',
18
+	'activated'
19 19
 );
20 20
 
21 21
 //k now we need to make sure the registration multi-status message type is active because it isn't by default
@@ -73,38 +73,38 @@  discard block
 block discarded – undo
73 73
 $I->loginAsAdmin();
74 74
 $I->amOnMessagesActivityListTablePage();
75 75
 $I->see(
76
-    '[email protected]',
77
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
78
-        'to',
79
-        'Registration Multi-status Summary',
80
-        MessagesAdmin::MESSAGE_STATUS_SENT,
81
-        '',
82
-        'Primary Registrant'
83
-    )
76
+	'[email protected]',
77
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
78
+		'to',
79
+		'Registration Multi-status Summary',
80
+		MessagesAdmin::MESSAGE_STATUS_SENT,
81
+		'',
82
+		'Primary Registrant'
83
+	)
84 84
 );
85 85
 $I->see(
86
-    '[email protected]',
87
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
88
-        'to',
89
-        'Registration Multi-status Summary',
90
-        MessagesAdmin::MESSAGE_STATUS_SENT
91
-    )
86
+	'[email protected]',
87
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
88
+		'to',
89
+		'Registration Multi-status Summary',
90
+		MessagesAdmin::MESSAGE_STATUS_SENT
91
+	)
92 92
 );
93 93
 //verify count
94 94
 $I->verifyMatchingCountofTextInMessageActivityListTableFor(
95
-    1,
96
-    '[email protected]',
97
-    'to',
98
-    'Registration Multi-status Summary',
99
-    MessagesAdmin::MESSAGE_STATUS_SENT,
100
-    'Email',
101
-    'Primary Registrant'
95
+	1,
96
+	'[email protected]',
97
+	'to',
98
+	'Registration Multi-status Summary',
99
+	MessagesAdmin::MESSAGE_STATUS_SENT,
100
+	'Email',
101
+	'Primary Registrant'
102 102
 );
103 103
 $I->verifyMatchingCountofTextInMessageActivityListTableFor(
104
-    1,
105
-    '[email protected]',
106
-    'to',
107
-    'Registration Multi-status Summary'
104
+	1,
105
+	'[email protected]',
106
+	'to',
107
+	'Registration Multi-status Summary'
108 108
 );
109 109
 
110 110
 //okay now let's do some registrations for just the first event and verify that registration multi-status summary is NOT
@@ -134,25 +134,25 @@  discard block
 block discarded – undo
134 134
 $I->loginAsAdmin();
135 135
 $I->amOnMessagesActivityListTablePage();
136 136
 $I->dontSee(
137
-    '[email protected]',
138
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
139
-        'to',
140
-        'Registration Multi-status Summary',
141
-        MessagesAdmin::MESSAGE_STATUS_SENT,
142
-        '',
143
-        'Primary Registrant'
144
-    )
137
+	'[email protected]',
138
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
139
+		'to',
140
+		'Registration Multi-status Summary',
141
+		MessagesAdmin::MESSAGE_STATUS_SENT,
142
+		'',
143
+		'Primary Registrant'
144
+	)
145 145
 );
146 146
 //there should still only be one admin multi-status summary thing.
147 147
 $I->verifyMatchingCountofTextInMessageActivityListTableFor(
148
-    1,
149
-    '[email protected]',
150
-    'to',
151
-    'Registration Multi-status Summary'
148
+	1,
149
+	'[email protected]',
150
+	'to',
151
+	'Registration Multi-status Summary'
152 152
 );
153 153
 
154 154
 //deactivate MER plugin so its not active for future tests
155 155
 $I->ensurePluginDeactivated(
156
-    'event-espresso-mer-multi-event-registration',
157
-    'plugins deactivated'
156
+	'event-espresso-mer-multi-event-registration',
157
+	'plugins deactivated'
158 158
 );
159 159
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/tests/c-TestCustomMessageTemplateCept.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 $event_one_link = $event_two_link = $event_three_link = '';
19 19
 
20 20
 $I->wantTo(
21
-    'Test that when registrations for multiple events are completed, and those events share the same custom'
22
-    . 'template, that that custom template will be used.'
21
+	'Test that when registrations for multiple events are completed, and those events share the same custom'
22
+	. 'template, that that custom template will be used.'
23 23
 );
24 24
 
25 25
 //need the MER plugin active for this test (we'll deactivate it after).
26 26
 $I->ensurePluginActive(
27
-    'event-espresso-mer-multi-event-registration',
28
-    'activated'
27
+	'event-espresso-mer-multi-event-registration',
28
+	'activated'
29 29
 );
30 30
 
31 31
 $I->loginAsAdmin();
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 
81 81
 
82 82
 $test_registration_details = array(
83
-    'fname' => 'CTGuy',
84
-    'lname' => 'Dude',
85
-    'email' => '[email protected]'
83
+	'fname' => 'CTGuy',
84
+	'lname' => 'Dude',
85
+	'email' => '[email protected]'
86 86
 );
87 87
 
88 88
 $I->amGoingTo('Register for Event One and Event Two and verify Custom Template A was used.');
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
 $I->loginAsAdmin();
109 109
 $I->amOnMessagesActivityListTablePage();
110 110
 $I->viewMessageInMessagesListTableFor(
111
-    'Registration Approved',
112
-    MessagesAdmin::MESSAGE_STATUS_SENT,
113
-    'Email',
114
-    'Registrant'
111
+	'Registration Approved',
112
+	MessagesAdmin::MESSAGE_STATUS_SENT,
113
+	'Email',
114
+	'Registrant'
115 115
 );
116 116
 $I->seeTextInViewMessageModal($custom_template_a_label);
117 117
 $I->dismissMessageModal();
118 118
 $I->deleteMessageInMessagesListTableFor(
119
-    'Registration Approved',
120
-    MessagesAdmin::MESSAGE_STATUS_SENT,
121
-    'Email',
122
-    'Registrant'
119
+	'Registration Approved',
120
+	MessagesAdmin::MESSAGE_STATUS_SENT,
121
+	'Email',
122
+	'Registrant'
123 123
 );
124 124
 
125 125
 //verify admin context
126 126
 $I->viewMessageInMessagesListTableFor(
127
-    'Registration Approved'
127
+	'Registration Approved'
128 128
 );
129 129
 $I->seeTextInViewMessageModal($custom_template_a_label);
130 130
 $I->dismissMessageModal();
@@ -153,25 +153,25 @@  discard block
 block discarded – undo
153 153
 $I->loginAsAdmin();
154 154
 $I->amOnMessagesActivityListTablePage();
155 155
 $I->viewMessageInMessagesListTableFor(
156
-    'Registration Approved',
157
-    MessagesAdmin::MESSAGE_STATUS_SENT,
158
-    'Email',
159
-    'Registrant'
156
+	'Registration Approved',
157
+	MessagesAdmin::MESSAGE_STATUS_SENT,
158
+	'Email',
159
+	'Registrant'
160 160
 );
161 161
 $I->waitForElementVisible(MessagesAdmin::MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR);
162 162
 $I->dontSeeTextInViewMessageModal($custom_template_a_label);
163 163
 $I->dontSeeTextInViewMessageModal($custom_template_b_label);
164 164
 $I->dismissMessageModal();
165 165
 $I->deleteMessageInMessagesListTableFor(
166
-    'Registration Approved',
167
-    MessagesAdmin::MESSAGE_STATUS_SENT,
168
-    'Email',
169
-    'Registrant'
166
+	'Registration Approved',
167
+	MessagesAdmin::MESSAGE_STATUS_SENT,
168
+	'Email',
169
+	'Registrant'
170 170
 );
171 171
 
172 172
 //verify admin context
173 173
 $I->viewMessageInMessagesListTableFor(
174
-    'Registration Approved'
174
+	'Registration Approved'
175 175
 );
176 176
 $I->waitForElementVisible(MessagesAdmin::MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR);
177 177
 $I->dontSee($custom_template_a_label);
@@ -183,6 +183,6 @@  discard block
 block discarded – undo
183 183
 
184 184
 //deactivate MER plugin so its not active for future tests
185 185
 $I->ensurePluginDeactivated(
186
-    'event-espresso-mer-multi-event-registration',
187
-    'plugins deactivated'
186
+	'event-espresso-mer-multi-event-registration',
187
+	'plugins deactivated'
188 188
 );
189 189
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Helpers/EventsAdmin.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -14,133 +14,133 @@
 block discarded – undo
14 14
 trait EventsAdmin
15 15
 {
16 16
 
17
-    /**
18
-     * @param string $additional_params
19
-     */
20
-    public function amOnDefaultEventsListTablePage($additional_params = '')
21
-    {
22
-        $this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params));
23
-    }
24
-
25
-
26
-    /**
27
-     * Triggers the publishing of the Event.
28
-     */
29
-    public function publishEvent()
30
-    {
31
-        $this->actor()->scrollTo(EventsPage::EVENT_EDITOR_TITLE_FIELD_SELECTOR);
32
-        $this->actor()->wait(2);
33
-        $this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR);
34
-        $this->actor()->waitForText('Event published.', 30);
35
-    }
36
-
37
-
38
-    /**
39
-     * Triggers saving the Event.
40
-     */
41
-    public function saveEvent()
42
-    {
43
-        $this->actor()->scrollTo(EventsPage::EVENT_EDITOR_TITLE_FIELD_SELECTOR);
44
-        $this->actor()->wait(2);
45
-        $this->actor()->click(EventsPage::EVENT_EDITOR_SAVE_BUTTON_SELECTOR);
46
-    }
47
-
48
-
49
-    /**
50
-     * Navigates the actor to the event list table page and will attempt to edit the event for the given title.
51
-     * First this will search using the given title and then attempt to edit from the results of the search.
52
-     *
53
-     * Assumes actor is already logged in.
54
-     * @param $event_title
55
-     */
56
-    public function amEditingTheEventWithTitle($event_title)
57
-    {
58
-        $this->amOnDefaultEventsListTablePage();
59
-        $this->actor()->fillField(EventsPage::EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR, $event_title);
60
-        $this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR);
61
-        $this->actor()->waitForText($event_title, 15);
62
-        $this->actor()->click(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
63
-    }
64
-
65
-
66
-    /**
67
-     * Navigates the user to the single event page (frontend view) for the given event title via clicking the "View"
68
-     * link for the event in the event list table.
69
-     * Assumes the actor is already logged in and on the Event list table page.
70
-     *
71
-     * @param string $event_title
72
-     */
73
-    public function amOnEventPageAfterClickingViewLinkInListTableForEvent($event_title)
74
-    {
75
-        $this->actor()->moveMouseOver(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
76
-        $this->actor()->click(EventsPage::eventListTableEventTitleViewLinkSelectorForTitle($event_title));
77
-    }
78
-
79
-
80
-    /**
81
-     * Used to retrieve the event id for the event via the list table and for the given event.
82
-     * @param string $event_title
83
-     */
84
-    public function observeEventIdInListTableForEvent($event_title)
85
-    {
86
-        return $this->actor()->observeValueFromInputAt(EventsPage::eventListTableEventIdSelectorForTitle($event_title));
87
-    }
88
-
89
-
90
-    /**
91
-     * This performs the click action on the gear icon that triggers the advanced settings view state.
92
-     * Assumes the actor is already logged in and editing an event.
93
-     *
94
-     * @param int $row_number  What ticket row to toggle open/close.
95
-     */
96
-    public function toggleAdvancedSettingsViewForTicketRow($row_number = 1)
97
-    {
98
-        $this->actor()->click(EventsPage::eventEditorTicketAdvancedDetailsSelector($row_number));
99
-    }
100
-
101
-
102
-    /**
103
-     * Toggles the TKT_is_taxable checkbox for the ticket in the given row.
104
-     * Assumes the actor is already logged in and editing an event and that the advanced settings view state for that
105
-     * ticket is "open".
106
-     *
107
-     * @param int $row_number  What ticket row to toggle the checkbox for.
108
-     */
109
-    public function toggleTicketIsTaxableForTicketRow($row_number = 1)
110
-    {
111
-        $this->actor()->click(EventsPage::eventEditorTicketTaxableCheckboxSelector($row_number));
112
-    }
113
-
114
-
115
-    /**
116
-     * Use to change the default registration status for the event.
117
-     * Assumes the view is already on the event editor.
118
-     * @param $registration_status
119
-     */
120
-    public function changeDefaultRegistrationStatusTo($registration_status)
121
-    {
122
-        $this->actor()->selectOption(
123
-            EventsPage::EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR,
124
-            $registration_status
125
-        );
126
-    }
127
-
128
-
129
-    /**
130
-     * Use this from the context of the event editor to select the given custom template for a given message type and
131
-     * messenger.
132
-     *
133
-     * @param string $message_type_label  The visible label for the message type (eg Registration Approved)
134
-     * @param string $messenger_slug      The slug for the messenger (eg 'email')
135
-     * @param string $custom_template_label The visible label in the select input for the custom template you want
136
-     *                                      selected.
137
-     */
138
-    public function selectCustomTemplateFor($message_type_label, $messenger_slug, $custom_template_label)
139
-    {
140
-        $this->actor()->click(EventsPage::eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug));
141
-        $this->actor()->selectOption(
142
-            EventsPage::eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label),
143
-            $custom_template_label
144
-        );
145
-    }
17
+	/**
18
+	 * @param string $additional_params
19
+	 */
20
+	public function amOnDefaultEventsListTablePage($additional_params = '')
21
+	{
22
+		$this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params));
23
+	}
24
+
25
+
26
+	/**
27
+	 * Triggers the publishing of the Event.
28
+	 */
29
+	public function publishEvent()
30
+	{
31
+		$this->actor()->scrollTo(EventsPage::EVENT_EDITOR_TITLE_FIELD_SELECTOR);
32
+		$this->actor()->wait(2);
33
+		$this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR);
34
+		$this->actor()->waitForText('Event published.', 30);
35
+	}
36
+
37
+
38
+	/**
39
+	 * Triggers saving the Event.
40
+	 */
41
+	public function saveEvent()
42
+	{
43
+		$this->actor()->scrollTo(EventsPage::EVENT_EDITOR_TITLE_FIELD_SELECTOR);
44
+		$this->actor()->wait(2);
45
+		$this->actor()->click(EventsPage::EVENT_EDITOR_SAVE_BUTTON_SELECTOR);
46
+	}
47
+
48
+
49
+	/**
50
+	 * Navigates the actor to the event list table page and will attempt to edit the event for the given title.
51
+	 * First this will search using the given title and then attempt to edit from the results of the search.
52
+	 *
53
+	 * Assumes actor is already logged in.
54
+	 * @param $event_title
55
+	 */
56
+	public function amEditingTheEventWithTitle($event_title)
57
+	{
58
+		$this->amOnDefaultEventsListTablePage();
59
+		$this->actor()->fillField(EventsPage::EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR, $event_title);
60
+		$this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR);
61
+		$this->actor()->waitForText($event_title, 15);
62
+		$this->actor()->click(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
63
+	}
64
+
65
+
66
+	/**
67
+	 * Navigates the user to the single event page (frontend view) for the given event title via clicking the "View"
68
+	 * link for the event in the event list table.
69
+	 * Assumes the actor is already logged in and on the Event list table page.
70
+	 *
71
+	 * @param string $event_title
72
+	 */
73
+	public function amOnEventPageAfterClickingViewLinkInListTableForEvent($event_title)
74
+	{
75
+		$this->actor()->moveMouseOver(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
76
+		$this->actor()->click(EventsPage::eventListTableEventTitleViewLinkSelectorForTitle($event_title));
77
+	}
78
+
79
+
80
+	/**
81
+	 * Used to retrieve the event id for the event via the list table and for the given event.
82
+	 * @param string $event_title
83
+	 */
84
+	public function observeEventIdInListTableForEvent($event_title)
85
+	{
86
+		return $this->actor()->observeValueFromInputAt(EventsPage::eventListTableEventIdSelectorForTitle($event_title));
87
+	}
88
+
89
+
90
+	/**
91
+	 * This performs the click action on the gear icon that triggers the advanced settings view state.
92
+	 * Assumes the actor is already logged in and editing an event.
93
+	 *
94
+	 * @param int $row_number  What ticket row to toggle open/close.
95
+	 */
96
+	public function toggleAdvancedSettingsViewForTicketRow($row_number = 1)
97
+	{
98
+		$this->actor()->click(EventsPage::eventEditorTicketAdvancedDetailsSelector($row_number));
99
+	}
100
+
101
+
102
+	/**
103
+	 * Toggles the TKT_is_taxable checkbox for the ticket in the given row.
104
+	 * Assumes the actor is already logged in and editing an event and that the advanced settings view state for that
105
+	 * ticket is "open".
106
+	 *
107
+	 * @param int $row_number  What ticket row to toggle the checkbox for.
108
+	 */
109
+	public function toggleTicketIsTaxableForTicketRow($row_number = 1)
110
+	{
111
+		$this->actor()->click(EventsPage::eventEditorTicketTaxableCheckboxSelector($row_number));
112
+	}
113
+
114
+
115
+	/**
116
+	 * Use to change the default registration status for the event.
117
+	 * Assumes the view is already on the event editor.
118
+	 * @param $registration_status
119
+	 */
120
+	public function changeDefaultRegistrationStatusTo($registration_status)
121
+	{
122
+		$this->actor()->selectOption(
123
+			EventsPage::EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR,
124
+			$registration_status
125
+		);
126
+	}
127
+
128
+
129
+	/**
130
+	 * Use this from the context of the event editor to select the given custom template for a given message type and
131
+	 * messenger.
132
+	 *
133
+	 * @param string $message_type_label  The visible label for the message type (eg Registration Approved)
134
+	 * @param string $messenger_slug      The slug for the messenger (eg 'email')
135
+	 * @param string $custom_template_label The visible label in the select input for the custom template you want
136
+	 *                                      selected.
137
+	 */
138
+	public function selectCustomTemplateFor($message_type_label, $messenger_slug, $custom_template_label)
139
+	{
140
+		$this->actor()->click(EventsPage::eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug));
141
+		$this->actor()->selectOption(
142
+			EventsPage::eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label),
143
+			$custom_template_label
144
+		);
145
+	}
146 146
 }
147 147
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Helpers/MessagesAdmin.php 1 patch
Indentation   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -10,296 +10,296 @@
 block discarded – undo
10 10
  */
11 11
 trait MessagesAdmin
12 12
 {
13
-    /**
14
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
15
-     *                                  a string.
16
-     */
17
-    public function amOnMessagesActivityListTablePage($additional_params = '')
18
-    {
19
-        $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params));
20
-    }
21
-
22
-    /**
23
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
24
-     *                                  a string.
25
-     */
26
-    public function amOnDefaultMessageTemplateListTablePage($additional_params = '')
27
-    {
28
-        $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params));
29
-    }
30
-
31
-
32
-    /**
33
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
34
-     *                                  a string.
35
-     */
36
-    public function amOnCustomMessageTemplateListTablePage($additional_params = '')
37
-    {
38
-        $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params));
39
-    }
40
-
41
-
42
-    /**
43
-     * Directs to message settings page
44
-     */
45
-    public function amOnMessageSettingsPage()
46
-    {
47
-        $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl());
48
-    }
49
-
50
-
51
-    public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email')
52
-    {
53
-        $this->actor()->dragAndDrop(
54
-            MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug),
55
-            MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR
56
-        );
57
-    }
58
-
59
-
60
-    /**
61
-     * Assumes you are already on the list table page that has the ui for editing the template.
62
-     * @param string $message_type_slug
63
-     * @param string $context [optional] if you want to click directly to the given context in the editor
64
-     */
65
-    public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '')
66
-    {
67
-        $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context));
68
-    }
69
-
70
-
71
-    /**
72
-     * Use this action to verify that the count for the given text in the specified field is as expected.  For example
73
-     * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column.
74
-     *
75
-     * @param int    $expected_occurence_count
76
-     * @param string $text_to_check_for
77
-     * @param string $field
78
-     * @param string $message_type_label
79
-     * @param string $message_status
80
-     * @param string $messenger
81
-     * @param string $context
82
-     */
83
-    public function verifyMatchingCountofTextInMessageActivityListTableFor(
84
-        $expected_occurence_count,
85
-        $text_to_check_for,
86
-        $field,
87
-        $message_type_label,
88
-        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
89
-        $messenger = 'Email',
90
-        $context = 'Event Admin'
91
-    ) {
92
-        $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor(
93
-            $field,
94
-            $message_type_label,
95
-            $message_status,
96
-            $messenger,
97
-            $context,
98
-            $text_to_check_for,
99
-            0
100
-        ));
101
-        $actual_count = count($elements);
102
-        $this->actor()->assertEquals(
103
-            $expected_occurence_count,
104
-            $actual_count,
105
-            sprintf(
106
-                'Expected %s of the %s text for the %s field but there were actually %s counted.',
107
-                $expected_occurence_count,
108
-                $text_to_check_for,
109
-                $field,
110
-                $actual_count
111
-            )
112
-        );
113
-    }
114
-
115
-
116
-    /**
117
-     * This will create a custom message template for the given messenger and message type from the context of the
118
-     * default (global) message template list table.
119
-     * Also takes care of verifying the template was created.
120
-     * @param string $message_type_label
121
-     * @param string $messenger_label
122
-     */
123
-    public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label)
124
-    {
125
-        $this->amOnDefaultMessageTemplateListTablePage();
126
-        $this->actor()->click(
127
-            MessagesPage::createCustomButtonForMessageTypeAndMessenger(
128
-                $message_type_label,
129
-                $messenger_label
130
-            )
131
-        );
132
-        $this->actor()->seeInField('#title', 'New Custom Template');
133
-    }
134
-
135
-
136
-    /**
137
-     * This switches the context of the current messages template to the given reference.
138
-     * @param string $context_reference  This should be the visible label for the option.
139
-     */
140
-    public function switchContextTo($context_reference)
141
-    {
142
-        $this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference);
143
-        $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR);
144
-        $this->actor()->waitForText($context_reference, 10, 'h1');
145
-    }
146
-
147
-
148
-    /**
149
-     * Toggles Context so its turned off or on (depending on where it started) and verifies the expected state after
150
-     * toggling.
151
-     *
152
-     * @param string $context_string           What context is being switched (used for the expected state text)
153
-     * @param bool   $expected_state_is_active Used to indicate whether the expected state is active (true) or inactive
154
-     *                                         (false)
155
-     */
156
-    public function toggleContextState($context_string, $expected_state_is_active = true)
157
-    {
158
-        $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE);
159
-        if ($expected_state_is_active) {
160
-            $this->actor()->waitForText("The template for $context_string is currently active.");
161
-        } else {
162
-            $this->actor()->waitForText("The template for $context_string is currently inactive");
163
-        }
164
-    }
165
-
166
-
167
-    /**
168
-     * Triggers saving the message template.
169
-     * @param bool $and_close   Use to indicate to click the Save and Close button.
170
-     */
171
-    public function saveMessageTemplate($and_close = false)
172
-    {
173
-        $this->actor()->scrollTo(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR);
174
-        if ($and_close) {
175
-            $this->actor()->click('Save and Close');
176
-        } else {
177
-            $this->actor()->click('Save');
178
-        }
179
-        $this->actor()->waitForText('successfully updated');
180
-    }
181
-
182
-
183
-    /**
184
-     * This takes care of clicking the View Message icon for the given parameters.
185
-     * Assumes you are already viewing the messages activity list table.
186
-     * @param        $message_type_label
187
-     * @param        $message_status
188
-     * @param string $messenger
189
-     * @param string $context
190
-     * @param int    $number_in_set
191
-     */
192
-    public function viewMessageInMessagesListTableFor(
193
-        $message_type_label,
194
-        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
195
-        $messenger = 'Email',
196
-        $context = 'Event Admin',
197
-        $number_in_set = 1
198
-    ) {
199
-        $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor(
200
-            $message_type_label,
201
-            $message_status,
202
-            $messenger,
203
-            $context,
204
-            $number_in_set
205
-        ));
206
-    }
207
-
208
-
209
-    /**
210
-     * Takes care of deleting a message matching the given parameters via the message activity list table.
211
-     * Assumes you are already viewing the messages activity list table.
212
-     * @param        $message_type_label
213
-     * @param        $message_status
214
-     * @param string $messenger
215
-     * @param string $context
216
-     * @param int    $number_in_set
217
-     */
218
-    public function deleteMessageInMessagesListTableFor(
219
-        $message_type_label,
220
-        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
221
-        $messenger = 'Email',
222
-        $context = 'Event Admin',
223
-        $number_in_set = 1
224
-    ) {
225
-        $delete_action_selector = MessagesPage::messagesActivityListTableDeleteActionSelectorFor(
226
-            $message_type_label,
227
-            $message_status,
228
-            $messenger,
229
-            $context,
230
-            $number_in_set
231
-        );
232
-        $cell_selector = MessagesPage::messagesActivityListTableCellSelectorFor(
233
-            'to',
234
-            $message_type_label,
235
-            $message_status,
236
-            $messenger,
237
-            $context,
238
-            '',
239
-            $number_in_set
240
-        );
241
-        $this->actor()->scrollTo($cell_selector, 0, -30);
242
-        $this->actor()->moveMouseOver(
243
-            $cell_selector,
244
-            5,
245
-            5
246
-        );
247
-        $this->actor()->waitForElementVisible(
248
-            $delete_action_selector
249
-        );
250
-        $this->actor()->click(
251
-            $delete_action_selector
252
-        );
253
-        $this->actor()->waitForText('successfully deleted', 20);
254
-    }
255
-
256
-
257
-    /**
258
-     * Assuming you have already triggered the view modal for a single message from the context of the message activity
259
-     * list table, this will take care of validating the given text is in that window.
260
-     * @param string $text_to_view
261
-     */
262
-    public function seeTextInViewMessageModal($text_to_view, $should_not_see = false)
263
-    {
264
-        $this->actor()->wait(2);
265
-        $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content');
266
-        $this->actor()->switchToIframe('message-view-window');
267
-        $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view);
268
-        $this->actor()->switchToIframe();
269
-    }
270
-
271
-
272
-    /**
273
-     * This returns the value for the link at the given selector in the message modal.
274
-     * @param string $selector (any selector string accepted by WebDriver)
275
-     */
276
-    public function observeLinkAtSelectorInMessageModal($selector)
277
-    {
278
-        $this->actor()->wait(2);
279
-        $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content');
280
-        $this->actor()->switchToIframe('message-view-window');
281
-        $link = $this->actor()->observeLinkUrlAt($selector);
282
-        $this->actor()->switchToIframe();
283
-        return $link;
284
-    }
285
-
286
-
287
-    /**
288
-     * Assuming you have already triggered the view modal for a single message from the context of the message activity
289
-     * list table, this will take care of validating the given text is NOT that window.
290
-     * @param string $text_to_view
291
-     */
292
-    public function dontSeeTextInViewMessageModal($text_to_view)
293
-    {
294
-        $this->seeTextInViewMessageModal($text_to_view, true);
295
-    }
296
-
297
-
298
-    public function dismissMessageModal()
299
-    {
300
-        $this->actor()->executeJs('window.dialogHelper.closeModal()');
301
-        //this is needed otherwise phantom js gets stuck in the wrong context and any future element events will fail.
302
-        $this->actor()->scrollTo('form#EE_Message_List_Table-table-frm');
303
-        $this->actor()->click('form#EE_Message_List_Table-table-frm');
304
-    }
13
+	/**
14
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
15
+	 *                                  a string.
16
+	 */
17
+	public function amOnMessagesActivityListTablePage($additional_params = '')
18
+	{
19
+		$this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params));
20
+	}
21
+
22
+	/**
23
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
24
+	 *                                  a string.
25
+	 */
26
+	public function amOnDefaultMessageTemplateListTablePage($additional_params = '')
27
+	{
28
+		$this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params));
29
+	}
30
+
31
+
32
+	/**
33
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
34
+	 *                                  a string.
35
+	 */
36
+	public function amOnCustomMessageTemplateListTablePage($additional_params = '')
37
+	{
38
+		$this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params));
39
+	}
40
+
41
+
42
+	/**
43
+	 * Directs to message settings page
44
+	 */
45
+	public function amOnMessageSettingsPage()
46
+	{
47
+		$this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl());
48
+	}
49
+
50
+
51
+	public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email')
52
+	{
53
+		$this->actor()->dragAndDrop(
54
+			MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug),
55
+			MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR
56
+		);
57
+	}
58
+
59
+
60
+	/**
61
+	 * Assumes you are already on the list table page that has the ui for editing the template.
62
+	 * @param string $message_type_slug
63
+	 * @param string $context [optional] if you want to click directly to the given context in the editor
64
+	 */
65
+	public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '')
66
+	{
67
+		$this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context));
68
+	}
69
+
70
+
71
+	/**
72
+	 * Use this action to verify that the count for the given text in the specified field is as expected.  For example
73
+	 * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column.
74
+	 *
75
+	 * @param int    $expected_occurence_count
76
+	 * @param string $text_to_check_for
77
+	 * @param string $field
78
+	 * @param string $message_type_label
79
+	 * @param string $message_status
80
+	 * @param string $messenger
81
+	 * @param string $context
82
+	 */
83
+	public function verifyMatchingCountofTextInMessageActivityListTableFor(
84
+		$expected_occurence_count,
85
+		$text_to_check_for,
86
+		$field,
87
+		$message_type_label,
88
+		$message_status = MessagesPage::MESSAGE_STATUS_SENT,
89
+		$messenger = 'Email',
90
+		$context = 'Event Admin'
91
+	) {
92
+		$elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor(
93
+			$field,
94
+			$message_type_label,
95
+			$message_status,
96
+			$messenger,
97
+			$context,
98
+			$text_to_check_for,
99
+			0
100
+		));
101
+		$actual_count = count($elements);
102
+		$this->actor()->assertEquals(
103
+			$expected_occurence_count,
104
+			$actual_count,
105
+			sprintf(
106
+				'Expected %s of the %s text for the %s field but there were actually %s counted.',
107
+				$expected_occurence_count,
108
+				$text_to_check_for,
109
+				$field,
110
+				$actual_count
111
+			)
112
+		);
113
+	}
114
+
115
+
116
+	/**
117
+	 * This will create a custom message template for the given messenger and message type from the context of the
118
+	 * default (global) message template list table.
119
+	 * Also takes care of verifying the template was created.
120
+	 * @param string $message_type_label
121
+	 * @param string $messenger_label
122
+	 */
123
+	public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label)
124
+	{
125
+		$this->amOnDefaultMessageTemplateListTablePage();
126
+		$this->actor()->click(
127
+			MessagesPage::createCustomButtonForMessageTypeAndMessenger(
128
+				$message_type_label,
129
+				$messenger_label
130
+			)
131
+		);
132
+		$this->actor()->seeInField('#title', 'New Custom Template');
133
+	}
134
+
135
+
136
+	/**
137
+	 * This switches the context of the current messages template to the given reference.
138
+	 * @param string $context_reference  This should be the visible label for the option.
139
+	 */
140
+	public function switchContextTo($context_reference)
141
+	{
142
+		$this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference);
143
+		$this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR);
144
+		$this->actor()->waitForText($context_reference, 10, 'h1');
145
+	}
146
+
147
+
148
+	/**
149
+	 * Toggles Context so its turned off or on (depending on where it started) and verifies the expected state after
150
+	 * toggling.
151
+	 *
152
+	 * @param string $context_string           What context is being switched (used for the expected state text)
153
+	 * @param bool   $expected_state_is_active Used to indicate whether the expected state is active (true) or inactive
154
+	 *                                         (false)
155
+	 */
156
+	public function toggleContextState($context_string, $expected_state_is_active = true)
157
+	{
158
+		$this->actor()->click(MessagesPage::MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE);
159
+		if ($expected_state_is_active) {
160
+			$this->actor()->waitForText("The template for $context_string is currently active.");
161
+		} else {
162
+			$this->actor()->waitForText("The template for $context_string is currently inactive");
163
+		}
164
+	}
165
+
166
+
167
+	/**
168
+	 * Triggers saving the message template.
169
+	 * @param bool $and_close   Use to indicate to click the Save and Close button.
170
+	 */
171
+	public function saveMessageTemplate($and_close = false)
172
+	{
173
+		$this->actor()->scrollTo(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR);
174
+		if ($and_close) {
175
+			$this->actor()->click('Save and Close');
176
+		} else {
177
+			$this->actor()->click('Save');
178
+		}
179
+		$this->actor()->waitForText('successfully updated');
180
+	}
181
+
182
+
183
+	/**
184
+	 * This takes care of clicking the View Message icon for the given parameters.
185
+	 * Assumes you are already viewing the messages activity list table.
186
+	 * @param        $message_type_label
187
+	 * @param        $message_status
188
+	 * @param string $messenger
189
+	 * @param string $context
190
+	 * @param int    $number_in_set
191
+	 */
192
+	public function viewMessageInMessagesListTableFor(
193
+		$message_type_label,
194
+		$message_status = MessagesPage::MESSAGE_STATUS_SENT,
195
+		$messenger = 'Email',
196
+		$context = 'Event Admin',
197
+		$number_in_set = 1
198
+	) {
199
+		$this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor(
200
+			$message_type_label,
201
+			$message_status,
202
+			$messenger,
203
+			$context,
204
+			$number_in_set
205
+		));
206
+	}
207
+
208
+
209
+	/**
210
+	 * Takes care of deleting a message matching the given parameters via the message activity list table.
211
+	 * Assumes you are already viewing the messages activity list table.
212
+	 * @param        $message_type_label
213
+	 * @param        $message_status
214
+	 * @param string $messenger
215
+	 * @param string $context
216
+	 * @param int    $number_in_set
217
+	 */
218
+	public function deleteMessageInMessagesListTableFor(
219
+		$message_type_label,
220
+		$message_status = MessagesPage::MESSAGE_STATUS_SENT,
221
+		$messenger = 'Email',
222
+		$context = 'Event Admin',
223
+		$number_in_set = 1
224
+	) {
225
+		$delete_action_selector = MessagesPage::messagesActivityListTableDeleteActionSelectorFor(
226
+			$message_type_label,
227
+			$message_status,
228
+			$messenger,
229
+			$context,
230
+			$number_in_set
231
+		);
232
+		$cell_selector = MessagesPage::messagesActivityListTableCellSelectorFor(
233
+			'to',
234
+			$message_type_label,
235
+			$message_status,
236
+			$messenger,
237
+			$context,
238
+			'',
239
+			$number_in_set
240
+		);
241
+		$this->actor()->scrollTo($cell_selector, 0, -30);
242
+		$this->actor()->moveMouseOver(
243
+			$cell_selector,
244
+			5,
245
+			5
246
+		);
247
+		$this->actor()->waitForElementVisible(
248
+			$delete_action_selector
249
+		);
250
+		$this->actor()->click(
251
+			$delete_action_selector
252
+		);
253
+		$this->actor()->waitForText('successfully deleted', 20);
254
+	}
255
+
256
+
257
+	/**
258
+	 * Assuming you have already triggered the view modal for a single message from the context of the message activity
259
+	 * list table, this will take care of validating the given text is in that window.
260
+	 * @param string $text_to_view
261
+	 */
262
+	public function seeTextInViewMessageModal($text_to_view, $should_not_see = false)
263
+	{
264
+		$this->actor()->wait(2);
265
+		$this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content');
266
+		$this->actor()->switchToIframe('message-view-window');
267
+		$should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view);
268
+		$this->actor()->switchToIframe();
269
+	}
270
+
271
+
272
+	/**
273
+	 * This returns the value for the link at the given selector in the message modal.
274
+	 * @param string $selector (any selector string accepted by WebDriver)
275
+	 */
276
+	public function observeLinkAtSelectorInMessageModal($selector)
277
+	{
278
+		$this->actor()->wait(2);
279
+		$this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content');
280
+		$this->actor()->switchToIframe('message-view-window');
281
+		$link = $this->actor()->observeLinkUrlAt($selector);
282
+		$this->actor()->switchToIframe();
283
+		return $link;
284
+	}
285
+
286
+
287
+	/**
288
+	 * Assuming you have already triggered the view modal for a single message from the context of the message activity
289
+	 * list table, this will take care of validating the given text is NOT that window.
290
+	 * @param string $text_to_view
291
+	 */
292
+	public function dontSeeTextInViewMessageModal($text_to_view)
293
+	{
294
+		$this->seeTextInViewMessageModal($text_to_view, true);
295
+	}
296
+
297
+
298
+	public function dismissMessageModal()
299
+	{
300
+		$this->actor()->executeJs('window.dialogHelper.closeModal()');
301
+		//this is needed otherwise phantom js gets stuck in the wrong context and any future element events will fail.
302
+		$this->actor()->scrollTo('form#EE_Message_List_Table-table-frm');
303
+		$this->actor()->click('form#EE_Message_List_Table-table-frm');
304
+	}
305 305
 }
Please login to merge, or discard this patch.
acceptance_tests/Helpers/CountrySettingsAdmin.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -6,59 +6,59 @@
 block discarded – undo
6 6
 
7 7
 trait CountrySettingsAdmin
8 8
 {
9
-    /**
10
-     * Instructs the actor to browse to the country settings page.
11
-     * Assumes the actor is already logged in.
12
-     * @param string $additional_params
13
-     */
14
-    public function amOnCountrySettingsAdminPage($additional_params = '')
15
-    {
16
-        $this->actor()->amOnAdminPage(CountrySettings::url($additional_params));
17
-    }
9
+	/**
10
+	 * Instructs the actor to browse to the country settings page.
11
+	 * Assumes the actor is already logged in.
12
+	 * @param string $additional_params
13
+	 */
14
+	public function amOnCountrySettingsAdminPage($additional_params = '')
15
+	{
16
+		$this->actor()->amOnAdminPage(CountrySettings::url($additional_params));
17
+	}
18 18
 
19 19
 
20
-    /**
21
-     * Instructs the actor to select the given decimal places radio option.
22
-     * Assumes the actor is already on the country settings page.
23
-     * @param string $decimal_places
24
-     * @param string $country_code
25
-     */
26
-    public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US')
27
-    {
28
-        $this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code));
29
-    }
20
+	/**
21
+	 * Instructs the actor to select the given decimal places radio option.
22
+	 * Assumes the actor is already on the country settings page.
23
+	 * @param string $decimal_places
24
+	 * @param string $country_code
25
+	 */
26
+	public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US')
27
+	{
28
+		$this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code));
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * Instructs the actor to select the given decimal mark radio option.
34
-     * Assumes the actor is already on the country settings page.
35
-     * @param string $decimal_mark
36
-     */
37
-    public function setCurrencyDecimalMarkTo($decimal_mark = '.')
38
-    {
39
-        $this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark));
40
-    }
32
+	/**
33
+	 * Instructs the actor to select the given decimal mark radio option.
34
+	 * Assumes the actor is already on the country settings page.
35
+	 * @param string $decimal_mark
36
+	 */
37
+	public function setCurrencyDecimalMarkTo($decimal_mark = '.')
38
+	{
39
+		$this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark));
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * Instructs the actor to select the given thousands separator radio option.
45
-     * Assumes the actor is already on the country settings page.
46
-     * @param string $thousands_seperator
47
-     */
48
-    public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',')
49
-    {
50
-        $this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator));
51
-    }
43
+	/**
44
+	 * Instructs the actor to select the given thousands separator radio option.
45
+	 * Assumes the actor is already on the country settings page.
46
+	 * @param string $thousands_seperator
47
+	 */
48
+	public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',')
49
+	{
50
+		$this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator));
51
+	}
52 52
 
53 53
 
54
-    /**
55
-     * Clicks the country settings submit button.
56
-     * Assumes the actor is on the country settings admin page.
57
-     */
58
-    public function saveCountrySettings()
59
-    {
60
-        $this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON);
61
-        //no indicator on the page when stuff has been updated so just give a bit of time for it to finish.
62
-        $this->actor()->wait(10);
63
-    }
54
+	/**
55
+	 * Clicks the country settings submit button.
56
+	 * Assumes the actor is on the country settings admin page.
57
+	 */
58
+	public function saveCountrySettings()
59
+	{
60
+		$this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON);
61
+		//no indicator on the page when stuff has been updated so just give a bit of time for it to finish.
62
+		$this->actor()->wait(10);
63
+	}
64 64
 }
65 65
\ No newline at end of file
Please login to merge, or discard this patch.
modules/single_page_checkout/inc/EE_SPCO_JSON_Response.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
  /**
3
- *
4
- * Class EE_SPCO_JSON_Response
5
- *
6
- * Description
7
- *
8
- * @package         Event Espresso
9
- * @subpackage    core
10
- * @author				Brent Christensen
11
- * 
12
- *
13
- */
3
+  *
4
+  * Class EE_SPCO_JSON_Response
5
+  *
6
+  * Description
7
+  *
8
+  * @package         Event Espresso
9
+  * @subpackage    core
10
+  * @author				Brent Christensen
11
+  * 
12
+  *
13
+  */
14 14
 class EE_SPCO_JSON_Response {
15 15
 
16 16
 	/**
Please login to merge, or discard this patch.