Completed
Branch FET/rule-specific-exclusions-l... (334422)
by
unknown
17:10 queued 32s
created
core/db_classes/EE_Registration_Payment.class.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -14,98 +14,98 @@
 block discarded – undo
14 14
 class EE_Registration_Payment extends EE_Base_Class
15 15
 {
16 16
 
17
-    /**
18
-     *
19
-     * @param array  $props_n_values
20
-     * @param string $timezone
21
-     * @return EE_Registration_Payment
22
-     */
23
-    public static function new_instance($props_n_values = array(), $timezone = '', $date_formats = array())
24
-    {
25
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
26
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
27
-    }
28
-
29
-
30
-    /**
31
-     * @param array  $props_n_values
32
-     * @param string $timezone
33
-     * @return EE_Registration_Payment
34
-     */
35
-    public static function new_instance_from_db($props_n_values = array(), $timezone = '')
36
-    {
37
-        return new self($props_n_values, true, $timezone);
38
-    }
39
-
40
-
41
-    /**
42
-     * registration_ID
43
-     *
44
-     * @access    public
45
-     * @return    int
46
-     */
47
-    public function registration_ID()
48
-    {
49
-        return $this->get('REG_ID');
50
-    }
51
-
52
-
53
-    /**
54
-     * payment_ID
55
-     *
56
-     * @access    public
57
-     * @return    int
58
-     */
59
-    public function payment_ID()
60
-    {
61
-        return $this->get('PAY_ID');
62
-    }
63
-
64
-
65
-    /**
66
-     * amount
67
-     *
68
-     * @access    public
69
-     * @return    float
70
-     */
71
-    public function amount()
72
-    {
73
-        return $this->get('RPY_amount');
74
-    }
75
-
76
-
77
-    /**
78
-     * amount
79
-     *
80
-     * @access    public
81
-     * @param float $amount
82
-     */
83
-    public function set_amount($amount = 0.000)
84
-    {
85
-        $this->set('RPY_amount', $amount);
86
-    }
87
-
88
-
89
-    /**
90
-     * registration
91
-     *
92
-     * @access    public
93
-     * @return \EE_Registration
94
-     */
95
-    public function registration()
96
-    {
97
-        return $this->get_first_related('Registration');
98
-    }
99
-
100
-
101
-    /**
102
-     * payment
103
-     *
104
-     * @access    public
105
-     * @return \EE_Payment
106
-     */
107
-    public function payment()
108
-    {
109
-        return $this->get_first_related('Payment');
110
-    }
17
+	/**
18
+	 *
19
+	 * @param array  $props_n_values
20
+	 * @param string $timezone
21
+	 * @return EE_Registration_Payment
22
+	 */
23
+	public static function new_instance($props_n_values = array(), $timezone = '', $date_formats = array())
24
+	{
25
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
26
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
27
+	}
28
+
29
+
30
+	/**
31
+	 * @param array  $props_n_values
32
+	 * @param string $timezone
33
+	 * @return EE_Registration_Payment
34
+	 */
35
+	public static function new_instance_from_db($props_n_values = array(), $timezone = '')
36
+	{
37
+		return new self($props_n_values, true, $timezone);
38
+	}
39
+
40
+
41
+	/**
42
+	 * registration_ID
43
+	 *
44
+	 * @access    public
45
+	 * @return    int
46
+	 */
47
+	public function registration_ID()
48
+	{
49
+		return $this->get('REG_ID');
50
+	}
51
+
52
+
53
+	/**
54
+	 * payment_ID
55
+	 *
56
+	 * @access    public
57
+	 * @return    int
58
+	 */
59
+	public function payment_ID()
60
+	{
61
+		return $this->get('PAY_ID');
62
+	}
63
+
64
+
65
+	/**
66
+	 * amount
67
+	 *
68
+	 * @access    public
69
+	 * @return    float
70
+	 */
71
+	public function amount()
72
+	{
73
+		return $this->get('RPY_amount');
74
+	}
75
+
76
+
77
+	/**
78
+	 * amount
79
+	 *
80
+	 * @access    public
81
+	 * @param float $amount
82
+	 */
83
+	public function set_amount($amount = 0.000)
84
+	{
85
+		$this->set('RPY_amount', $amount);
86
+	}
87
+
88
+
89
+	/**
90
+	 * registration
91
+	 *
92
+	 * @access    public
93
+	 * @return \EE_Registration
94
+	 */
95
+	public function registration()
96
+	{
97
+		return $this->get_first_related('Registration');
98
+	}
99
+
100
+
101
+	/**
102
+	 * payment
103
+	 *
104
+	 * @access    public
105
+	 * @return \EE_Payment
106
+	 */
107
+	public function payment()
108
+	{
109
+		return $this->get_first_related('Payment');
110
+	}
111 111
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Question_Group_Question.class.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -6,23 +6,23 @@
 block discarded – undo
6 6
 class EE_Question_Group_Question extends EE_Base_Class
7 7
 {
8 8
 
9
-    /**
10
-     * @param array $props_n_values
11
-     * @return EE_Question_Group_Question|mixed
12
-     */
13
-    public static function new_instance($props_n_values = array())
14
-    {
15
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
16
-        return $has_object ? $has_object : new self($props_n_values);
17
-    }
9
+	/**
10
+	 * @param array $props_n_values
11
+	 * @return EE_Question_Group_Question|mixed
12
+	 */
13
+	public static function new_instance($props_n_values = array())
14
+	{
15
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
16
+		return $has_object ? $has_object : new self($props_n_values);
17
+	}
18 18
 
19 19
 
20
-    /**
21
-     * @param array $props_n_values
22
-     * @return EE_Question_Group_Question
23
-     */
24
-    public static function new_instance_from_db($props_n_values = array())
25
-    {
26
-        return new self($props_n_values, true);
27
-    }
20
+	/**
21
+	 * @param array $props_n_values
22
+	 * @return EE_Question_Group_Question
23
+	 */
24
+	public static function new_instance_from_db($props_n_values = array())
25
+	{
26
+		return new self($props_n_values, true);
27
+	}
28 28
 }
Please login to merge, or discard this patch.
core/db_classes/EE_State.class.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -11,104 +11,104 @@
 block discarded – undo
11 11
 class EE_State extends EE_Base_Class
12 12
 {
13 13
 
14
-    /**
15
-     * @param array $props_n_values
16
-     * @return EE_State|mixed
17
-     */
18
-    public static function new_instance($props_n_values = array())
19
-    {
20
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
21
-        return $has_object ? $has_object : new self($props_n_values);
22
-    }
23
-
24
-
25
-    /**
26
-     * @param array $props_n_values
27
-     * @return EE_State
28
-     */
29
-    public static function new_instance_from_db($props_n_values = array())
30
-    {
31
-        return new self($props_n_values, true);
32
-    }
33
-
34
-
35
-    /**
36
-     * @return string
37
-     */
38
-    public function country_iso()
39
-    {
40
-        return $this->get('CNT_ISO');
41
-    }
42
-
43
-
44
-    /**
45
-     * @return string
46
-     */
47
-    public function abbrev()
48
-    {
49
-        return $this->get('STA_abbrev');
50
-    }
51
-
52
-
53
-    /**
54
-     * @return bool
55
-     */
56
-    public function active()
57
-    {
58
-        return $this->get('STA_active');
59
-    }
60
-
61
-
62
-    /**
63
-     * @return string
64
-     */
65
-    public function name()
66
-    {
67
-        return $this->get('STA_name');
68
-    }
69
-
70
-
71
-    /**
72
-     * @return EE_Country
73
-     */
74
-    public function country()
75
-    {
76
-        return $this->get_first_related('Country');
77
-    }
78
-
79
-
80
-    /**
81
-     * @param $iso
82
-     */
83
-    public function set_country_iso($iso)
84
-    {
85
-        $this->set('CNT_ISO', $iso);
86
-    }
87
-
88
-
89
-    /**
90
-     * @param $abbrev
91
-     */
92
-    public function set_abbrev($abbrev)
93
-    {
94
-        $this->set('STA_abbrev', $abbrev);
95
-    }
96
-
97
-
98
-    /**
99
-     * @param $active
100
-     */
101
-    public function set_active($active)
102
-    {
103
-        $this->set('STA_active', $active);
104
-    }
105
-
106
-
107
-    /**
108
-     * @param $name
109
-     */
110
-    public function set_name($name)
111
-    {
112
-        $this->set('STA_name', $name);
113
-    }
14
+	/**
15
+	 * @param array $props_n_values
16
+	 * @return EE_State|mixed
17
+	 */
18
+	public static function new_instance($props_n_values = array())
19
+	{
20
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
21
+		return $has_object ? $has_object : new self($props_n_values);
22
+	}
23
+
24
+
25
+	/**
26
+	 * @param array $props_n_values
27
+	 * @return EE_State
28
+	 */
29
+	public static function new_instance_from_db($props_n_values = array())
30
+	{
31
+		return new self($props_n_values, true);
32
+	}
33
+
34
+
35
+	/**
36
+	 * @return string
37
+	 */
38
+	public function country_iso()
39
+	{
40
+		return $this->get('CNT_ISO');
41
+	}
42
+
43
+
44
+	/**
45
+	 * @return string
46
+	 */
47
+	public function abbrev()
48
+	{
49
+		return $this->get('STA_abbrev');
50
+	}
51
+
52
+
53
+	/**
54
+	 * @return bool
55
+	 */
56
+	public function active()
57
+	{
58
+		return $this->get('STA_active');
59
+	}
60
+
61
+
62
+	/**
63
+	 * @return string
64
+	 */
65
+	public function name()
66
+	{
67
+		return $this->get('STA_name');
68
+	}
69
+
70
+
71
+	/**
72
+	 * @return EE_Country
73
+	 */
74
+	public function country()
75
+	{
76
+		return $this->get_first_related('Country');
77
+	}
78
+
79
+
80
+	/**
81
+	 * @param $iso
82
+	 */
83
+	public function set_country_iso($iso)
84
+	{
85
+		$this->set('CNT_ISO', $iso);
86
+	}
87
+
88
+
89
+	/**
90
+	 * @param $abbrev
91
+	 */
92
+	public function set_abbrev($abbrev)
93
+	{
94
+		$this->set('STA_abbrev', $abbrev);
95
+	}
96
+
97
+
98
+	/**
99
+	 * @param $active
100
+	 */
101
+	public function set_active($active)
102
+	{
103
+		$this->set('STA_active', $active);
104
+	}
105
+
106
+
107
+	/**
108
+	 * @param $name
109
+	 */
110
+	public function set_name($name)
111
+	{
112
+		$this->set('STA_name', $name);
113
+	}
114 114
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Attendee.class.php 2 patches
Indentation   +742 added lines, -742 removed lines patch added patch discarded remove patch
@@ -25,746 +25,746 @@
 block discarded – undo
25 25
 class EE_Attendee extends EE_CPT_Base implements EEI_Contact, EEI_Address, EEI_Admin_Links, EEI_Attendee
26 26
 {
27 27
 
28
-    /**
29
-     * Sets some dynamic defaults
30
-     *
31
-     * @param array  $fieldValues
32
-     * @param bool   $bydb
33
-     * @param string $timezone
34
-     * @param array  $date_formats
35
-     * @throws EE_Error
36
-     */
37
-    protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
38
-    {
39
-        if (! isset($fieldValues['ATT_full_name'])) {
40
-            $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
41
-            $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
42
-            $fieldValues['ATT_full_name'] = $fname . $lname;
43
-        }
44
-        if (! isset($fieldValues['ATT_slug'])) {
45
-            // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
46
-            $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
47
-        }
48
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
49
-            $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
50
-        }
51
-        parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
52
-    }
53
-
54
-
55
-    /**
56
-     * @param array  $props_n_values          incoming values
57
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
58
-     *                                        used.)
59
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
60
-     *                                        date_format and the second value is the time format
61
-     * @return EE_Attendee
62
-     * @throws EE_Error
63
-     */
64
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
65
-    {
66
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
67
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
68
-    }
69
-
70
-
71
-    /**
72
-     * @param array  $props_n_values  incoming values from the database
73
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
74
-     *                                the website will be used.
75
-     * @return EE_Attendee
76
-     */
77
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
78
-    {
79
-        return new self($props_n_values, true, $timezone);
80
-    }
81
-
82
-
83
-    /**
84
-     *        Set Attendee First Name
85
-     *
86
-     * @access        public
87
-     * @param string $fname
88
-     * @throws EE_Error
89
-     */
90
-    public function set_fname($fname = '')
91
-    {
92
-        $this->set('ATT_fname', $fname);
93
-    }
94
-
95
-
96
-    /**
97
-     *        Set Attendee Last Name
98
-     *
99
-     * @access        public
100
-     * @param string $lname
101
-     * @throws EE_Error
102
-     */
103
-    public function set_lname($lname = '')
104
-    {
105
-        $this->set('ATT_lname', $lname);
106
-    }
107
-
108
-
109
-    /**
110
-     *        Set Attendee Address
111
-     *
112
-     * @access        public
113
-     * @param string $address
114
-     * @throws EE_Error
115
-     */
116
-    public function set_address($address = '')
117
-    {
118
-        $this->set('ATT_address', $address);
119
-    }
120
-
121
-
122
-    /**
123
-     *        Set Attendee Address2
124
-     *
125
-     * @access        public
126
-     * @param        string $address2
127
-     * @throws EE_Error
128
-     */
129
-    public function set_address2($address2 = '')
130
-    {
131
-        $this->set('ATT_address2', $address2);
132
-    }
133
-
134
-
135
-    /**
136
-     *        Set Attendee City
137
-     *
138
-     * @access        public
139
-     * @param        string $city
140
-     * @throws EE_Error
141
-     */
142
-    public function set_city($city = '')
143
-    {
144
-        $this->set('ATT_city', $city);
145
-    }
146
-
147
-
148
-    /**
149
-     *        Set Attendee State ID
150
-     *
151
-     * @access        public
152
-     * @param        int $STA_ID
153
-     * @throws EE_Error
154
-     */
155
-    public function set_state($STA_ID = 0)
156
-    {
157
-        $this->set('STA_ID', $STA_ID);
158
-    }
159
-
160
-
161
-    /**
162
-     *        Set Attendee Country ISO Code
163
-     *
164
-     * @access        public
165
-     * @param        string $CNT_ISO
166
-     * @throws EE_Error
167
-     */
168
-    public function set_country($CNT_ISO = '')
169
-    {
170
-        $this->set('CNT_ISO', $CNT_ISO);
171
-    }
172
-
173
-
174
-    /**
175
-     *        Set Attendee Zip/Postal Code
176
-     *
177
-     * @access        public
178
-     * @param        string $zip
179
-     * @throws EE_Error
180
-     */
181
-    public function set_zip($zip = '')
182
-    {
183
-        $this->set('ATT_zip', $zip);
184
-    }
185
-
186
-
187
-    /**
188
-     *        Set Attendee Email Address
189
-     *
190
-     * @access        public
191
-     * @param        string $email
192
-     * @throws EE_Error
193
-     */
194
-    public function set_email($email = '')
195
-    {
196
-        $this->set('ATT_email', $email);
197
-    }
198
-
199
-
200
-    /**
201
-     *        Set Attendee Phone
202
-     *
203
-     * @access        public
204
-     * @param        string $phone
205
-     * @throws EE_Error
206
-     */
207
-    public function set_phone($phone = '')
208
-    {
209
-        $this->set('ATT_phone', $phone);
210
-    }
211
-
212
-
213
-    /**
214
-     *        set deleted
215
-     *
216
-     * @access        public
217
-     * @param        bool $ATT_deleted
218
-     * @throws EE_Error
219
-     */
220
-    public function set_deleted($ATT_deleted = false)
221
-    {
222
-        $this->set('ATT_deleted', $ATT_deleted);
223
-    }
224
-
225
-
226
-    /**
227
-     * Returns the value for the post_author id saved with the cpt
228
-     *
229
-     * @since 4.5.0
230
-     * @return int
231
-     * @throws EE_Error
232
-     */
233
-    public function wp_user()
234
-    {
235
-        return $this->get('ATT_author');
236
-    }
237
-
238
-
239
-    /**
240
-     *        get Attendee First Name
241
-     *
242
-     * @access        public
243
-     * @return string
244
-     * @throws EE_Error
245
-     */
246
-    public function fname()
247
-    {
248
-        return $this->get('ATT_fname');
249
-    }
250
-
251
-
252
-    /**
253
-     * echoes out the attendee's first name
254
-     *
255
-     * @return void
256
-     * @throws EE_Error
257
-     */
258
-    public function e_full_name()
259
-    {
260
-        echo $this->full_name();
261
-    }
262
-
263
-
264
-    /**
265
-     * Returns the first and last name concatenated together with a space.
266
-     *
267
-     * @param bool $apply_html_entities
268
-     * @return string
269
-     * @throws EE_Error
270
-     */
271
-    public function full_name($apply_html_entities = false)
272
-    {
273
-        $full_name = array(
274
-            $this->fname(),
275
-            $this->lname(),
276
-        );
277
-        $full_name = array_filter($full_name);
278
-        $full_name = implode(' ', $full_name);
279
-        return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
280
-    }
281
-
282
-
283
-    /**
284
-     * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
285
-     * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
286
-     * attendee.
287
-     *
288
-     * @param bool $apply_html_entities
289
-     * @return string
290
-     * @throws EE_Error
291
-     */
292
-    public function ATT_full_name($apply_html_entities = false)
293
-    {
294
-        return $apply_html_entities
295
-            ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
296
-            : $this->get('ATT_full_name');
297
-    }
298
-
299
-
300
-    /**
301
-     *        get Attendee Last Name
302
-     *
303
-     * @access        public
304
-     * @return string
305
-     * @throws EE_Error
306
-     */
307
-    public function lname()
308
-    {
309
-        return $this->get('ATT_lname');
310
-    }
311
-
312
-
313
-    /**
314
-     * Gets the attendee's full address as an array so client code can decide hwo to display it
315
-     *
316
-     * @return array numerically indexed, with each part of the address that is known.
317
-     * Eg, if the user only responded to state and country,
318
-     * it would be array(0=>'Alabama',1=>'USA')
319
-     * @return array
320
-     * @throws EE_Error
321
-     */
322
-    public function full_address_as_array()
323
-    {
324
-        $full_address_array = array();
325
-        $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
326
-        foreach ($initial_address_fields as $address_field_name) {
327
-            $address_fields_value = $this->get($address_field_name);
328
-            if (! empty($address_fields_value)) {
329
-                $full_address_array[] = $address_fields_value;
330
-            }
331
-        }
332
-        // now handle state and country
333
-        $state_obj = $this->state_obj();
334
-        if ($state_obj instanceof EE_State) {
335
-            $full_address_array[] = $state_obj->name();
336
-        }
337
-        $country_obj = $this->country_obj();
338
-        if ($country_obj instanceof EE_Country) {
339
-            $full_address_array[] = $country_obj->name();
340
-        }
341
-        // lastly get the xip
342
-        $zip_value = $this->zip();
343
-        if (! empty($zip_value)) {
344
-            $full_address_array[] = $zip_value;
345
-        }
346
-        return $full_address_array;
347
-    }
348
-
349
-
350
-    /**
351
-     *        get Attendee Address
352
-     *
353
-     * @return string
354
-     * @throws EE_Error
355
-     */
356
-    public function address()
357
-    {
358
-        return $this->get('ATT_address');
359
-    }
360
-
361
-
362
-    /**
363
-     *        get Attendee Address2
364
-     *
365
-     * @return string
366
-     * @throws EE_Error
367
-     */
368
-    public function address2()
369
-    {
370
-        return $this->get('ATT_address2');
371
-    }
372
-
373
-
374
-    /**
375
-     *        get Attendee City
376
-     *
377
-     * @return string
378
-     * @throws EE_Error
379
-     */
380
-    public function city()
381
-    {
382
-        return $this->get('ATT_city');
383
-    }
384
-
385
-
386
-    /**
387
-     *        get Attendee State ID
388
-     *
389
-     * @return string
390
-     * @throws EE_Error
391
-     */
392
-    public function state_ID()
393
-    {
394
-        return $this->get('STA_ID');
395
-    }
396
-
397
-
398
-    /**
399
-     * @return string
400
-     * @throws EE_Error
401
-     */
402
-    public function state_abbrev()
403
-    {
404
-        return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
405
-    }
406
-
407
-
408
-    /**
409
-     * Gets the state set to this attendee
410
-     *
411
-     * @return EE_State
412
-     * @throws EE_Error
413
-     */
414
-    public function state_obj()
415
-    {
416
-        return $this->get_first_related('State');
417
-    }
418
-
419
-
420
-    /**
421
-     * Returns the state's name, otherwise 'Unknown'
422
-     *
423
-     * @return string
424
-     * @throws EE_Error
425
-     */
426
-    public function state_name()
427
-    {
428
-        if ($this->state_obj()) {
429
-            return $this->state_obj()->name();
430
-        } else {
431
-            return '';
432
-        }
433
-    }
434
-
435
-
436
-    /**
437
-     * either displays the state abbreviation or the state name, as determined
438
-     * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
439
-     * defaults to abbreviation
440
-     *
441
-     * @return string
442
-     * @throws EE_Error
443
-     */
444
-    public function state()
445
-    {
446
-        if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
447
-            return $this->state_abbrev();
448
-        }
449
-        return $this->state_name();
450
-    }
451
-
452
-
453
-    /**
454
-     *    get Attendee Country ISO Code
455
-     *
456
-     * @return string
457
-     * @throws EE_Error
458
-     */
459
-    public function country_ID()
460
-    {
461
-        return $this->get('CNT_ISO');
462
-    }
463
-
464
-
465
-    /**
466
-     * Gets country set for this attendee
467
-     *
468
-     * @return EE_Country
469
-     * @throws EE_Error
470
-     */
471
-    public function country_obj()
472
-    {
473
-        return $this->get_first_related('Country');
474
-    }
475
-
476
-
477
-    /**
478
-     * Returns the country's name if known, otherwise 'Unknown'
479
-     *
480
-     * @return string
481
-     * @throws EE_Error
482
-     */
483
-    public function country_name()
484
-    {
485
-        if ($this->country_obj()) {
486
-            return $this->country_obj()->name();
487
-        }
488
-        return '';
489
-    }
490
-
491
-
492
-    /**
493
-     * either displays the country ISO2 code or the country name, as determined
494
-     * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
495
-     * defaults to abbreviation
496
-     *
497
-     * @return string
498
-     * @throws EE_Error
499
-     */
500
-    public function country()
501
-    {
502
-        if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
503
-            return $this->country_ID();
504
-        }
505
-        return $this->country_name();
506
-    }
507
-
508
-
509
-    /**
510
-     *        get Attendee Zip/Postal Code
511
-     *
512
-     * @return string
513
-     * @throws EE_Error
514
-     */
515
-    public function zip()
516
-    {
517
-        return $this->get('ATT_zip');
518
-    }
519
-
520
-
521
-    /**
522
-     *        get Attendee Email Address
523
-     *
524
-     * @return string
525
-     * @throws EE_Error
526
-     */
527
-    public function email()
528
-    {
529
-        return $this->get('ATT_email');
530
-    }
531
-
532
-
533
-    /**
534
-     *        get Attendee Phone #
535
-     *
536
-     * @return string
537
-     * @throws EE_Error
538
-     */
539
-    public function phone()
540
-    {
541
-        return $this->get('ATT_phone');
542
-    }
543
-
544
-
545
-    /**
546
-     *    get deleted
547
-     *
548
-     * @return        bool
549
-     * @throws EE_Error
550
-     */
551
-    public function deleted()
552
-    {
553
-        return $this->get('ATT_deleted');
554
-    }
555
-
556
-
557
-    /**
558
-     * Gets registrations of this attendee
559
-     *
560
-     * @param array $query_params
561
-     * @return EE_Registration[]
562
-     * @throws EE_Error
563
-     */
564
-    public function get_registrations($query_params = array())
565
-    {
566
-        return $this->get_many_related('Registration', $query_params);
567
-    }
568
-
569
-
570
-    /**
571
-     * Gets the most recent registration of this attendee
572
-     *
573
-     * @return EE_Registration
574
-     * @throws EE_Error
575
-     */
576
-    public function get_most_recent_registration()
577
-    {
578
-        return $this->get_first_related(
579
-            'Registration',
580
-            array('order_by' => array('REG_date' => 'DESC'))
581
-        ); // null, 'REG_date', 'DESC', '=', 'OBJECT_K');
582
-    }
583
-
584
-
585
-    /**
586
-     * Gets the most recent registration for this attend at this event
587
-     *
588
-     * @param int $event_id
589
-     * @return EE_Registration
590
-     * @throws EE_Error
591
-     */
592
-    public function get_most_recent_registration_for_event($event_id)
593
-    {
594
-        return $this->get_first_related(
595
-            'Registration',
596
-            array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))
597
-        );
598
-    }
599
-
600
-
601
-    /**
602
-     * returns any events attached to this attendee ($_Event property);
603
-     *
604
-     * @return array
605
-     * @throws EE_Error
606
-     */
607
-    public function events()
608
-    {
609
-        return $this->get_many_related('Event');
610
-    }
611
-
612
-
613
-    /**
614
-     * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
615
-     * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
616
-     * used to save the billing info
617
-     *
618
-     * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
619
-     * @return EE_Form_Section_Proper|null
620
-     * @throws EE_Error
621
-     */
622
-    public function billing_info_for_payment_method($payment_method)
623
-    {
624
-        $pm_type = $payment_method->type_obj();
625
-        if (! $pm_type instanceof EE_PMT_Base) {
626
-            return null;
627
-        }
628
-        $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
629
-        if (! $billing_info) {
630
-            return null;
631
-        }
632
-        $billing_form = $pm_type->billing_form();
633
-        // double-check the form isn't totally hidden, in which case pretend there is no form
634
-        $form_totally_hidden = true;
635
-        foreach ($billing_form->inputs_in_subsections() as $input) {
636
-            if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
637
-                $form_totally_hidden = false;
638
-                break;
639
-            }
640
-        }
641
-        if ($form_totally_hidden) {
642
-            return null;
643
-        }
644
-        if ($billing_form instanceof EE_Form_Section_Proper) {
645
-            $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
646
-        }
647
-
648
-        return $billing_form;
649
-    }
650
-
651
-
652
-    /**
653
-     * Gets the postmeta key that holds this attendee's billing info for the
654
-     * specified payment method
655
-     *
656
-     * @param EE_Payment_Method $payment_method
657
-     * @return string
658
-     * @throws EE_Error
659
-     */
660
-    public function get_billing_info_postmeta_name($payment_method)
661
-    {
662
-        if ($payment_method->type_obj() instanceof EE_PMT_Base) {
663
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
664
-        }
665
-        return null;
666
-    }
667
-
668
-
669
-    /**
670
-     * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
671
-     * retrieve it
672
-     *
673
-     * @param EE_Billing_Attendee_Info_Form $billing_form
674
-     * @param EE_Payment_Method             $payment_method
675
-     * @return boolean
676
-     * @throws EE_Error
677
-     */
678
-    public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
679
-    {
680
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
681
-            EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
682
-            return false;
683
-        }
684
-        $billing_form->clean_sensitive_data();
685
-        return update_post_meta(
686
-            $this->ID(),
687
-            $this->get_billing_info_postmeta_name($payment_method),
688
-            $billing_form->input_values(true)
689
-        );
690
-    }
691
-
692
-
693
-    /**
694
-     * Return the link to the admin details for the object.
695
-     *
696
-     * @return string
697
-     * @throws EE_Error
698
-     * @throws InvalidArgumentException
699
-     * @throws InvalidDataTypeException
700
-     * @throws InvalidInterfaceException
701
-     * @throws ReflectionException
702
-     */
703
-    public function get_admin_details_link()
704
-    {
705
-        return $this->get_admin_edit_link();
706
-    }
707
-
708
-
709
-    /**
710
-     * Returns the link to the editor for the object.  Sometimes this is the same as the details.
711
-     *
712
-     * @return string
713
-     * @throws EE_Error
714
-     * @throws InvalidArgumentException
715
-     * @throws ReflectionException
716
-     * @throws InvalidDataTypeException
717
-     * @throws InvalidInterfaceException
718
-     */
719
-    public function get_admin_edit_link()
720
-    {
721
-        EE_Registry::instance()->load_helper('URL');
722
-        return EEH_URL::add_query_args_and_nonce(
723
-            array(
724
-                'page'   => 'espresso_registrations',
725
-                'action' => 'edit_attendee',
726
-                'post'   => $this->ID(),
727
-            ),
728
-            admin_url('admin.php')
729
-        );
730
-    }
731
-
732
-
733
-    /**
734
-     * Returns the link to a settings page for the object.
735
-     *
736
-     * @return string
737
-     * @throws EE_Error
738
-     * @throws InvalidArgumentException
739
-     * @throws InvalidDataTypeException
740
-     * @throws InvalidInterfaceException
741
-     * @throws ReflectionException
742
-     */
743
-    public function get_admin_settings_link()
744
-    {
745
-        return $this->get_admin_edit_link();
746
-    }
747
-
748
-
749
-    /**
750
-     * Returns the link to the "overview" for the object (typically the "list table" view).
751
-     *
752
-     * @return string
753
-     * @throws EE_Error
754
-     * @throws InvalidArgumentException
755
-     * @throws ReflectionException
756
-     * @throws InvalidDataTypeException
757
-     * @throws InvalidInterfaceException
758
-     */
759
-    public function get_admin_overview_link()
760
-    {
761
-        EE_Registry::instance()->load_helper('URL');
762
-        return EEH_URL::add_query_args_and_nonce(
763
-            array(
764
-                'page'   => 'espresso_registrations',
765
-                'action' => 'contact_list',
766
-            ),
767
-            admin_url('admin.php')
768
-        );
769
-    }
28
+	/**
29
+	 * Sets some dynamic defaults
30
+	 *
31
+	 * @param array  $fieldValues
32
+	 * @param bool   $bydb
33
+	 * @param string $timezone
34
+	 * @param array  $date_formats
35
+	 * @throws EE_Error
36
+	 */
37
+	protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
38
+	{
39
+		if (! isset($fieldValues['ATT_full_name'])) {
40
+			$fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
41
+			$lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
42
+			$fieldValues['ATT_full_name'] = $fname . $lname;
43
+		}
44
+		if (! isset($fieldValues['ATT_slug'])) {
45
+			// $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
46
+			$fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
47
+		}
48
+		if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
49
+			$fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
50
+		}
51
+		parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
52
+	}
53
+
54
+
55
+	/**
56
+	 * @param array  $props_n_values          incoming values
57
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
58
+	 *                                        used.)
59
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
60
+	 *                                        date_format and the second value is the time format
61
+	 * @return EE_Attendee
62
+	 * @throws EE_Error
63
+	 */
64
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
65
+	{
66
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
67
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
68
+	}
69
+
70
+
71
+	/**
72
+	 * @param array  $props_n_values  incoming values from the database
73
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
74
+	 *                                the website will be used.
75
+	 * @return EE_Attendee
76
+	 */
77
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
78
+	{
79
+		return new self($props_n_values, true, $timezone);
80
+	}
81
+
82
+
83
+	/**
84
+	 *        Set Attendee First Name
85
+	 *
86
+	 * @access        public
87
+	 * @param string $fname
88
+	 * @throws EE_Error
89
+	 */
90
+	public function set_fname($fname = '')
91
+	{
92
+		$this->set('ATT_fname', $fname);
93
+	}
94
+
95
+
96
+	/**
97
+	 *        Set Attendee Last Name
98
+	 *
99
+	 * @access        public
100
+	 * @param string $lname
101
+	 * @throws EE_Error
102
+	 */
103
+	public function set_lname($lname = '')
104
+	{
105
+		$this->set('ATT_lname', $lname);
106
+	}
107
+
108
+
109
+	/**
110
+	 *        Set Attendee Address
111
+	 *
112
+	 * @access        public
113
+	 * @param string $address
114
+	 * @throws EE_Error
115
+	 */
116
+	public function set_address($address = '')
117
+	{
118
+		$this->set('ATT_address', $address);
119
+	}
120
+
121
+
122
+	/**
123
+	 *        Set Attendee Address2
124
+	 *
125
+	 * @access        public
126
+	 * @param        string $address2
127
+	 * @throws EE_Error
128
+	 */
129
+	public function set_address2($address2 = '')
130
+	{
131
+		$this->set('ATT_address2', $address2);
132
+	}
133
+
134
+
135
+	/**
136
+	 *        Set Attendee City
137
+	 *
138
+	 * @access        public
139
+	 * @param        string $city
140
+	 * @throws EE_Error
141
+	 */
142
+	public function set_city($city = '')
143
+	{
144
+		$this->set('ATT_city', $city);
145
+	}
146
+
147
+
148
+	/**
149
+	 *        Set Attendee State ID
150
+	 *
151
+	 * @access        public
152
+	 * @param        int $STA_ID
153
+	 * @throws EE_Error
154
+	 */
155
+	public function set_state($STA_ID = 0)
156
+	{
157
+		$this->set('STA_ID', $STA_ID);
158
+	}
159
+
160
+
161
+	/**
162
+	 *        Set Attendee Country ISO Code
163
+	 *
164
+	 * @access        public
165
+	 * @param        string $CNT_ISO
166
+	 * @throws EE_Error
167
+	 */
168
+	public function set_country($CNT_ISO = '')
169
+	{
170
+		$this->set('CNT_ISO', $CNT_ISO);
171
+	}
172
+
173
+
174
+	/**
175
+	 *        Set Attendee Zip/Postal Code
176
+	 *
177
+	 * @access        public
178
+	 * @param        string $zip
179
+	 * @throws EE_Error
180
+	 */
181
+	public function set_zip($zip = '')
182
+	{
183
+		$this->set('ATT_zip', $zip);
184
+	}
185
+
186
+
187
+	/**
188
+	 *        Set Attendee Email Address
189
+	 *
190
+	 * @access        public
191
+	 * @param        string $email
192
+	 * @throws EE_Error
193
+	 */
194
+	public function set_email($email = '')
195
+	{
196
+		$this->set('ATT_email', $email);
197
+	}
198
+
199
+
200
+	/**
201
+	 *        Set Attendee Phone
202
+	 *
203
+	 * @access        public
204
+	 * @param        string $phone
205
+	 * @throws EE_Error
206
+	 */
207
+	public function set_phone($phone = '')
208
+	{
209
+		$this->set('ATT_phone', $phone);
210
+	}
211
+
212
+
213
+	/**
214
+	 *        set deleted
215
+	 *
216
+	 * @access        public
217
+	 * @param        bool $ATT_deleted
218
+	 * @throws EE_Error
219
+	 */
220
+	public function set_deleted($ATT_deleted = false)
221
+	{
222
+		$this->set('ATT_deleted', $ATT_deleted);
223
+	}
224
+
225
+
226
+	/**
227
+	 * Returns the value for the post_author id saved with the cpt
228
+	 *
229
+	 * @since 4.5.0
230
+	 * @return int
231
+	 * @throws EE_Error
232
+	 */
233
+	public function wp_user()
234
+	{
235
+		return $this->get('ATT_author');
236
+	}
237
+
238
+
239
+	/**
240
+	 *        get Attendee First Name
241
+	 *
242
+	 * @access        public
243
+	 * @return string
244
+	 * @throws EE_Error
245
+	 */
246
+	public function fname()
247
+	{
248
+		return $this->get('ATT_fname');
249
+	}
250
+
251
+
252
+	/**
253
+	 * echoes out the attendee's first name
254
+	 *
255
+	 * @return void
256
+	 * @throws EE_Error
257
+	 */
258
+	public function e_full_name()
259
+	{
260
+		echo $this->full_name();
261
+	}
262
+
263
+
264
+	/**
265
+	 * Returns the first and last name concatenated together with a space.
266
+	 *
267
+	 * @param bool $apply_html_entities
268
+	 * @return string
269
+	 * @throws EE_Error
270
+	 */
271
+	public function full_name($apply_html_entities = false)
272
+	{
273
+		$full_name = array(
274
+			$this->fname(),
275
+			$this->lname(),
276
+		);
277
+		$full_name = array_filter($full_name);
278
+		$full_name = implode(' ', $full_name);
279
+		return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
280
+	}
281
+
282
+
283
+	/**
284
+	 * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
285
+	 * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
286
+	 * attendee.
287
+	 *
288
+	 * @param bool $apply_html_entities
289
+	 * @return string
290
+	 * @throws EE_Error
291
+	 */
292
+	public function ATT_full_name($apply_html_entities = false)
293
+	{
294
+		return $apply_html_entities
295
+			? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
296
+			: $this->get('ATT_full_name');
297
+	}
298
+
299
+
300
+	/**
301
+	 *        get Attendee Last Name
302
+	 *
303
+	 * @access        public
304
+	 * @return string
305
+	 * @throws EE_Error
306
+	 */
307
+	public function lname()
308
+	{
309
+		return $this->get('ATT_lname');
310
+	}
311
+
312
+
313
+	/**
314
+	 * Gets the attendee's full address as an array so client code can decide hwo to display it
315
+	 *
316
+	 * @return array numerically indexed, with each part of the address that is known.
317
+	 * Eg, if the user only responded to state and country,
318
+	 * it would be array(0=>'Alabama',1=>'USA')
319
+	 * @return array
320
+	 * @throws EE_Error
321
+	 */
322
+	public function full_address_as_array()
323
+	{
324
+		$full_address_array = array();
325
+		$initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
326
+		foreach ($initial_address_fields as $address_field_name) {
327
+			$address_fields_value = $this->get($address_field_name);
328
+			if (! empty($address_fields_value)) {
329
+				$full_address_array[] = $address_fields_value;
330
+			}
331
+		}
332
+		// now handle state and country
333
+		$state_obj = $this->state_obj();
334
+		if ($state_obj instanceof EE_State) {
335
+			$full_address_array[] = $state_obj->name();
336
+		}
337
+		$country_obj = $this->country_obj();
338
+		if ($country_obj instanceof EE_Country) {
339
+			$full_address_array[] = $country_obj->name();
340
+		}
341
+		// lastly get the xip
342
+		$zip_value = $this->zip();
343
+		if (! empty($zip_value)) {
344
+			$full_address_array[] = $zip_value;
345
+		}
346
+		return $full_address_array;
347
+	}
348
+
349
+
350
+	/**
351
+	 *        get Attendee Address
352
+	 *
353
+	 * @return string
354
+	 * @throws EE_Error
355
+	 */
356
+	public function address()
357
+	{
358
+		return $this->get('ATT_address');
359
+	}
360
+
361
+
362
+	/**
363
+	 *        get Attendee Address2
364
+	 *
365
+	 * @return string
366
+	 * @throws EE_Error
367
+	 */
368
+	public function address2()
369
+	{
370
+		return $this->get('ATT_address2');
371
+	}
372
+
373
+
374
+	/**
375
+	 *        get Attendee City
376
+	 *
377
+	 * @return string
378
+	 * @throws EE_Error
379
+	 */
380
+	public function city()
381
+	{
382
+		return $this->get('ATT_city');
383
+	}
384
+
385
+
386
+	/**
387
+	 *        get Attendee State ID
388
+	 *
389
+	 * @return string
390
+	 * @throws EE_Error
391
+	 */
392
+	public function state_ID()
393
+	{
394
+		return $this->get('STA_ID');
395
+	}
396
+
397
+
398
+	/**
399
+	 * @return string
400
+	 * @throws EE_Error
401
+	 */
402
+	public function state_abbrev()
403
+	{
404
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
405
+	}
406
+
407
+
408
+	/**
409
+	 * Gets the state set to this attendee
410
+	 *
411
+	 * @return EE_State
412
+	 * @throws EE_Error
413
+	 */
414
+	public function state_obj()
415
+	{
416
+		return $this->get_first_related('State');
417
+	}
418
+
419
+
420
+	/**
421
+	 * Returns the state's name, otherwise 'Unknown'
422
+	 *
423
+	 * @return string
424
+	 * @throws EE_Error
425
+	 */
426
+	public function state_name()
427
+	{
428
+		if ($this->state_obj()) {
429
+			return $this->state_obj()->name();
430
+		} else {
431
+			return '';
432
+		}
433
+	}
434
+
435
+
436
+	/**
437
+	 * either displays the state abbreviation or the state name, as determined
438
+	 * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
439
+	 * defaults to abbreviation
440
+	 *
441
+	 * @return string
442
+	 * @throws EE_Error
443
+	 */
444
+	public function state()
445
+	{
446
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
447
+			return $this->state_abbrev();
448
+		}
449
+		return $this->state_name();
450
+	}
451
+
452
+
453
+	/**
454
+	 *    get Attendee Country ISO Code
455
+	 *
456
+	 * @return string
457
+	 * @throws EE_Error
458
+	 */
459
+	public function country_ID()
460
+	{
461
+		return $this->get('CNT_ISO');
462
+	}
463
+
464
+
465
+	/**
466
+	 * Gets country set for this attendee
467
+	 *
468
+	 * @return EE_Country
469
+	 * @throws EE_Error
470
+	 */
471
+	public function country_obj()
472
+	{
473
+		return $this->get_first_related('Country');
474
+	}
475
+
476
+
477
+	/**
478
+	 * Returns the country's name if known, otherwise 'Unknown'
479
+	 *
480
+	 * @return string
481
+	 * @throws EE_Error
482
+	 */
483
+	public function country_name()
484
+	{
485
+		if ($this->country_obj()) {
486
+			return $this->country_obj()->name();
487
+		}
488
+		return '';
489
+	}
490
+
491
+
492
+	/**
493
+	 * either displays the country ISO2 code or the country name, as determined
494
+	 * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
495
+	 * defaults to abbreviation
496
+	 *
497
+	 * @return string
498
+	 * @throws EE_Error
499
+	 */
500
+	public function country()
501
+	{
502
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
503
+			return $this->country_ID();
504
+		}
505
+		return $this->country_name();
506
+	}
507
+
508
+
509
+	/**
510
+	 *        get Attendee Zip/Postal Code
511
+	 *
512
+	 * @return string
513
+	 * @throws EE_Error
514
+	 */
515
+	public function zip()
516
+	{
517
+		return $this->get('ATT_zip');
518
+	}
519
+
520
+
521
+	/**
522
+	 *        get Attendee Email Address
523
+	 *
524
+	 * @return string
525
+	 * @throws EE_Error
526
+	 */
527
+	public function email()
528
+	{
529
+		return $this->get('ATT_email');
530
+	}
531
+
532
+
533
+	/**
534
+	 *        get Attendee Phone #
535
+	 *
536
+	 * @return string
537
+	 * @throws EE_Error
538
+	 */
539
+	public function phone()
540
+	{
541
+		return $this->get('ATT_phone');
542
+	}
543
+
544
+
545
+	/**
546
+	 *    get deleted
547
+	 *
548
+	 * @return        bool
549
+	 * @throws EE_Error
550
+	 */
551
+	public function deleted()
552
+	{
553
+		return $this->get('ATT_deleted');
554
+	}
555
+
556
+
557
+	/**
558
+	 * Gets registrations of this attendee
559
+	 *
560
+	 * @param array $query_params
561
+	 * @return EE_Registration[]
562
+	 * @throws EE_Error
563
+	 */
564
+	public function get_registrations($query_params = array())
565
+	{
566
+		return $this->get_many_related('Registration', $query_params);
567
+	}
568
+
569
+
570
+	/**
571
+	 * Gets the most recent registration of this attendee
572
+	 *
573
+	 * @return EE_Registration
574
+	 * @throws EE_Error
575
+	 */
576
+	public function get_most_recent_registration()
577
+	{
578
+		return $this->get_first_related(
579
+			'Registration',
580
+			array('order_by' => array('REG_date' => 'DESC'))
581
+		); // null, 'REG_date', 'DESC', '=', 'OBJECT_K');
582
+	}
583
+
584
+
585
+	/**
586
+	 * Gets the most recent registration for this attend at this event
587
+	 *
588
+	 * @param int $event_id
589
+	 * @return EE_Registration
590
+	 * @throws EE_Error
591
+	 */
592
+	public function get_most_recent_registration_for_event($event_id)
593
+	{
594
+		return $this->get_first_related(
595
+			'Registration',
596
+			array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))
597
+		);
598
+	}
599
+
600
+
601
+	/**
602
+	 * returns any events attached to this attendee ($_Event property);
603
+	 *
604
+	 * @return array
605
+	 * @throws EE_Error
606
+	 */
607
+	public function events()
608
+	{
609
+		return $this->get_many_related('Event');
610
+	}
611
+
612
+
613
+	/**
614
+	 * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
615
+	 * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
616
+	 * used to save the billing info
617
+	 *
618
+	 * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
619
+	 * @return EE_Form_Section_Proper|null
620
+	 * @throws EE_Error
621
+	 */
622
+	public function billing_info_for_payment_method($payment_method)
623
+	{
624
+		$pm_type = $payment_method->type_obj();
625
+		if (! $pm_type instanceof EE_PMT_Base) {
626
+			return null;
627
+		}
628
+		$billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
629
+		if (! $billing_info) {
630
+			return null;
631
+		}
632
+		$billing_form = $pm_type->billing_form();
633
+		// double-check the form isn't totally hidden, in which case pretend there is no form
634
+		$form_totally_hidden = true;
635
+		foreach ($billing_form->inputs_in_subsections() as $input) {
636
+			if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
637
+				$form_totally_hidden = false;
638
+				break;
639
+			}
640
+		}
641
+		if ($form_totally_hidden) {
642
+			return null;
643
+		}
644
+		if ($billing_form instanceof EE_Form_Section_Proper) {
645
+			$billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
646
+		}
647
+
648
+		return $billing_form;
649
+	}
650
+
651
+
652
+	/**
653
+	 * Gets the postmeta key that holds this attendee's billing info for the
654
+	 * specified payment method
655
+	 *
656
+	 * @param EE_Payment_Method $payment_method
657
+	 * @return string
658
+	 * @throws EE_Error
659
+	 */
660
+	public function get_billing_info_postmeta_name($payment_method)
661
+	{
662
+		if ($payment_method->type_obj() instanceof EE_PMT_Base) {
663
+			return 'billing_info_' . $payment_method->type_obj()->system_name();
664
+		}
665
+		return null;
666
+	}
667
+
668
+
669
+	/**
670
+	 * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
671
+	 * retrieve it
672
+	 *
673
+	 * @param EE_Billing_Attendee_Info_Form $billing_form
674
+	 * @param EE_Payment_Method             $payment_method
675
+	 * @return boolean
676
+	 * @throws EE_Error
677
+	 */
678
+	public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
679
+	{
680
+		if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
681
+			EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
682
+			return false;
683
+		}
684
+		$billing_form->clean_sensitive_data();
685
+		return update_post_meta(
686
+			$this->ID(),
687
+			$this->get_billing_info_postmeta_name($payment_method),
688
+			$billing_form->input_values(true)
689
+		);
690
+	}
691
+
692
+
693
+	/**
694
+	 * Return the link to the admin details for the object.
695
+	 *
696
+	 * @return string
697
+	 * @throws EE_Error
698
+	 * @throws InvalidArgumentException
699
+	 * @throws InvalidDataTypeException
700
+	 * @throws InvalidInterfaceException
701
+	 * @throws ReflectionException
702
+	 */
703
+	public function get_admin_details_link()
704
+	{
705
+		return $this->get_admin_edit_link();
706
+	}
707
+
708
+
709
+	/**
710
+	 * Returns the link to the editor for the object.  Sometimes this is the same as the details.
711
+	 *
712
+	 * @return string
713
+	 * @throws EE_Error
714
+	 * @throws InvalidArgumentException
715
+	 * @throws ReflectionException
716
+	 * @throws InvalidDataTypeException
717
+	 * @throws InvalidInterfaceException
718
+	 */
719
+	public function get_admin_edit_link()
720
+	{
721
+		EE_Registry::instance()->load_helper('URL');
722
+		return EEH_URL::add_query_args_and_nonce(
723
+			array(
724
+				'page'   => 'espresso_registrations',
725
+				'action' => 'edit_attendee',
726
+				'post'   => $this->ID(),
727
+			),
728
+			admin_url('admin.php')
729
+		);
730
+	}
731
+
732
+
733
+	/**
734
+	 * Returns the link to a settings page for the object.
735
+	 *
736
+	 * @return string
737
+	 * @throws EE_Error
738
+	 * @throws InvalidArgumentException
739
+	 * @throws InvalidDataTypeException
740
+	 * @throws InvalidInterfaceException
741
+	 * @throws ReflectionException
742
+	 */
743
+	public function get_admin_settings_link()
744
+	{
745
+		return $this->get_admin_edit_link();
746
+	}
747
+
748
+
749
+	/**
750
+	 * Returns the link to the "overview" for the object (typically the "list table" view).
751
+	 *
752
+	 * @return string
753
+	 * @throws EE_Error
754
+	 * @throws InvalidArgumentException
755
+	 * @throws ReflectionException
756
+	 * @throws InvalidDataTypeException
757
+	 * @throws InvalidInterfaceException
758
+	 */
759
+	public function get_admin_overview_link()
760
+	{
761
+		EE_Registry::instance()->load_helper('URL');
762
+		return EEH_URL::add_query_args_and_nonce(
763
+			array(
764
+				'page'   => 'espresso_registrations',
765
+				'action' => 'contact_list',
766
+			),
767
+			admin_url('admin.php')
768
+		);
769
+	}
770 770
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,16 +36,16 @@  discard block
 block discarded – undo
36 36
      */
37 37
     protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
38 38
     {
39
-        if (! isset($fieldValues['ATT_full_name'])) {
40
-            $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
39
+        if ( ! isset($fieldValues['ATT_full_name'])) {
40
+            $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'].' ' : '';
41 41
             $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
42
-            $fieldValues['ATT_full_name'] = $fname . $lname;
42
+            $fieldValues['ATT_full_name'] = $fname.$lname;
43 43
         }
44
-        if (! isset($fieldValues['ATT_slug'])) {
44
+        if ( ! isset($fieldValues['ATT_slug'])) {
45 45
             // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
46 46
             $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
47 47
         }
48
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
48
+        if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
49 49
             $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
50 50
         }
51 51
         parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
         $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
326 326
         foreach ($initial_address_fields as $address_field_name) {
327 327
             $address_fields_value = $this->get($address_field_name);
328
-            if (! empty($address_fields_value)) {
328
+            if ( ! empty($address_fields_value)) {
329 329
                 $full_address_array[] = $address_fields_value;
330 330
             }
331 331
         }
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
         }
341 341
         // lastly get the xip
342 342
         $zip_value = $this->zip();
343
-        if (! empty($zip_value)) {
343
+        if ( ! empty($zip_value)) {
344 344
             $full_address_array[] = $zip_value;
345 345
         }
346 346
         return $full_address_array;
@@ -622,18 +622,18 @@  discard block
 block discarded – undo
622 622
     public function billing_info_for_payment_method($payment_method)
623 623
     {
624 624
         $pm_type = $payment_method->type_obj();
625
-        if (! $pm_type instanceof EE_PMT_Base) {
625
+        if ( ! $pm_type instanceof EE_PMT_Base) {
626 626
             return null;
627 627
         }
628 628
         $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
629
-        if (! $billing_info) {
629
+        if ( ! $billing_info) {
630 630
             return null;
631 631
         }
632 632
         $billing_form = $pm_type->billing_form();
633 633
         // double-check the form isn't totally hidden, in which case pretend there is no form
634 634
         $form_totally_hidden = true;
635 635
         foreach ($billing_form->inputs_in_subsections() as $input) {
636
-            if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
636
+            if ( ! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
637 637
                 $form_totally_hidden = false;
638 638
                 break;
639 639
             }
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
     public function get_billing_info_postmeta_name($payment_method)
661 661
     {
662 662
         if ($payment_method->type_obj() instanceof EE_PMT_Base) {
663
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
663
+            return 'billing_info_'.$payment_method->type_obj()->system_name();
664 664
         }
665 665
         return null;
666 666
     }
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
      */
678 678
     public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
679 679
     {
680
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
680
+        if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
681 681
             EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
682 682
             return false;
683 683
         }
Please login to merge, or discard this patch.
core/db_classes/EE_Event_Message_Template.class.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -12,25 +12,25 @@
 block discarded – undo
12 12
 class EE_Event_Message_Template extends EE_Base_Class
13 13
 {
14 14
 
15
-    /**
16
-     * @param array $props_n_values
17
-     * @param null  $timezone
18
-     * @return EE_Event_Message_Template|mixed
19
-     */
20
-    public static function new_instance($props_n_values = array(), $timezone = null)
21
-    {
22
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
23
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone);
24
-    }
15
+	/**
16
+	 * @param array $props_n_values
17
+	 * @param null  $timezone
18
+	 * @return EE_Event_Message_Template|mixed
19
+	 */
20
+	public static function new_instance($props_n_values = array(), $timezone = null)
21
+	{
22
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
23
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone);
24
+	}
25 25
 
26 26
 
27
-    /**
28
-     * @param array $props_n_values
29
-     * @param null  $timezone
30
-     * @return EE_Event_Message_Template
31
-     */
32
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
33
-    {
34
-        return new self($props_n_values, true, $timezone);
35
-    }
27
+	/**
28
+	 * @param array $props_n_values
29
+	 * @param null  $timezone
30
+	 * @return EE_Event_Message_Template
31
+	 */
32
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
33
+	{
34
+		return new self($props_n_values, true, $timezone);
35
+	}
36 36
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Change_Log.class.php 2 patches
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -11,217 +11,217 @@
 block discarded – undo
11 11
 class EE_Change_Log extends EE_Base_Class
12 12
 {
13 13
 
14
-    /**
15
-     * @param array  $props_n_values          incoming values
16
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
17
-     *                                        used.)
18
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
19
-     *                                        date_format and the second value is the time format
20
-     * @return EE_Change_Log
21
-     * @throws EE_Error
22
-     */
23
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
24
-    {
25
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
26
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
27
-    }
28
-
29
-
30
-    /**
31
-     * @param array  $props_n_values  incoming values from the database
32
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
33
-     *                                the website will be used.
34
-     * @return EE_Change_Log
35
-     */
36
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
37
-    {
38
-        return new self($props_n_values, true, $timezone);
39
-    }
40
-
41
-    /**
42
-     * Gets message
43
-     *
44
-     * @return mixed
45
-     * @throws EE_Error
46
-     */
47
-    public function message()
48
-    {
49
-        return $this->get('LOG_message');
50
-    }
51
-
52
-    /**
53
-     * Sets message
54
-     *
55
-     * @param mixed $message
56
-     * @throws EE_Error
57
-     */
58
-    public function set_message($message)
59
-    {
60
-        $this->set('LOG_message', $message);
61
-    }
62
-
63
-    /**
64
-     * Gets time
65
-     *
66
-     * @return string
67
-     * @throws EE_Error
68
-     */
69
-    public function time()
70
-    {
71
-        return $this->get('LOG_time');
72
-    }
73
-
74
-    /**
75
-     * Sets time
76
-     *
77
-     * @param string $time
78
-     * @throws EE_Error
79
-     */
80
-    public function set_time($time)
81
-    {
82
-        $this->set('LOG_time', $time);
83
-    }
84
-
85
-    /**
86
-     * Gets log_type
87
-     *
88
-     * @return string
89
-     * @throws EE_Error
90
-     */
91
-    public function log_type()
92
-    {
93
-        return $this->get('LOG_type');
94
-    }
95
-
96
-
97
-    /**
98
-     * Return the localized log type label.
99
-     *
100
-     * @return string
101
-     * @throws EE_Error
102
-     */
103
-    public function log_type_label()
104
-    {
105
-        return EEM_Change_Log::get_pretty_label_for_type($this->log_type());
106
-    }
107
-
108
-    /**
109
-     * Sets log_type
110
-     *
111
-     * @param string $log_type
112
-     * @throws EE_Error
113
-     */
114
-    public function set_log_type($log_type)
115
-    {
116
-        $this->set('LOG_type', $log_type);
117
-    }
118
-
119
-    /**
120
-     * Gets type of the model object related to this log
121
-     *
122
-     * @return string
123
-     * @throws EE_Error
124
-     */
125
-    public function OBJ_type()
126
-    {
127
-        return $this->get('OBJ_type');
128
-    }
129
-
130
-    /**
131
-     * Sets type
132
-     *
133
-     * @param string $type
134
-     * @throws EE_Error
135
-     */
136
-    public function set_OBJ_type($type)
137
-    {
138
-        $this->set('OBJ_type', $type);
139
-    }
140
-
141
-    /**
142
-     * Gets OBJ_ID (the ID of the item related to this log)
143
-     *
144
-     * @return mixed
145
-     * @throws EE_Error
146
-     */
147
-    public function OBJ_ID()
148
-    {
149
-        return $this->get('OBJ_ID');
150
-    }
151
-
152
-    /**
153
-     * Sets OBJ_ID
154
-     *
155
-     * @param mixed $OBJ_ID
156
-     * @throws EE_Error
157
-     */
158
-    public function set_OBJ_ID($OBJ_ID)
159
-    {
160
-        $this->set('OBJ_ID', $OBJ_ID);
161
-    }
162
-
163
-    /**
164
-     * Gets wp_user
165
-     *
166
-     * @return int
167
-     * @throws EE_Error
168
-     */
169
-    public function wp_user()
170
-    {
171
-        return $this->get('LOG_wp_user');
172
-    }
173
-
174
-    /**
175
-     * Sets wp_user
176
-     *
177
-     * @param int $wp_user_id
178
-     * @throws EE_Error
179
-     */
180
-    public function set_wp_user($wp_user_id)
181
-    {
182
-        $this->set('LOG_wp_user', $wp_user_id);
183
-    }
184
-
185
-    /**
186
-     * Gets the model object attached to this log
187
-     *
188
-     * @return EE_Base_Class
189
-     * @throws EE_Error
190
-     */
191
-    public function object()
192
-    {
193
-        $model_name_of_related_obj = $this->OBJ_type();
194
-        $is_model_name = EE_Registry::instance()->is_model_name($model_name_of_related_obj);
195
-        if (! $is_model_name) {
196
-            return null;
197
-        } else {
198
-            return $this->get_first_related($model_name_of_related_obj);
199
-        }
200
-    }
201
-
202
-    /**
203
-     * Shorthand for setting the OBJ_ID and OBJ_type. Slightly handier than using
204
-     * _add_relation_to because you don't have to specify what type of model you're
205
-     * associating it with
206
-     *
207
-     * @param EE_Base_Class $object
208
-     * @param boolean       $save
209
-     * @return bool if $save=true, NULL is $save=false
210
-     * @throws EE_Error
211
-     */
212
-    public function set_object($object, $save = true)
213
-    {
214
-        if ($object instanceof EE_Base_Class) {
215
-            $this->set_OBJ_type($object->get_model()->get_this_model_name());
216
-            $this->set_OBJ_ID($object->ID());
217
-        } else {
218
-            $this->set_OBJ_type(null);
219
-            $this->set_OBJ_ID(null);
220
-        }
221
-        if ($save) {
222
-            return $this->save();
223
-        } else {
224
-            return null;
225
-        }
226
-    }
14
+	/**
15
+	 * @param array  $props_n_values          incoming values
16
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
17
+	 *                                        used.)
18
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
19
+	 *                                        date_format and the second value is the time format
20
+	 * @return EE_Change_Log
21
+	 * @throws EE_Error
22
+	 */
23
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
24
+	{
25
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
26
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
27
+	}
28
+
29
+
30
+	/**
31
+	 * @param array  $props_n_values  incoming values from the database
32
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
33
+	 *                                the website will be used.
34
+	 * @return EE_Change_Log
35
+	 */
36
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
37
+	{
38
+		return new self($props_n_values, true, $timezone);
39
+	}
40
+
41
+	/**
42
+	 * Gets message
43
+	 *
44
+	 * @return mixed
45
+	 * @throws EE_Error
46
+	 */
47
+	public function message()
48
+	{
49
+		return $this->get('LOG_message');
50
+	}
51
+
52
+	/**
53
+	 * Sets message
54
+	 *
55
+	 * @param mixed $message
56
+	 * @throws EE_Error
57
+	 */
58
+	public function set_message($message)
59
+	{
60
+		$this->set('LOG_message', $message);
61
+	}
62
+
63
+	/**
64
+	 * Gets time
65
+	 *
66
+	 * @return string
67
+	 * @throws EE_Error
68
+	 */
69
+	public function time()
70
+	{
71
+		return $this->get('LOG_time');
72
+	}
73
+
74
+	/**
75
+	 * Sets time
76
+	 *
77
+	 * @param string $time
78
+	 * @throws EE_Error
79
+	 */
80
+	public function set_time($time)
81
+	{
82
+		$this->set('LOG_time', $time);
83
+	}
84
+
85
+	/**
86
+	 * Gets log_type
87
+	 *
88
+	 * @return string
89
+	 * @throws EE_Error
90
+	 */
91
+	public function log_type()
92
+	{
93
+		return $this->get('LOG_type');
94
+	}
95
+
96
+
97
+	/**
98
+	 * Return the localized log type label.
99
+	 *
100
+	 * @return string
101
+	 * @throws EE_Error
102
+	 */
103
+	public function log_type_label()
104
+	{
105
+		return EEM_Change_Log::get_pretty_label_for_type($this->log_type());
106
+	}
107
+
108
+	/**
109
+	 * Sets log_type
110
+	 *
111
+	 * @param string $log_type
112
+	 * @throws EE_Error
113
+	 */
114
+	public function set_log_type($log_type)
115
+	{
116
+		$this->set('LOG_type', $log_type);
117
+	}
118
+
119
+	/**
120
+	 * Gets type of the model object related to this log
121
+	 *
122
+	 * @return string
123
+	 * @throws EE_Error
124
+	 */
125
+	public function OBJ_type()
126
+	{
127
+		return $this->get('OBJ_type');
128
+	}
129
+
130
+	/**
131
+	 * Sets type
132
+	 *
133
+	 * @param string $type
134
+	 * @throws EE_Error
135
+	 */
136
+	public function set_OBJ_type($type)
137
+	{
138
+		$this->set('OBJ_type', $type);
139
+	}
140
+
141
+	/**
142
+	 * Gets OBJ_ID (the ID of the item related to this log)
143
+	 *
144
+	 * @return mixed
145
+	 * @throws EE_Error
146
+	 */
147
+	public function OBJ_ID()
148
+	{
149
+		return $this->get('OBJ_ID');
150
+	}
151
+
152
+	/**
153
+	 * Sets OBJ_ID
154
+	 *
155
+	 * @param mixed $OBJ_ID
156
+	 * @throws EE_Error
157
+	 */
158
+	public function set_OBJ_ID($OBJ_ID)
159
+	{
160
+		$this->set('OBJ_ID', $OBJ_ID);
161
+	}
162
+
163
+	/**
164
+	 * Gets wp_user
165
+	 *
166
+	 * @return int
167
+	 * @throws EE_Error
168
+	 */
169
+	public function wp_user()
170
+	{
171
+		return $this->get('LOG_wp_user');
172
+	}
173
+
174
+	/**
175
+	 * Sets wp_user
176
+	 *
177
+	 * @param int $wp_user_id
178
+	 * @throws EE_Error
179
+	 */
180
+	public function set_wp_user($wp_user_id)
181
+	{
182
+		$this->set('LOG_wp_user', $wp_user_id);
183
+	}
184
+
185
+	/**
186
+	 * Gets the model object attached to this log
187
+	 *
188
+	 * @return EE_Base_Class
189
+	 * @throws EE_Error
190
+	 */
191
+	public function object()
192
+	{
193
+		$model_name_of_related_obj = $this->OBJ_type();
194
+		$is_model_name = EE_Registry::instance()->is_model_name($model_name_of_related_obj);
195
+		if (! $is_model_name) {
196
+			return null;
197
+		} else {
198
+			return $this->get_first_related($model_name_of_related_obj);
199
+		}
200
+	}
201
+
202
+	/**
203
+	 * Shorthand for setting the OBJ_ID and OBJ_type. Slightly handier than using
204
+	 * _add_relation_to because you don't have to specify what type of model you're
205
+	 * associating it with
206
+	 *
207
+	 * @param EE_Base_Class $object
208
+	 * @param boolean       $save
209
+	 * @return bool if $save=true, NULL is $save=false
210
+	 * @throws EE_Error
211
+	 */
212
+	public function set_object($object, $save = true)
213
+	{
214
+		if ($object instanceof EE_Base_Class) {
215
+			$this->set_OBJ_type($object->get_model()->get_this_model_name());
216
+			$this->set_OBJ_ID($object->ID());
217
+		} else {
218
+			$this->set_OBJ_type(null);
219
+			$this->set_OBJ_ID(null);
220
+		}
221
+		if ($save) {
222
+			return $this->save();
223
+		} else {
224
+			return null;
225
+		}
226
+	}
227 227
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -192,7 +192,7 @@
 block discarded – undo
192 192
     {
193 193
         $model_name_of_related_obj = $this->OBJ_type();
194 194
         $is_model_name = EE_Registry::instance()->is_model_name($model_name_of_related_obj);
195
-        if (! $is_model_name) {
195
+        if ( ! $is_model_name) {
196 196
             return null;
197 197
         } else {
198 198
             return $this->get_first_related($model_name_of_related_obj);
Please login to merge, or discard this patch.
core/libraries/line_item_filters/EE_Line_Item_Filter_Processor.class.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -36,88 +36,88 @@
 block discarded – undo
36 36
 class EE_Line_Item_Filter_Processor
37 37
 {
38 38
 
39
-    /**
40
-     * @type EE_Line_Item_Filter_Collection $line_item_filters
41
-     */
42
-    protected $line_item_filters;
39
+	/**
40
+	 * @type EE_Line_Item_Filter_Collection $line_item_filters
41
+	 */
42
+	protected $line_item_filters;
43 43
 
44
-    /**
45
-     * @type EEI_Line_Item $grand_total_line_item
46
-     */
47
-    protected $grand_total_line_item;
44
+	/**
45
+	 * @type EEI_Line_Item $grand_total_line_item
46
+	 */
47
+	protected $grand_total_line_item;
48 48
 
49 49
 
50
-    /**
51
-     * EE_Line_Item_Filter_Processor constructor.
52
-     *
53
-     * @param \EE_Line_Item_Filter_Collection $line_item_filters
54
-     * @param \EEI_Line_Item                  $grand_total_line_item
55
-     * @throws \EE_Error
56
-     */
57
-    public function __construct(EE_Line_Item_Filter_Collection $line_item_filters, EEI_Line_Item $grand_total_line_item)
58
-    {
59
-        $this->line_item_filters = $line_item_filters;
60
-        if ($grand_total_line_item->type() !== EEM_Line_Item::type_total) {
61
-            throw new EE_Error(__('A Line Item of the type total is required', 'event_espresso'));
62
-        }
63
-        $this->grand_total_line_item = $this->clone_and_reset_line_item_tree($grand_total_line_item);
64
-    }
50
+	/**
51
+	 * EE_Line_Item_Filter_Processor constructor.
52
+	 *
53
+	 * @param \EE_Line_Item_Filter_Collection $line_item_filters
54
+	 * @param \EEI_Line_Item                  $grand_total_line_item
55
+	 * @throws \EE_Error
56
+	 */
57
+	public function __construct(EE_Line_Item_Filter_Collection $line_item_filters, EEI_Line_Item $grand_total_line_item)
58
+	{
59
+		$this->line_item_filters = $line_item_filters;
60
+		if ($grand_total_line_item->type() !== EEM_Line_Item::type_total) {
61
+			throw new EE_Error(__('A Line Item of the type total is required', 'event_espresso'));
62
+		}
63
+		$this->grand_total_line_item = $this->clone_and_reset_line_item_tree($grand_total_line_item);
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * clone_and_reset_line_item_tree
69
-     *
70
-     * @param \EEI_Line_Item $line_item
71
-     * @return \EEI_Line_Item
72
-     */
73
-    protected function clone_and_reset_line_item_tree(EEI_Line_Item $line_item)
74
-    {
75
-        $cloned_line_item = $this->clone_and_reset_line_item($line_item);
76
-        foreach ($line_item->children() as $child_line_item) {
77
-            $cloned_line_item->add_child_line_item($this->clone_and_reset_line_item_tree($child_line_item));
78
-        }
79
-        return $cloned_line_item;
80
-    }
67
+	/**
68
+	 * clone_and_reset_line_item_tree
69
+	 *
70
+	 * @param \EEI_Line_Item $line_item
71
+	 * @return \EEI_Line_Item
72
+	 */
73
+	protected function clone_and_reset_line_item_tree(EEI_Line_Item $line_item)
74
+	{
75
+		$cloned_line_item = $this->clone_and_reset_line_item($line_item);
76
+		foreach ($line_item->children() as $child_line_item) {
77
+			$cloned_line_item->add_child_line_item($this->clone_and_reset_line_item_tree($child_line_item));
78
+		}
79
+		return $cloned_line_item;
80
+	}
81 81
 
82 82
 
83
-    /**
84
-     * clone_and_reset_line_item
85
-     *
86
-     * clones the incoming object
87
-     * resets any fields that represent database primary keys
88
-     * resets total
89
-     *
90
-     * @param \EEI_Line_Item $line_item
91
-     * @return \EEI_Line_Item
92
-     */
93
-    protected function clone_and_reset_line_item(EEI_Line_Item $line_item)
94
-    {
95
-        // we don't actually want to work with the original line item, so clone it
96
-        $cloned_line_item = clone $line_item;
97
-        $cloned_line_item->set('LIN_ID', null);
98
-        $cloned_line_item->set('LIN_parent', null);
99
-        $cloned_line_item->clear_related_line_item_cache();
100
-        foreach (array_keys(EEM_Line_Item::instance()->relation_settings()) as $relation_name) {
101
-            $cloned_line_item->clear_cache($relation_name, null, true);
102
-        }
103
-        $cloned_line_item->set_allow_persist(false);
104
-        return $cloned_line_item;
105
-    }
83
+	/**
84
+	 * clone_and_reset_line_item
85
+	 *
86
+	 * clones the incoming object
87
+	 * resets any fields that represent database primary keys
88
+	 * resets total
89
+	 *
90
+	 * @param \EEI_Line_Item $line_item
91
+	 * @return \EEI_Line_Item
92
+	 */
93
+	protected function clone_and_reset_line_item(EEI_Line_Item $line_item)
94
+	{
95
+		// we don't actually want to work with the original line item, so clone it
96
+		$cloned_line_item = clone $line_item;
97
+		$cloned_line_item->set('LIN_ID', null);
98
+		$cloned_line_item->set('LIN_parent', null);
99
+		$cloned_line_item->clear_related_line_item_cache();
100
+		foreach (array_keys(EEM_Line_Item::instance()->relation_settings()) as $relation_name) {
101
+			$cloned_line_item->clear_cache($relation_name, null, true);
102
+		}
103
+		$cloned_line_item->set_allow_persist(false);
104
+		return $cloned_line_item;
105
+	}
106 106
 
107 107
 
108
-    /**
109
-     * process
110
-     *
111
-     * @return EEI_Line_Item
112
-     */
113
-    public function process()
114
-    {
115
-        $this->line_item_filters->rewind();
116
-        while ($this->line_item_filters->valid()) {
117
-            $this->grand_total_line_item = $this->line_item_filters->current()->process($this->grand_total_line_item);
118
-            $this->line_item_filters->next();
119
-        }
120
-        $this->grand_total_line_item->recalculate_total_including_taxes();
121
-        return $this->grand_total_line_item;
122
-    }
108
+	/**
109
+	 * process
110
+	 *
111
+	 * @return EEI_Line_Item
112
+	 */
113
+	public function process()
114
+	{
115
+		$this->line_item_filters->rewind();
116
+		while ($this->line_item_filters->valid()) {
117
+			$this->grand_total_line_item = $this->line_item_filters->current()->process($this->grand_total_line_item);
118
+			$this->line_item_filters->next();
119
+		}
120
+		$this->grand_total_line_item->recalculate_total_including_taxes();
121
+		return $this->grand_total_line_item;
122
+	}
123 123
 }
Please login to merge, or discard this patch.
core/libraries/line_item_filters/EE_Non_Zero_Line_Item_Filter.class.php 2 patches
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -14,96 +14,96 @@
 block discarded – undo
14 14
 class EE_Non_Zero_Line_Item_Filter extends EE_Line_Item_Filter_Base
15 15
 {
16 16
 
17
-    /**
18
-     * EE_Non_Zero_Line_Item_Filter constructor.
19
-     */
20
-    public function __construct()
21
-    {
22
-    }
17
+	/**
18
+	 * EE_Non_Zero_Line_Item_Filter constructor.
19
+	 */
20
+	public function __construct()
21
+	{
22
+	}
23 23
 
24 24
 
25
-    /**
26
-     * Creates a duplicate of the line item tree, except only includes billable items
27
-     * and the portion of line items attributed to billable things
28
-     *
29
-     * @param EEI_Line_Item $line_item
30
-     * @return EEI_Line_Item
31
-     */
32
-    public function process(EEI_Line_Item $line_item)
33
-    {
34
-        $non_zero_line_item = $this->_filter_zero_line_item($line_item);
35
-        if (! $non_zero_line_item instanceof EEI_Line_Item) {
36
-            return null;
37
-        }
38
-        // if this is an event subtotal, we want to only include it if it
39
-        // has a non-zero total and at least one ticket line item child
40
-        if ($line_item->children()) {
41
-            $ticket_or_subtotals_with_tkt_children_count = 0;
42
-            foreach ($line_item->children() as $child_line_item) {
43
-                $code = $child_line_item->code();
44
-                $child_line_item = $this->process($child_line_item);
45
-                if (! $child_line_item instanceof EEI_Line_Item) {
46
-                    $line_item->delete_child_line_item($code);
47
-                    continue;
48
-                }
49
-                if ((
50
-                        $child_line_item instanceof EEI_Line_Item
51
-                        && $child_line_item->type() === EEM_Line_Item::type_sub_total
52
-                    )
53
-                    || (
54
-                        $child_line_item instanceof EEI_Line_Item
55
-                        && $child_line_item->type() === EEM_Line_Item::type_line_item
56
-                        && $child_line_item->OBJ_type() === 'Ticket'
57
-                    )
58
-                ) {
59
-                    $ticket_or_subtotals_with_tkt_children_count++;
60
-                }
61
-            }
62
-            // if this is an event subtotal with NO ticket children
63
-            // we basically want to ignore it
64
-            return $this->_filter_zero_subtotal_line_item(
65
-                $non_zero_line_item,
66
-                $ticket_or_subtotals_with_tkt_children_count
67
-            );
68
-        }
69
-        return $non_zero_line_item;
70
-    }
25
+	/**
26
+	 * Creates a duplicate of the line item tree, except only includes billable items
27
+	 * and the portion of line items attributed to billable things
28
+	 *
29
+	 * @param EEI_Line_Item $line_item
30
+	 * @return EEI_Line_Item
31
+	 */
32
+	public function process(EEI_Line_Item $line_item)
33
+	{
34
+		$non_zero_line_item = $this->_filter_zero_line_item($line_item);
35
+		if (! $non_zero_line_item instanceof EEI_Line_Item) {
36
+			return null;
37
+		}
38
+		// if this is an event subtotal, we want to only include it if it
39
+		// has a non-zero total and at least one ticket line item child
40
+		if ($line_item->children()) {
41
+			$ticket_or_subtotals_with_tkt_children_count = 0;
42
+			foreach ($line_item->children() as $child_line_item) {
43
+				$code = $child_line_item->code();
44
+				$child_line_item = $this->process($child_line_item);
45
+				if (! $child_line_item instanceof EEI_Line_Item) {
46
+					$line_item->delete_child_line_item($code);
47
+					continue;
48
+				}
49
+				if ((
50
+						$child_line_item instanceof EEI_Line_Item
51
+						&& $child_line_item->type() === EEM_Line_Item::type_sub_total
52
+					)
53
+					|| (
54
+						$child_line_item instanceof EEI_Line_Item
55
+						&& $child_line_item->type() === EEM_Line_Item::type_line_item
56
+						&& $child_line_item->OBJ_type() === 'Ticket'
57
+					)
58
+				) {
59
+					$ticket_or_subtotals_with_tkt_children_count++;
60
+				}
61
+			}
62
+			// if this is an event subtotal with NO ticket children
63
+			// we basically want to ignore it
64
+			return $this->_filter_zero_subtotal_line_item(
65
+				$non_zero_line_item,
66
+				$ticket_or_subtotals_with_tkt_children_count
67
+			);
68
+		}
69
+		return $non_zero_line_item;
70
+	}
71 71
 
72 72
 
73
-    /**
74
-     * Creates a new, unsaved line item, but if it's a ticket line item
75
-     * with a total of 0, or a subtotal of 0, returns null instead
76
-     *
77
-     * @param EEI_Line_Item $line_item
78
-     * @return EEI_Line_Item
79
-     */
80
-    protected function _filter_zero_line_item(EEI_Line_Item $line_item)
81
-    {
82
-        if ($line_item->type() === EEM_Line_Item::type_line_item
83
-            && $line_item->OBJ_type() === 'Ticket'
84
-            && (int) $line_item->quantity() === 0
85
-        ) {
86
-            return null;
87
-        }
88
-        return $line_item;
89
-    }
73
+	/**
74
+	 * Creates a new, unsaved line item, but if it's a ticket line item
75
+	 * with a total of 0, or a subtotal of 0, returns null instead
76
+	 *
77
+	 * @param EEI_Line_Item $line_item
78
+	 * @return EEI_Line_Item
79
+	 */
80
+	protected function _filter_zero_line_item(EEI_Line_Item $line_item)
81
+	{
82
+		if ($line_item->type() === EEM_Line_Item::type_line_item
83
+			&& $line_item->OBJ_type() === 'Ticket'
84
+			&& (int) $line_item->quantity() === 0
85
+		) {
86
+			return null;
87
+		}
88
+		return $line_item;
89
+	}
90 90
 
91 91
 
92
-    /**
93
-     * Creates a new, unsaved line item, but if it's a ticket line item
94
-     * with a total of 0, or a subtotal of 0, returns null instead
95
-     *
96
-     * @param EEI_Line_Item $line_item
97
-     * @param int           $ticket_children
98
-     * @return EEI_Line_Item
99
-     */
100
-    protected function _filter_zero_subtotal_line_item(EEI_Line_Item $line_item, $ticket_children = 0)
101
-    {
102
-        if ((int) $ticket_children === 0
103
-            && $line_item->type() === EEM_Line_Item::type_sub_total
104
-        ) {
105
-            return null;
106
-        }
107
-        return $line_item;
108
-    }
92
+	/**
93
+	 * Creates a new, unsaved line item, but if it's a ticket line item
94
+	 * with a total of 0, or a subtotal of 0, returns null instead
95
+	 *
96
+	 * @param EEI_Line_Item $line_item
97
+	 * @param int           $ticket_children
98
+	 * @return EEI_Line_Item
99
+	 */
100
+	protected function _filter_zero_subtotal_line_item(EEI_Line_Item $line_item, $ticket_children = 0)
101
+	{
102
+		if ((int) $ticket_children === 0
103
+			&& $line_item->type() === EEM_Line_Item::type_sub_total
104
+		) {
105
+			return null;
106
+		}
107
+		return $line_item;
108
+	}
109 109
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     public function process(EEI_Line_Item $line_item)
33 33
     {
34 34
         $non_zero_line_item = $this->_filter_zero_line_item($line_item);
35
-        if (! $non_zero_line_item instanceof EEI_Line_Item) {
35
+        if ( ! $non_zero_line_item instanceof EEI_Line_Item) {
36 36
             return null;
37 37
         }
38 38
         // if this is an event subtotal, we want to only include it if it
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             foreach ($line_item->children() as $child_line_item) {
43 43
                 $code = $child_line_item->code();
44 44
                 $child_line_item = $this->process($child_line_item);
45
-                if (! $child_line_item instanceof EEI_Line_Item) {
45
+                if ( ! $child_line_item instanceof EEI_Line_Item) {
46 46
                     $line_item->delete_child_line_item($code);
47 47
                     continue;
48 48
                 }
Please login to merge, or discard this patch.
core/libraries/line_item_filters/EE_Line_Item_Filter_Collection.class.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * EE_Line_Item_Filter_Collection constructor.
23
-     */
24
-    public function __construct()
25
-    {
26
-        $this->interface = 'EEI_Line_Item_Filter';
27
-    }
21
+	/**
22
+	 * EE_Line_Item_Filter_Collection constructor.
23
+	 */
24
+	public function __construct()
25
+	{
26
+		$this->interface = 'EEI_Line_Item_Filter';
27
+	}
28 28
 }
Please login to merge, or discard this patch.