Completed
Branch fix-dummy-related-question-qst... (e5efcf)
by
unknown
07:49 queued 03:45
created
core/libraries/batch/Helpers/JobParameters.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      */
159 159
     public static function load($job_id)
160 160
     {
161
-        $job_parameter_vars = get_option(JobParameters::wp_option_prefix . $job_id);
161
+        $job_parameter_vars = get_option(JobParameters::wp_option_prefix.$job_id);
162 162
         if (
163 163
             ! is_array($job_parameter_vars) ||
164 164
             ! isset($job_parameter_vars['_classname']) ||
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
                         'event_espresso'
172 172
                     ),
173 173
                     $job_id,
174
-                    get_option(JobParameters::wp_option_prefix . $job_id)
174
+                    get_option(JobParameters::wp_option_prefix.$job_id)
175 175
                 )
176 176
             );
177 177
         }
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
      */
230 230
     public function request_datum($key, $default = '')
231 231
     {
232
-        if (isset($this->_request_data[ $key ])) {
233
-            return $this->_request_data[ $key ];
232
+        if (isset($this->_request_data[$key])) {
233
+            return $this->_request_data[$key];
234 234
         } else {
235 235
             return $default;
236 236
         }
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
      */
247 247
     public function extra_datum($key, $default = '')
248 248
     {
249
-        if (isset($this->_extra_data[ $key ])) {
250
-            return $this->_extra_data[ $key ];
249
+        if (isset($this->_extra_data[$key])) {
250
+            return $this->_extra_data[$key];
251 251
         } else {
252 252
             return $default;
253 253
         }
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
      */
263 263
     public function add_extra_data($key, $value)
264 264
     {
265
-        $this->_extra_data[ $key ] = $value;
265
+        $this->_extra_data[$key] = $value;
266 266
     }
267 267
 
268 268
 
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
      */
386 386
     public function option_name()
387 387
     {
388
-        return JobParameters::wp_option_prefix . $this->job_id();
388
+        return JobParameters::wp_option_prefix.$this->job_id();
389 389
     }
390 390
 
391 391
 
Please login to merge, or discard this patch.
Indentation   +393 added lines, -393 removed lines patch added patch discarded remove patch
@@ -14,397 +14,397 @@
 block discarded – undo
14 14
  */
15 15
 class JobParameters
16 16
 {
17
-    // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
18
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
19
-    // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
20
-    /**
21
-     * status indicating the job should continue
22
-     */
23
-    const status_continue = 'continue';
24
-
25
-    /**
26
-     * status indicated the job has been completed successfully and should be cleaned up next
27
-     */
28
-    const status_complete = 'complete';
29
-
30
-    /**
31
-     * status indicating there was an error and the job should be cleaned up
32
-     */
33
-    const status_error = 'error';
34
-
35
-    /**
36
-     * status indicating the job has been cleaned up, and so this is probably the last
37
-     * time you'll see this job
38
-     */
39
-    const status_cleaned_up = 'cleaned_up';
40
-
41
-    const wp_option_prefix = 'ee_job_parameters_';
42
-
43
-
44
-    /**
45
-     * String uniquely identifying the job
46
-     *
47
-     * @var string
48
-     */
49
-    protected $_job_id;
50
-
51
-    /**
52
-     * @var string
53
-     */
54
-    protected $_classname;
55
-
56
-    /**
57
-     * @var array
58
-     */
59
-    protected $_request_data;
60
-
61
-    /**
62
-     * Array of any extra data we want to remember about this request, that
63
-     * wasn't necessarily past in with the request data
64
-     *
65
-     * @var array
66
-     */
67
-    protected $_extra_data;
68
-
69
-    /**
70
-     * Estimate of how many units HAVE been processed
71
-     *
72
-     * @var int
73
-     */
74
-    protected $_units_processed = 0;
75
-
76
-    /**
77
-     * @var string
78
-     */
79
-    protected $_status;
80
-
81
-    /**
82
-     * The size of the total job in whatever units you want.
83
-     * If you can't provide an estimate leave as 0.
84
-     * Once _units_processed equals _job_size, we should be done
85
-     *
86
-     * @var int
87
-     */
88
-    protected $_job_size = 0;
89
-
90
-
91
-    /**
92
-     * @param string $job_id
93
-     * @param string $classname
94
-     * @param array  $request_data
95
-     * @param array  $extra_data
96
-     */
97
-    public function __construct($job_id, $classname, $request_data, $extra_data = array())
98
-    {
99
-        $this->set_job_id($job_id);
100
-        $this->set_classname($classname);
101
-        $this->set_request_data($request_data);
102
-        $this->set_extra_data($extra_data);
103
-        $this->set_status(JobParameters::status_continue);
104
-    }
105
-
106
-
107
-    /**
108
-     * Returns the array of strings of valid stati
109
-     *
110
-     * @return array
111
-     */
112
-    public static function valid_stati()
113
-    {
114
-        return array(
115
-            JobParameters::status_complete,
116
-            JobParameters::status_continue,
117
-            JobParameters::status_error,
118
-            JobParameters::status_cleaned_up,
119
-        );
120
-    }
121
-
122
-
123
-    /**
124
-     * Saves this option to the database (wordpress options table)
125
-     *
126
-     * @param boolean $first
127
-     * @return boolean success
128
-     */
129
-    public function save($first = false)
130
-    {
131
-        $object_vars = get_object_vars($this);
132
-        if ($first) {
133
-            return add_option($this->option_name(), $object_vars, null, 'no');
134
-        } else {
135
-            return update_option($this->option_name(), $object_vars);
136
-        }
137
-    }
138
-
139
-
140
-    /**
141
-     * Deletes the job from teh database, although this object is still usable
142
-     * for the rest of the request
143
-     *
144
-     * @return boolean
145
-     */
146
-    public function delete()
147
-    {
148
-        return delete_option($this->option_name());
149
-    }
150
-
151
-
152
-    /**
153
-     * Loads the specified job from the database
154
-     *
155
-     * @param string $job_id
156
-     * @return JobParameters
157
-     * @throws BatchRequestException
158
-     */
159
-    public static function load($job_id)
160
-    {
161
-        $job_parameter_vars = get_option(JobParameters::wp_option_prefix . $job_id);
162
-        if (
163
-            ! is_array($job_parameter_vars) ||
164
-            ! isset($job_parameter_vars['_classname']) ||
165
-            ! isset($job_parameter_vars['_request_data'])
166
-        ) {
167
-            throw new BatchRequestException(
168
-                sprintf(
169
-                    esc_html__(
170
-                        'Could not retrieve job %1$s from the Wordpress options table, and so the job could not continue. The wordpress option was %2$s',
171
-                        'event_espresso'
172
-                    ),
173
-                    $job_id,
174
-                    get_option(JobParameters::wp_option_prefix . $job_id)
175
-                )
176
-            );
177
-        }
178
-        $job_parameters = new JobParameters(
179
-            $job_id,
180
-            $job_parameter_vars['_classname'],
181
-            $job_parameter_vars['_request_data']
182
-        );
183
-        foreach ($job_parameter_vars as $key => $value) {
184
-            $job_parameters->{$key} = $value;
185
-        }
186
-        return $job_parameters;
187
-    }
188
-
189
-
190
-    /**
191
-     * Gets the job's unique string
192
-     *
193
-     * @return string
194
-     */
195
-    public function job_id()
196
-    {
197
-        return $this->_job_id;
198
-    }
199
-
200
-
201
-    /**
202
-     * Gets the classname that should run this job
203
-     *
204
-     * @return string
205
-     */
206
-    public function classname()
207
-    {
208
-        return $this->_classname;
209
-    }
210
-
211
-
212
-    /**
213
-     * Gets the original array of request data for this job
214
-     *
215
-     * @return array
216
-     */
217
-    public function request_data()
218
-    {
219
-        return $this->_request_data;
220
-    }
221
-
222
-
223
-    /**
224
-     * Gets a single item from the request data
225
-     *
226
-     * @param string       $key
227
-     * @param string|array $default
228
-     * @return string|array
229
-     */
230
-    public function request_datum($key, $default = '')
231
-    {
232
-        if (isset($this->_request_data[ $key ])) {
233
-            return $this->_request_data[ $key ];
234
-        } else {
235
-            return $default;
236
-        }
237
-    }
238
-
239
-
240
-    /**
241
-     * Gets a single item from the extra data
242
-     *
243
-     * @param string       $key
244
-     * @param string|array $default
245
-     * @return string|array
246
-     */
247
-    public function extra_datum($key, $default = '')
248
-    {
249
-        if (isset($this->_extra_data[ $key ])) {
250
-            return $this->_extra_data[ $key ];
251
-        } else {
252
-            return $default;
253
-        }
254
-    }
255
-
256
-
257
-    /**
258
-     * Adds an extra piece of extra data that we're going to want later during the job
259
-     *
260
-     * @param string                $key
261
-     * @param string|int|array|null $value almost any extra data you want to store
262
-     */
263
-    public function add_extra_data($key, $value)
264
-    {
265
-        $this->_extra_data[ $key ] = $value;
266
-    }
267
-
268
-
269
-    /**
270
-     * Array of any extra data we want to store
271
-     *
272
-     * @return array
273
-     */
274
-    public function extra_data()
275
-    {
276
-        return $this->_extra_data;
277
-    }
278
-
279
-
280
-    /**
281
-     * Returns the job size, in whatever units you want
282
-     *
283
-     * @return int
284
-     */
285
-    public function job_size()
286
-    {
287
-        return $this->_job_size;
288
-    }
289
-
290
-
291
-    /**
292
-     * Sets the job size. You decide what units to use
293
-     *
294
-     * @param int $size
295
-     */
296
-    public function set_job_size($size)
297
-    {
298
-        $this->_job_size = $size;
299
-    }
300
-
301
-
302
-    /**
303
-     * The number of "units" processed, in the same units as the "job size"
304
-     *
305
-     * @return int
306
-     */
307
-    public function units_processed()
308
-    {
309
-        return $this->_units_processed;
310
-    }
311
-
312
-
313
-    /**
314
-     * Marks more units as processed
315
-     *
316
-     * @param int $newly_processed
317
-     * @return int updated units processed
318
-     */
319
-    public function mark_processed($newly_processed)
320
-    {
321
-        $this->_units_processed += $newly_processed;
322
-        return $this->_units_processed;
323
-    }
324
-
325
-
326
-    /**
327
-     * Sets the total count of units processed. You might prefer to use mark_processed
328
-     *
329
-     * @param int $total_units_processed
330
-     */
331
-    public function set_units_processed($total_units_processed)
332
-    {
333
-        $this->_units_processed = $total_units_processed;
334
-    }
335
-
336
-
337
-    /**
338
-     * Sets the job's ID
339
-     *
340
-     * @param string $job_id
341
-     */
342
-    public function set_job_id($job_id)
343
-    {
344
-        $this->_job_id = $job_id;
345
-    }
346
-
347
-
348
-    /**
349
-     * sets the classname
350
-     *
351
-     * @param string $classname
352
-     */
353
-    public function set_classname($classname)
354
-    {
355
-        $this->_classname = $classname;
356
-    }
357
-
358
-
359
-    /**
360
-     * Sets the request data
361
-     *
362
-     * @param array $request_data
363
-     */
364
-    public function set_request_data($request_data)
365
-    {
366
-        $this->_request_data = $request_data;
367
-    }
368
-
369
-
370
-    /**
371
-     * Sets the array of extra data we want to store on this request
372
-     *
373
-     * @param array $extra_data
374
-     */
375
-    public function set_extra_data($extra_data)
376
-    {
377
-        $this->_extra_data = $extra_data;
378
-    }
379
-
380
-
381
-    /**
382
-     * Gets the name of the wordpress option that should store these job parameters
383
-     *
384
-     * @return string
385
-     */
386
-    public function option_name()
387
-    {
388
-        return JobParameters::wp_option_prefix . $this->job_id();
389
-    }
390
-
391
-
392
-    /**
393
-     * Gets the job\s current status. One of JobParameters::valid_stati();
394
-     *
395
-     * @return string
396
-     */
397
-    public function status()
398
-    {
399
-        return $this->_status;
400
-    }
401
-
402
-
403
-    /**
404
-     * @param string $status on eof JobParameters::valid_stati()
405
-     */
406
-    public function set_status($status)
407
-    {
408
-        $this->_status = $status;
409
-    }
17
+	// phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
18
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
19
+	// phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
20
+	/**
21
+	 * status indicating the job should continue
22
+	 */
23
+	const status_continue = 'continue';
24
+
25
+	/**
26
+	 * status indicated the job has been completed successfully and should be cleaned up next
27
+	 */
28
+	const status_complete = 'complete';
29
+
30
+	/**
31
+	 * status indicating there was an error and the job should be cleaned up
32
+	 */
33
+	const status_error = 'error';
34
+
35
+	/**
36
+	 * status indicating the job has been cleaned up, and so this is probably the last
37
+	 * time you'll see this job
38
+	 */
39
+	const status_cleaned_up = 'cleaned_up';
40
+
41
+	const wp_option_prefix = 'ee_job_parameters_';
42
+
43
+
44
+	/**
45
+	 * String uniquely identifying the job
46
+	 *
47
+	 * @var string
48
+	 */
49
+	protected $_job_id;
50
+
51
+	/**
52
+	 * @var string
53
+	 */
54
+	protected $_classname;
55
+
56
+	/**
57
+	 * @var array
58
+	 */
59
+	protected $_request_data;
60
+
61
+	/**
62
+	 * Array of any extra data we want to remember about this request, that
63
+	 * wasn't necessarily past in with the request data
64
+	 *
65
+	 * @var array
66
+	 */
67
+	protected $_extra_data;
68
+
69
+	/**
70
+	 * Estimate of how many units HAVE been processed
71
+	 *
72
+	 * @var int
73
+	 */
74
+	protected $_units_processed = 0;
75
+
76
+	/**
77
+	 * @var string
78
+	 */
79
+	protected $_status;
80
+
81
+	/**
82
+	 * The size of the total job in whatever units you want.
83
+	 * If you can't provide an estimate leave as 0.
84
+	 * Once _units_processed equals _job_size, we should be done
85
+	 *
86
+	 * @var int
87
+	 */
88
+	protected $_job_size = 0;
89
+
90
+
91
+	/**
92
+	 * @param string $job_id
93
+	 * @param string $classname
94
+	 * @param array  $request_data
95
+	 * @param array  $extra_data
96
+	 */
97
+	public function __construct($job_id, $classname, $request_data, $extra_data = array())
98
+	{
99
+		$this->set_job_id($job_id);
100
+		$this->set_classname($classname);
101
+		$this->set_request_data($request_data);
102
+		$this->set_extra_data($extra_data);
103
+		$this->set_status(JobParameters::status_continue);
104
+	}
105
+
106
+
107
+	/**
108
+	 * Returns the array of strings of valid stati
109
+	 *
110
+	 * @return array
111
+	 */
112
+	public static function valid_stati()
113
+	{
114
+		return array(
115
+			JobParameters::status_complete,
116
+			JobParameters::status_continue,
117
+			JobParameters::status_error,
118
+			JobParameters::status_cleaned_up,
119
+		);
120
+	}
121
+
122
+
123
+	/**
124
+	 * Saves this option to the database (wordpress options table)
125
+	 *
126
+	 * @param boolean $first
127
+	 * @return boolean success
128
+	 */
129
+	public function save($first = false)
130
+	{
131
+		$object_vars = get_object_vars($this);
132
+		if ($first) {
133
+			return add_option($this->option_name(), $object_vars, null, 'no');
134
+		} else {
135
+			return update_option($this->option_name(), $object_vars);
136
+		}
137
+	}
138
+
139
+
140
+	/**
141
+	 * Deletes the job from teh database, although this object is still usable
142
+	 * for the rest of the request
143
+	 *
144
+	 * @return boolean
145
+	 */
146
+	public function delete()
147
+	{
148
+		return delete_option($this->option_name());
149
+	}
150
+
151
+
152
+	/**
153
+	 * Loads the specified job from the database
154
+	 *
155
+	 * @param string $job_id
156
+	 * @return JobParameters
157
+	 * @throws BatchRequestException
158
+	 */
159
+	public static function load($job_id)
160
+	{
161
+		$job_parameter_vars = get_option(JobParameters::wp_option_prefix . $job_id);
162
+		if (
163
+			! is_array($job_parameter_vars) ||
164
+			! isset($job_parameter_vars['_classname']) ||
165
+			! isset($job_parameter_vars['_request_data'])
166
+		) {
167
+			throw new BatchRequestException(
168
+				sprintf(
169
+					esc_html__(
170
+						'Could not retrieve job %1$s from the Wordpress options table, and so the job could not continue. The wordpress option was %2$s',
171
+						'event_espresso'
172
+					),
173
+					$job_id,
174
+					get_option(JobParameters::wp_option_prefix . $job_id)
175
+				)
176
+			);
177
+		}
178
+		$job_parameters = new JobParameters(
179
+			$job_id,
180
+			$job_parameter_vars['_classname'],
181
+			$job_parameter_vars['_request_data']
182
+		);
183
+		foreach ($job_parameter_vars as $key => $value) {
184
+			$job_parameters->{$key} = $value;
185
+		}
186
+		return $job_parameters;
187
+	}
188
+
189
+
190
+	/**
191
+	 * Gets the job's unique string
192
+	 *
193
+	 * @return string
194
+	 */
195
+	public function job_id()
196
+	{
197
+		return $this->_job_id;
198
+	}
199
+
200
+
201
+	/**
202
+	 * Gets the classname that should run this job
203
+	 *
204
+	 * @return string
205
+	 */
206
+	public function classname()
207
+	{
208
+		return $this->_classname;
209
+	}
210
+
211
+
212
+	/**
213
+	 * Gets the original array of request data for this job
214
+	 *
215
+	 * @return array
216
+	 */
217
+	public function request_data()
218
+	{
219
+		return $this->_request_data;
220
+	}
221
+
222
+
223
+	/**
224
+	 * Gets a single item from the request data
225
+	 *
226
+	 * @param string       $key
227
+	 * @param string|array $default
228
+	 * @return string|array
229
+	 */
230
+	public function request_datum($key, $default = '')
231
+	{
232
+		if (isset($this->_request_data[ $key ])) {
233
+			return $this->_request_data[ $key ];
234
+		} else {
235
+			return $default;
236
+		}
237
+	}
238
+
239
+
240
+	/**
241
+	 * Gets a single item from the extra data
242
+	 *
243
+	 * @param string       $key
244
+	 * @param string|array $default
245
+	 * @return string|array
246
+	 */
247
+	public function extra_datum($key, $default = '')
248
+	{
249
+		if (isset($this->_extra_data[ $key ])) {
250
+			return $this->_extra_data[ $key ];
251
+		} else {
252
+			return $default;
253
+		}
254
+	}
255
+
256
+
257
+	/**
258
+	 * Adds an extra piece of extra data that we're going to want later during the job
259
+	 *
260
+	 * @param string                $key
261
+	 * @param string|int|array|null $value almost any extra data you want to store
262
+	 */
263
+	public function add_extra_data($key, $value)
264
+	{
265
+		$this->_extra_data[ $key ] = $value;
266
+	}
267
+
268
+
269
+	/**
270
+	 * Array of any extra data we want to store
271
+	 *
272
+	 * @return array
273
+	 */
274
+	public function extra_data()
275
+	{
276
+		return $this->_extra_data;
277
+	}
278
+
279
+
280
+	/**
281
+	 * Returns the job size, in whatever units you want
282
+	 *
283
+	 * @return int
284
+	 */
285
+	public function job_size()
286
+	{
287
+		return $this->_job_size;
288
+	}
289
+
290
+
291
+	/**
292
+	 * Sets the job size. You decide what units to use
293
+	 *
294
+	 * @param int $size
295
+	 */
296
+	public function set_job_size($size)
297
+	{
298
+		$this->_job_size = $size;
299
+	}
300
+
301
+
302
+	/**
303
+	 * The number of "units" processed, in the same units as the "job size"
304
+	 *
305
+	 * @return int
306
+	 */
307
+	public function units_processed()
308
+	{
309
+		return $this->_units_processed;
310
+	}
311
+
312
+
313
+	/**
314
+	 * Marks more units as processed
315
+	 *
316
+	 * @param int $newly_processed
317
+	 * @return int updated units processed
318
+	 */
319
+	public function mark_processed($newly_processed)
320
+	{
321
+		$this->_units_processed += $newly_processed;
322
+		return $this->_units_processed;
323
+	}
324
+
325
+
326
+	/**
327
+	 * Sets the total count of units processed. You might prefer to use mark_processed
328
+	 *
329
+	 * @param int $total_units_processed
330
+	 */
331
+	public function set_units_processed($total_units_processed)
332
+	{
333
+		$this->_units_processed = $total_units_processed;
334
+	}
335
+
336
+
337
+	/**
338
+	 * Sets the job's ID
339
+	 *
340
+	 * @param string $job_id
341
+	 */
342
+	public function set_job_id($job_id)
343
+	{
344
+		$this->_job_id = $job_id;
345
+	}
346
+
347
+
348
+	/**
349
+	 * sets the classname
350
+	 *
351
+	 * @param string $classname
352
+	 */
353
+	public function set_classname($classname)
354
+	{
355
+		$this->_classname = $classname;
356
+	}
357
+
358
+
359
+	/**
360
+	 * Sets the request data
361
+	 *
362
+	 * @param array $request_data
363
+	 */
364
+	public function set_request_data($request_data)
365
+	{
366
+		$this->_request_data = $request_data;
367
+	}
368
+
369
+
370
+	/**
371
+	 * Sets the array of extra data we want to store on this request
372
+	 *
373
+	 * @param array $extra_data
374
+	 */
375
+	public function set_extra_data($extra_data)
376
+	{
377
+		$this->_extra_data = $extra_data;
378
+	}
379
+
380
+
381
+	/**
382
+	 * Gets the name of the wordpress option that should store these job parameters
383
+	 *
384
+	 * @return string
385
+	 */
386
+	public function option_name()
387
+	{
388
+		return JobParameters::wp_option_prefix . $this->job_id();
389
+	}
390
+
391
+
392
+	/**
393
+	 * Gets the job\s current status. One of JobParameters::valid_stati();
394
+	 *
395
+	 * @return string
396
+	 */
397
+	public function status()
398
+	{
399
+		return $this->_status;
400
+	}
401
+
402
+
403
+	/**
404
+	 * @param string $status on eof JobParameters::valid_stati()
405
+	 */
406
+	public function set_status($status)
407
+	{
408
+		$this->_status = $status;
409
+	}
410 410
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Ticket_Price.model.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,11 +42,11 @@
 block discarded – undo
42 42
             'Price' => new EE_Belongs_To_Relation()
43 43
         );
44 44
         $this->_model_chain_to_wp_user = 'Ticket';
45
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
45
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
46 46
         // account for default tickets in the caps
47
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
48
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
49
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
47
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
48
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
49
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
50 50
         // follow the caps of the ticket
51 51
         $this->_caps_slug = 'tickets';
52 52
         parent::__construct($timezone);
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -11,43 +11,43 @@
 block discarded – undo
11 11
  */
12 12
 class EEM_Ticket_Price extends EEM_Base
13 13
 {
14
-    // private instance of the EEM_Ticket_Price object
15
-    protected static $_instance = null;
14
+	// private instance of the EEM_Ticket_Price object
15
+	protected static $_instance = null;
16 16
 
17
-    /**
18
-     *      private constructor to prevent direct creation
19
-     *      @Constructor
20
-     *      @access protected
21
-     *      @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
22
-     *      @return void
23
-     */
24
-    protected function __construct($timezone)
25
-    {
26
-        $this->singular_item = esc_html__('Ticket Price', 'event_espresso');
27
-        $this->plural_item = esc_html__('Ticket Prices', 'event_espresso');
17
+	/**
18
+	 *      private constructor to prevent direct creation
19
+	 *      @Constructor
20
+	 *      @access protected
21
+	 *      @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
22
+	 *      @return void
23
+	 */
24
+	protected function __construct($timezone)
25
+	{
26
+		$this->singular_item = esc_html__('Ticket Price', 'event_espresso');
27
+		$this->plural_item = esc_html__('Ticket Prices', 'event_espresso');
28 28
 
29
-        $this->_tables = array(
30
-            'Ticket_Price' => new EE_Primary_Table('esp_ticket_price', 'TKP_ID')
31
-        );
32
-        $this->_fields = array(
33
-            'Ticket_Price' => array(
34
-                'TKP_ID' => new EE_Primary_Key_Int_Field('TKP_ID', 'Ticket Price ID'),
35
-                'TKT_ID' => new EE_Foreign_Key_Int_Field('TKT_ID', 'Ticket Id', false, 0, 'Ticket'),
36
-                'PRC_ID' => new EE_Foreign_Key_Int_Field('PRC_ID', 'Price ID', false, 0, 'Price'),
37
-            )
38
-        );
39
-        $this->_model_relations = array(
40
-            'Ticket' => new EE_Belongs_To_Relation(),
41
-            'Price' => new EE_Belongs_To_Relation()
42
-        );
43
-        $this->_model_chain_to_wp_user = 'Ticket';
44
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
45
-        // account for default tickets in the caps
46
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
47
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
48
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
49
-        // follow the caps of the ticket
50
-        $this->_caps_slug = 'tickets';
51
-        parent::__construct($timezone);
52
-    }
29
+		$this->_tables = array(
30
+			'Ticket_Price' => new EE_Primary_Table('esp_ticket_price', 'TKP_ID')
31
+		);
32
+		$this->_fields = array(
33
+			'Ticket_Price' => array(
34
+				'TKP_ID' => new EE_Primary_Key_Int_Field('TKP_ID', 'Ticket Price ID'),
35
+				'TKT_ID' => new EE_Foreign_Key_Int_Field('TKT_ID', 'Ticket Id', false, 0, 'Ticket'),
36
+				'PRC_ID' => new EE_Foreign_Key_Int_Field('PRC_ID', 'Price ID', false, 0, 'Price'),
37
+			)
38
+		);
39
+		$this->_model_relations = array(
40
+			'Ticket' => new EE_Belongs_To_Relation(),
41
+			'Price' => new EE_Belongs_To_Relation()
42
+		);
43
+		$this->_model_chain_to_wp_user = 'Ticket';
44
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
45
+		// account for default tickets in the caps
46
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
47
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
48
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
49
+		// follow the caps of the ticket
50
+		$this->_caps_slug = 'tickets';
51
+		parent::__construct($timezone);
52
+	}
53 53
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Currency.model.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
             'Payment_Method' => new EE_HABTM_Relation('Currency_Payment_Method'),
35 35
         );
36 36
         // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
37
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
38 38
 
39 39
         parent::__construct($timezone);
40 40
     }
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
     public function get_all_active($query_params = array())
49 49
     {
50 50
         $query_params[0]['CUR_active'] = true;
51
-        if (! isset($query_params['order_by'])) {
52
-            $query_params['order_by'] = array('CUR_code' => 'ASC','CUR_single' => 'ASC');
51
+        if ( ! isset($query_params['order_by'])) {
52
+            $query_params['order_by'] = array('CUR_code' => 'ASC', 'CUR_single' => 'ASC');
53 53
         }
54 54
         return $this->get_all($query_params);
55 55
     }
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
72 72
             $currencies = $this->get_all_active();
73 73
         } else {
74
-            $currencies = $this->get_all_active(array(array('CUR_code' => array('IN',$currencies_supported))));
74
+            $currencies = $this->get_all_active(array(array('CUR_code' => array('IN', $currencies_supported))));
75 75
         }
76 76
         return $currencies;
77 77
     }
Please login to merge, or discard this patch.
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -11,68 +11,68 @@
 block discarded – undo
11 11
  */
12 12
 class EEM_Currency extends EEM_Base
13 13
 {
14
-        // private instance of the Attendee object
15
-    protected static $_instance = null;
14
+		// private instance of the Attendee object
15
+	protected static $_instance = null;
16 16
 
17
-    protected function __construct($timezone = null)
18
-    {
19
-        $this->singular_item = esc_html__('Currency', 'event_espresso');
20
-        $this->plural_item = esc_html__('Currencies', 'event_espresso');
21
-        $this->_tables = array(
22
-            'Currency' => new EE_Primary_Table('esp_currency', 'CUR_code')
23
-        );
24
-        $this->_fields = array(
25
-            'Currency' => array(
26
-                'CUR_code' => new EE_Primary_Key_String_Field('CUR_code', esc_html__('Currency Code', 'event_espresso')),
27
-                'CUR_single' => new EE_Plain_Text_Field('CUR_single', esc_html__('Currency Name Singular', 'event_espresso'), false),
28
-                'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', esc_html__('Currency Name Plural', 'event_espresso'), false),
29
-                'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', esc_html__('Currency Sign', 'event_espresso'), false),
30
-                'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', esc_html__('Currency Decimal Places', 'event_espresso'), false, 2),
31
-                'CUR_active' => new EE_Boolean_Field('CUR_active', esc_html__('Active?', 'event_espresso'), false, true),
32
-            ));
33
-        $this->_model_relations = array(
34
-            'Payment_Method' => new EE_HABTM_Relation('Currency_Payment_Method'),
35
-        );
36
-        // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
17
+	protected function __construct($timezone = null)
18
+	{
19
+		$this->singular_item = esc_html__('Currency', 'event_espresso');
20
+		$this->plural_item = esc_html__('Currencies', 'event_espresso');
21
+		$this->_tables = array(
22
+			'Currency' => new EE_Primary_Table('esp_currency', 'CUR_code')
23
+		);
24
+		$this->_fields = array(
25
+			'Currency' => array(
26
+				'CUR_code' => new EE_Primary_Key_String_Field('CUR_code', esc_html__('Currency Code', 'event_espresso')),
27
+				'CUR_single' => new EE_Plain_Text_Field('CUR_single', esc_html__('Currency Name Singular', 'event_espresso'), false),
28
+				'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', esc_html__('Currency Name Plural', 'event_espresso'), false),
29
+				'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', esc_html__('Currency Sign', 'event_espresso'), false),
30
+				'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', esc_html__('Currency Decimal Places', 'event_espresso'), false, 2),
31
+				'CUR_active' => new EE_Boolean_Field('CUR_active', esc_html__('Active?', 'event_espresso'), false, true),
32
+			));
33
+		$this->_model_relations = array(
34
+			'Payment_Method' => new EE_HABTM_Relation('Currency_Payment_Method'),
35
+		);
36
+		// this model is generally available for reading
37
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
38 38
 
39
-        parent::__construct($timezone);
40
-    }
39
+		parent::__construct($timezone);
40
+	}
41 41
 
42
-    /**
43
-     * Gets all thea ctive currencies, and orders them by their singular name, and then their code
44
-     * (may be overridden)
45
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
46
-     * @return EE_Currency[]
47
-     */
48
-    public function get_all_active($query_params = array())
49
-    {
50
-        $query_params[0]['CUR_active'] = true;
51
-        if (! isset($query_params['order_by'])) {
52
-            $query_params['order_by'] = array('CUR_code' => 'ASC','CUR_single' => 'ASC');
53
-        }
54
-        return $this->get_all($query_params);
55
-    }
56
-    /**
57
-     * Gets all the currencies which can be used by that payment method type
58
-     * @param EE_PMT_Base $payment_method_type
59
-     * @return EE_Currency[]
60
-     */
61
-    public function get_all_currencies_usable_by($payment_method_type)
62
-    {
63
-        if (
64
-            $payment_method_type instanceof EE_PMT_Base &&
65
-                $payment_method_type->get_gateway()
66
-        ) {
67
-            $currencies_supported = $payment_method_type->get_gateway()->currencies_supported();
68
-        } else {
69
-            $currencies_supported = EE_Gateway::all_currencies_supported;
70
-        }
71
-        if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
72
-            $currencies = $this->get_all_active();
73
-        } else {
74
-            $currencies = $this->get_all_active(array(array('CUR_code' => array('IN',$currencies_supported))));
75
-        }
76
-        return $currencies;
77
-    }
42
+	/**
43
+	 * Gets all thea ctive currencies, and orders them by their singular name, and then their code
44
+	 * (may be overridden)
45
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
46
+	 * @return EE_Currency[]
47
+	 */
48
+	public function get_all_active($query_params = array())
49
+	{
50
+		$query_params[0]['CUR_active'] = true;
51
+		if (! isset($query_params['order_by'])) {
52
+			$query_params['order_by'] = array('CUR_code' => 'ASC','CUR_single' => 'ASC');
53
+		}
54
+		return $this->get_all($query_params);
55
+	}
56
+	/**
57
+	 * Gets all the currencies which can be used by that payment method type
58
+	 * @param EE_PMT_Base $payment_method_type
59
+	 * @return EE_Currency[]
60
+	 */
61
+	public function get_all_currencies_usable_by($payment_method_type)
62
+	{
63
+		if (
64
+			$payment_method_type instanceof EE_PMT_Base &&
65
+				$payment_method_type->get_gateway()
66
+		) {
67
+			$currencies_supported = $payment_method_type->get_gateway()->currencies_supported();
68
+		} else {
69
+			$currencies_supported = EE_Gateway::all_currencies_supported;
70
+		}
71
+		if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
72
+			$currencies = $this->get_all_active();
73
+		} else {
74
+			$currencies = $this->get_all_active(array(array('CUR_code' => array('IN',$currencies_supported))));
75
+		}
76
+		return $currencies;
77
+	}
78 78
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Currency_Payment_Method.model.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
             'Payment_Method' => new EE_Belongs_To_Relation()
35 35
         );
36 36
         // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
37
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
38 38
         $this->_caps_slug = 'payment_methods';
39 39
         parent::__construct($timezone);
40 40
     }
Please login to merge, or discard this patch.
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,31 +11,31 @@
 block discarded – undo
11 11
  */
12 12
 class EEM_Currency_Payment_Method extends EEM_Base
13 13
 {
14
-    // private instance of the Attendee object
15
-    protected static $_instance = null;
14
+	// private instance of the Attendee object
15
+	protected static $_instance = null;
16 16
 
17 17
 
18
-    protected function __construct($timezone = null)
19
-    {
20
-        $this->singular_item = esc_html__('Currency Usable by Payment Method', 'event_espresso');
21
-        $this->plural_item = esc_html__('Currencies Usable by Payment Methods', 'event_espresso');
22
-        $this->_tables = array(
23
-            'Currency_Payment_Method' => new EE_Primary_Table('esp_currency_payment_method', 'CPM_ID')
24
-        );
25
-        $this->_fields = array(
26
-            'Currency_Payment_Method' => array(
27
-                'CPM_ID' => new EE_Primary_Key_Int_Field('CPM_ID', esc_html__('Currency to Payment Method LInk ID', 'event_espresso')),
28
-                'CUR_code' => new EE_Foreign_Key_String_Field('CUR_code', esc_html__('Currency Code', 'event_espresso'), false, '', 'Currency'),
29
-                'PMD_ID' => new EE_Foreign_Key_Int_Field('PMD_ID', esc_html__('Paymetn Method ID', 'event_espresso'), false, 0, 'Payment_Method')
30
-            )
31
-        );
32
-        $this->_model_relations = array(
33
-            'Currency' => new EE_Belongs_To_Relation(),
34
-            'Payment_Method' => new EE_Belongs_To_Relation()
35
-        );
36
-        // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
38
-        $this->_caps_slug = 'payment_methods';
39
-        parent::__construct($timezone);
40
-    }
18
+	protected function __construct($timezone = null)
19
+	{
20
+		$this->singular_item = esc_html__('Currency Usable by Payment Method', 'event_espresso');
21
+		$this->plural_item = esc_html__('Currencies Usable by Payment Methods', 'event_espresso');
22
+		$this->_tables = array(
23
+			'Currency_Payment_Method' => new EE_Primary_Table('esp_currency_payment_method', 'CPM_ID')
24
+		);
25
+		$this->_fields = array(
26
+			'Currency_Payment_Method' => array(
27
+				'CPM_ID' => new EE_Primary_Key_Int_Field('CPM_ID', esc_html__('Currency to Payment Method LInk ID', 'event_espresso')),
28
+				'CUR_code' => new EE_Foreign_Key_String_Field('CUR_code', esc_html__('Currency Code', 'event_espresso'), false, '', 'Currency'),
29
+				'PMD_ID' => new EE_Foreign_Key_Int_Field('PMD_ID', esc_html__('Paymetn Method ID', 'event_espresso'), false, 0, 'Payment_Method')
30
+			)
31
+		);
32
+		$this->_model_relations = array(
33
+			'Currency' => new EE_Belongs_To_Relation(),
34
+			'Payment_Method' => new EE_Belongs_To_Relation()
35
+		);
36
+		// this model is generally available for reading
37
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
38
+		$this->_caps_slug = 'payment_methods';
39
+		parent::__construct($timezone);
40
+	}
41 41
 }
Please login to merge, or discard this patch.
core/db_models/helpers/EE_Model_Parser.php 2 patches
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -9,153 +9,153 @@
 block discarded – undo
9 9
  */
10 10
 class EE_Model_Parser
11 11
 {
12
-    const table_alias_model_relation_chain_separator = '__';
13
-    const table_alias_model_relation_chain_prefix_end = '___';
14
-    /**
15
-     * Adds a period onto the front and end of the string. This often helps in searching.
16
-     * For example, if we want to find the model name "Event", it can be tricky when the following are possible
17
-     * "","Event.EVT_ID","Event","Event_Venue.Venue.VNU_ID",etc. It's easier to look for ".Event." in
18
-     * "..",".Event.EVT_ID.", ".Event.", and ".Event_Venue.Venue.VNU_ID", especially when the last example should NOT
19
-     * be found because the "Event" model isn't mentioned- it's just a string that has a model name that coincidentally
20
-     * has it as a substring
21
-     * @param string $string_to_pad
22
-     * @return string
23
-     */
24
-    public static function pad_with_periods($string_to_pad)
25
-    {
26
-        return "." . $string_to_pad . ".";
27
-    }
28
-    /**
29
-     * Basically undoes _pad_with_periods
30
-     * @param string $string_to_trim
31
-     * @return string
32
-     */
33
-    public static function trim_periods($string_to_trim)
34
-    {
35
-        return trim($string_to_trim, '.');
36
-    }
12
+	const table_alias_model_relation_chain_separator = '__';
13
+	const table_alias_model_relation_chain_prefix_end = '___';
14
+	/**
15
+	 * Adds a period onto the front and end of the string. This often helps in searching.
16
+	 * For example, if we want to find the model name "Event", it can be tricky when the following are possible
17
+	 * "","Event.EVT_ID","Event","Event_Venue.Venue.VNU_ID",etc. It's easier to look for ".Event." in
18
+	 * "..",".Event.EVT_ID.", ".Event.", and ".Event_Venue.Venue.VNU_ID", especially when the last example should NOT
19
+	 * be found because the "Event" model isn't mentioned- it's just a string that has a model name that coincidentally
20
+	 * has it as a substring
21
+	 * @param string $string_to_pad
22
+	 * @return string
23
+	 */
24
+	public static function pad_with_periods($string_to_pad)
25
+	{
26
+		return "." . $string_to_pad . ".";
27
+	}
28
+	/**
29
+	 * Basically undoes _pad_with_periods
30
+	 * @param string $string_to_trim
31
+	 * @return string
32
+	 */
33
+	public static function trim_periods($string_to_trim)
34
+	{
35
+		return trim($string_to_trim, '.');
36
+	}
37 37
 
38 38
 
39 39
 
40
-    /**
41
-     * Gets the calculated table's alias
42
-     * @param string $model_relation_chain or query param
43
-     * @param        $this_model_name
44
-     * @return string which can be added onto table aliases to make them unique
45
-     */
46
-    public static function extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this_model_name)
47
-    {
48
-        // eg $model_relation_chain = 'Venue.Event_Venue.Event.Registration", and $this_model_name = 'Event'
49
-        $model_relation_chain = self::pad_with_periods($model_relation_chain);
50
-        $this_model_name = self::pad_with_periods($this_model_name);
51
-        // eg '.Venue.Event_Venue.Event.Registration." and '.Event.'
52
-        // remove this model name and everything afterwards
53
-        $pos_of_model_name = strpos($model_relation_chain, $this_model_name);
54
-        $model_relation_chain = substr($model_relation_chain, 0, $pos_of_model_name);
55
-        // eg '.Venue.Event_Venue.'
56
-        // trim periods
57
-        $model_relation_chain = self::trim_periods($model_relation_chain);
58
-        // eg 'Venue.Event_Venue'
59
-        // replace periods with double-underscores
60
-        $model_relation_chain = str_replace(".", self::table_alias_model_relation_chain_separator, $model_relation_chain);
61
-        // eg 'Venue__Event_Venue'
62
-        if ($model_relation_chain != '') {
63
-            $model_relation_chain = $model_relation_chain . self::table_alias_model_relation_chain_prefix_end;
64
-        }
65
-        // eg 'Venue_Event_Venue___'
66
-        return $model_relation_chain;
67
-    }
68
-    /**
69
-     * Gets the table's alias (without prefix or anything)
70
-     * @param string $table_alias_with_model_relation_chain_prefix which CAN have a table alias model relation chain prefix (or not)
71
-     * @return string
72
-     */
73
-    public static function remove_table_alias_model_relation_chain_prefix($table_alias_with_model_relation_chain_prefix)
74
-    {
75
-        // does this actually have a table alias model relation chain prefix?
76
-        $pos = strpos($table_alias_with_model_relation_chain_prefix, self::table_alias_model_relation_chain_prefix_end);
77
-        if ($pos !== false) {
78
-            // yes
79
-            // find that triple underscore and remove it and everything before it
80
-            $table_alias = substr($table_alias_with_model_relation_chain_prefix, $pos + strlen(self::table_alias_model_relation_chain_prefix_end));
81
-        } else {
82
-            $table_alias = $table_alias_with_model_relation_chain_prefix;
83
-        }
84
-        return $table_alias;
85
-    }
86
-    /**
87
-     * Gets the table alias model relation chain prefix from the table alias already containing it
88
-     * @param string $table_alias_with_model_relation_chain_prefix
89
-     * @return string
90
-     */
91
-    public static function get_prefix_from_table_alias_with_model_relation_chain_prefix($table_alias_with_model_relation_chain_prefix)
92
-    {
93
-        // does this actually have a table alias model relation chain prefix?
94
-        $pos = strpos($table_alias_with_model_relation_chain_prefix, self::table_alias_model_relation_chain_prefix_end);
95
-        if ($pos !== false) {
96
-            // yes
97
-            // find that triple underscore and remove it and everything before it
98
-            $prefix = substr($table_alias_with_model_relation_chain_prefix, 0, $pos + strlen(self::table_alias_model_relation_chain_prefix_end));
99
-        } else {
100
-            $prefix = '';
101
-        }
102
-        return $prefix;
103
-    }
40
+	/**
41
+	 * Gets the calculated table's alias
42
+	 * @param string $model_relation_chain or query param
43
+	 * @param        $this_model_name
44
+	 * @return string which can be added onto table aliases to make them unique
45
+	 */
46
+	public static function extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this_model_name)
47
+	{
48
+		// eg $model_relation_chain = 'Venue.Event_Venue.Event.Registration", and $this_model_name = 'Event'
49
+		$model_relation_chain = self::pad_with_periods($model_relation_chain);
50
+		$this_model_name = self::pad_with_periods($this_model_name);
51
+		// eg '.Venue.Event_Venue.Event.Registration." and '.Event.'
52
+		// remove this model name and everything afterwards
53
+		$pos_of_model_name = strpos($model_relation_chain, $this_model_name);
54
+		$model_relation_chain = substr($model_relation_chain, 0, $pos_of_model_name);
55
+		// eg '.Venue.Event_Venue.'
56
+		// trim periods
57
+		$model_relation_chain = self::trim_periods($model_relation_chain);
58
+		// eg 'Venue.Event_Venue'
59
+		// replace periods with double-underscores
60
+		$model_relation_chain = str_replace(".", self::table_alias_model_relation_chain_separator, $model_relation_chain);
61
+		// eg 'Venue__Event_Venue'
62
+		if ($model_relation_chain != '') {
63
+			$model_relation_chain = $model_relation_chain . self::table_alias_model_relation_chain_prefix_end;
64
+		}
65
+		// eg 'Venue_Event_Venue___'
66
+		return $model_relation_chain;
67
+	}
68
+	/**
69
+	 * Gets the table's alias (without prefix or anything)
70
+	 * @param string $table_alias_with_model_relation_chain_prefix which CAN have a table alias model relation chain prefix (or not)
71
+	 * @return string
72
+	 */
73
+	public static function remove_table_alias_model_relation_chain_prefix($table_alias_with_model_relation_chain_prefix)
74
+	{
75
+		// does this actually have a table alias model relation chain prefix?
76
+		$pos = strpos($table_alias_with_model_relation_chain_prefix, self::table_alias_model_relation_chain_prefix_end);
77
+		if ($pos !== false) {
78
+			// yes
79
+			// find that triple underscore and remove it and everything before it
80
+			$table_alias = substr($table_alias_with_model_relation_chain_prefix, $pos + strlen(self::table_alias_model_relation_chain_prefix_end));
81
+		} else {
82
+			$table_alias = $table_alias_with_model_relation_chain_prefix;
83
+		}
84
+		return $table_alias;
85
+	}
86
+	/**
87
+	 * Gets the table alias model relation chain prefix from the table alias already containing it
88
+	 * @param string $table_alias_with_model_relation_chain_prefix
89
+	 * @return string
90
+	 */
91
+	public static function get_prefix_from_table_alias_with_model_relation_chain_prefix($table_alias_with_model_relation_chain_prefix)
92
+	{
93
+		// does this actually have a table alias model relation chain prefix?
94
+		$pos = strpos($table_alias_with_model_relation_chain_prefix, self::table_alias_model_relation_chain_prefix_end);
95
+		if ($pos !== false) {
96
+			// yes
97
+			// find that triple underscore and remove it and everything before it
98
+			$prefix = substr($table_alias_with_model_relation_chain_prefix, 0, $pos + strlen(self::table_alias_model_relation_chain_prefix_end));
99
+		} else {
100
+			$prefix = '';
101
+		}
102
+		return $prefix;
103
+	}
104 104
 
105
-    /**
106
-     * Gets the table alias model relation chain prefix (ie, what can be prepended onto
107
-     * EE_Model_Field::get_qualified_column() to get the proper column name for that field
108
-     * in a specific query) from teh query param (eg 'Registration.Event.EVT_ID').
109
-     *
110
-     * @param string $model_name of the model on which the related query param was found to be belong
111
-     * @param string $original_query_param
112
-     * @return string
113
-     */
114
-    public static function extract_table_alias_model_relation_chain_from_query_param($model_name, $original_query_param)
115
-    {
116
-        $relation_chain = self::extract_model_relation_chain($model_name, $original_query_param);
117
-        $table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($relation_chain, $model_name);
118
-        return $table_alias_with_model_relation_chain_prefix;
119
-    }
120
-    /**
121
-     * Gets the model relation chain to $model_name from the $original_query_param.
122
-     * Eg, if $model_name were 'Payment', and $original_query_param were 'Registration.Transaction.Payment.PAY_ID',
123
-     * this would return 'Registration.Transaction.Payment'. Also if the query param were 'Registration.Transaction.Payment'
124
-     * and $model_name were 'Payment', it should return 'Registration.Transaction.Payment'
125
-     * @param string $model_name
126
-     * @param string $original_query_param
127
-     * @return string
128
-     */
129
-    public static function extract_model_relation_chain($model_name, $original_query_param)
130
-    {
131
-        // prefix and postfix both with a period, as this facilitates searching
132
-        $model_name = EE_Model_Parser::pad_with_periods($model_name);
133
-        $original_query_param = EE_Model_Parser::pad_with_periods($original_query_param);
134
-        $pos_of_model_string = strpos($original_query_param, $model_name);
135
-        // eg, if we're looking for the model relation chain from Event to Payment, the original query param is probably something like
136
-        // "Registration.Transaction.Payment.PAY_ID", $pos_of_model_string points to the 'P' or Payment. We want the string
137
-        // "Registration.Transaction.Payment"
138
-        $model_relation_chain = substr($original_query_param, 0, $pos_of_model_string + strlen($model_name));
139
-        return EE_Model_Parser::trim_periods($model_relation_chain);
140
-    }
105
+	/**
106
+	 * Gets the table alias model relation chain prefix (ie, what can be prepended onto
107
+	 * EE_Model_Field::get_qualified_column() to get the proper column name for that field
108
+	 * in a specific query) from teh query param (eg 'Registration.Event.EVT_ID').
109
+	 *
110
+	 * @param string $model_name of the model on which the related query param was found to be belong
111
+	 * @param string $original_query_param
112
+	 * @return string
113
+	 */
114
+	public static function extract_table_alias_model_relation_chain_from_query_param($model_name, $original_query_param)
115
+	{
116
+		$relation_chain = self::extract_model_relation_chain($model_name, $original_query_param);
117
+		$table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($relation_chain, $model_name);
118
+		return $table_alias_with_model_relation_chain_prefix;
119
+	}
120
+	/**
121
+	 * Gets the model relation chain to $model_name from the $original_query_param.
122
+	 * Eg, if $model_name were 'Payment', and $original_query_param were 'Registration.Transaction.Payment.PAY_ID',
123
+	 * this would return 'Registration.Transaction.Payment'. Also if the query param were 'Registration.Transaction.Payment'
124
+	 * and $model_name were 'Payment', it should return 'Registration.Transaction.Payment'
125
+	 * @param string $model_name
126
+	 * @param string $original_query_param
127
+	 * @return string
128
+	 */
129
+	public static function extract_model_relation_chain($model_name, $original_query_param)
130
+	{
131
+		// prefix and postfix both with a period, as this facilitates searching
132
+		$model_name = EE_Model_Parser::pad_with_periods($model_name);
133
+		$original_query_param = EE_Model_Parser::pad_with_periods($original_query_param);
134
+		$pos_of_model_string = strpos($original_query_param, $model_name);
135
+		// eg, if we're looking for the model relation chain from Event to Payment, the original query param is probably something like
136
+		// "Registration.Transaction.Payment.PAY_ID", $pos_of_model_string points to the 'P' or Payment. We want the string
137
+		// "Registration.Transaction.Payment"
138
+		$model_relation_chain = substr($original_query_param, 0, $pos_of_model_string + strlen($model_name));
139
+		return EE_Model_Parser::trim_periods($model_relation_chain);
140
+	}
141 141
 
142
-    /**
143
-     * Replaces the specified model in teh model relation chain with teh join model.
144
-     * Eg EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain(
145
-     * "Ticket", "Datetime_Ticket", "Datetime.Ticket" ) will return
146
-     * "Datetime.Datetime_Ticket" which can be used to find the table alias model relation chain prefix
147
-     * using EE_Model_Parser::extract_table_alias_model_relation_chain_prefix
148
-     * @param string $model_name
149
-     * @param string $join_model_name
150
-     * @param string $model_relation_chain
151
-     * @return string
152
-     */
153
-    public static function replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_name, $model_relation_chain)
154
-    {
155
-        $model_name = EE_Model_Parser::pad_with_periods($model_name);
156
-        $join_model_name = EE_Model_Parser::pad_with_periods($join_model_name);
157
-        $model_relation_chain = EE_Model_Parser::pad_with_periods($model_relation_chain);
158
-        $replaced_with_periods = str_replace($model_name, $join_model_name, $model_relation_chain);
159
-        return EE_Model_Parser::trim_periods($replaced_with_periods);
160
-    }
142
+	/**
143
+	 * Replaces the specified model in teh model relation chain with teh join model.
144
+	 * Eg EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain(
145
+	 * "Ticket", "Datetime_Ticket", "Datetime.Ticket" ) will return
146
+	 * "Datetime.Datetime_Ticket" which can be used to find the table alias model relation chain prefix
147
+	 * using EE_Model_Parser::extract_table_alias_model_relation_chain_prefix
148
+	 * @param string $model_name
149
+	 * @param string $join_model_name
150
+	 * @param string $model_relation_chain
151
+	 * @return string
152
+	 */
153
+	public static function replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_name, $model_relation_chain)
154
+	{
155
+		$model_name = EE_Model_Parser::pad_with_periods($model_name);
156
+		$join_model_name = EE_Model_Parser::pad_with_periods($join_model_name);
157
+		$model_relation_chain = EE_Model_Parser::pad_with_periods($model_relation_chain);
158
+		$replaced_with_periods = str_replace($model_name, $join_model_name, $model_relation_chain);
159
+		return EE_Model_Parser::trim_periods($replaced_with_periods);
160
+	}
161 161
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public static function pad_with_periods($string_to_pad)
25 25
     {
26
-        return "." . $string_to_pad . ".";
26
+        return ".".$string_to_pad.".";
27 27
     }
28 28
     /**
29 29
      * Basically undoes _pad_with_periods
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $model_relation_chain = str_replace(".", self::table_alias_model_relation_chain_separator, $model_relation_chain);
61 61
         // eg 'Venue__Event_Venue'
62 62
         if ($model_relation_chain != '') {
63
-            $model_relation_chain = $model_relation_chain . self::table_alias_model_relation_chain_prefix_end;
63
+            $model_relation_chain = $model_relation_chain.self::table_alias_model_relation_chain_prefix_end;
64 64
         }
65 65
         // eg 'Venue_Event_Venue___'
66 66
         return $model_relation_chain;
Please login to merge, or discard this patch.
core/db_models/helpers/EE_Secondary_Table.php 2 patches
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -8,118 +8,118 @@
 block discarded – undo
8 8
  */
9 9
 class EE_Secondary_Table extends EE_Table_Base
10 10
 {
11
-    protected $_extra_join_conditions;
11
+	protected $_extra_join_conditions;
12 12
 
13
-    /**
14
-     *
15
-     * @global type $wpdb
16
-     * @param string $table_name with or without wpdb prefix
17
-     * @param string $pk_column name of primary key column on THIS table
18
-     * @param string $fk_column the name of the COLUMN that is a foreign key to the primary table's primary key
19
-     * @param string $extra_join_conditions string for additional SQL to add onto the join statement's ON condition
20
-     * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite install,
21
-     *                  or whether each site on a multisite install has a copy of this table
22
-     */
23
-    public function __construct($table_name, $pk_column, $fk_column = null, $extra_join_conditions = null, $global = false)
24
-    {
25
-        $this->_fk_on_table = $fk_column;
26
-        $this->_extra_join_conditions = $extra_join_conditions;
27
-        parent::__construct($table_name, $pk_column, $global);
28
-    }
29
-    public function get_fk_on_table()
30
-    {
31
-        return $this->_fk_on_table;
32
-    }
33
-    public function _construct_finalize_set_table_to_join_with(EE_Table_Base $table)
34
-    {
35
-        $this->_table_to_join_with = $table;
36
-    }
37
-    /**
38
-     *
39
-     * @return string of sql like "Event.post_type = 'event'", which gets added to
40
-     * the end of the join statement with the primary table
41
-     */
42
-    public function get_extra_join_conditions()
43
-    {
44
-        return $this->_extra_join_conditions;
45
-    }
46
-    /**
47
-     *
48
-     * @return EE_Primary_Table
49
-     */
50
-    public function get_table_to_join_with()
51
-    {
52
-        return $this->_table_to_join_with;
53
-    }
54
-    /**
55
-     * creates join statement FROM primary table
56
-     * gets SQL like "LEFT JOIN table_name AS table_alias ON other_table_alias.pk = table_alias.fk
57
-     *
58
-     * @param string $table allows us to set special conditions on the $table_name portion of the join query (i.e. doing a subquery)
59
-     * @return string of SQL
60
-     */
61
-    public function get_join_sql($primary_table_alias_with_model_chain_prefix)
62
-    {
13
+	/**
14
+	 *
15
+	 * @global type $wpdb
16
+	 * @param string $table_name with or without wpdb prefix
17
+	 * @param string $pk_column name of primary key column on THIS table
18
+	 * @param string $fk_column the name of the COLUMN that is a foreign key to the primary table's primary key
19
+	 * @param string $extra_join_conditions string for additional SQL to add onto the join statement's ON condition
20
+	 * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite install,
21
+	 *                  or whether each site on a multisite install has a copy of this table
22
+	 */
23
+	public function __construct($table_name, $pk_column, $fk_column = null, $extra_join_conditions = null, $global = false)
24
+	{
25
+		$this->_fk_on_table = $fk_column;
26
+		$this->_extra_join_conditions = $extra_join_conditions;
27
+		parent::__construct($table_name, $pk_column, $global);
28
+	}
29
+	public function get_fk_on_table()
30
+	{
31
+		return $this->_fk_on_table;
32
+	}
33
+	public function _construct_finalize_set_table_to_join_with(EE_Table_Base $table)
34
+	{
35
+		$this->_table_to_join_with = $table;
36
+	}
37
+	/**
38
+	 *
39
+	 * @return string of sql like "Event.post_type = 'event'", which gets added to
40
+	 * the end of the join statement with the primary table
41
+	 */
42
+	public function get_extra_join_conditions()
43
+	{
44
+		return $this->_extra_join_conditions;
45
+	}
46
+	/**
47
+	 *
48
+	 * @return EE_Primary_Table
49
+	 */
50
+	public function get_table_to_join_with()
51
+	{
52
+		return $this->_table_to_join_with;
53
+	}
54
+	/**
55
+	 * creates join statement FROM primary table
56
+	 * gets SQL like "LEFT JOIN table_name AS table_alias ON other_table_alias.pk = table_alias.fk
57
+	 *
58
+	 * @param string $table allows us to set special conditions on the $table_name portion of the join query (i.e. doing a subquery)
59
+	 * @return string of SQL
60
+	 */
61
+	public function get_join_sql($primary_table_alias_with_model_chain_prefix)
62
+	{
63 63
 
64
-        $table_name = $this->get_table_name();
65
-        $secondary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($primary_table_alias_with_model_chain_prefix) . $this->get_table_alias();
66
-        $other_table_pk = $this->get_table_to_join_with()->get_pk_column();
67
-        $fk = $this->get_fk_on_table();
68
-        $join_sql = " LEFT JOIN $table_name AS $secondary_table_alias ON $primary_table_alias_with_model_chain_prefix.$other_table_pk = $secondary_table_alias.$fk ";
69
-        if ($this->get_extra_join_conditions()) {
70
-            $join_sql .= "AND " . $this->get_extra_join_conditions();
71
-        }
72
-        return $join_sql;
73
-    }
64
+		$table_name = $this->get_table_name();
65
+		$secondary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($primary_table_alias_with_model_chain_prefix) . $this->get_table_alias();
66
+		$other_table_pk = $this->get_table_to_join_with()->get_pk_column();
67
+		$fk = $this->get_fk_on_table();
68
+		$join_sql = " LEFT JOIN $table_name AS $secondary_table_alias ON $primary_table_alias_with_model_chain_prefix.$other_table_pk = $secondary_table_alias.$fk ";
69
+		if ($this->get_extra_join_conditions()) {
70
+			$join_sql .= "AND " . $this->get_extra_join_conditions();
71
+		}
72
+		return $join_sql;
73
+	}
74 74
 
75 75
 
76
-    /**
77
-     * Produces join SQL like get_join_sql, except instead of joining the primary table to the
78
-     * secondary table, does the inverse: joins the secondary table to the primary one. (Eg, isntead of
79
-     * " LEFT JOIN secondary_table_table AS Secondary ON ..." like get_join_sql, this function returns
80
-     * " LEFT JOIN primary_table AS Primary ON ...".
81
-     * This is useful if the secondary table is already included in the SQL, but the primary table is not yet.
82
-     * @return string
83
-     */
84
-    public function get_inverse_join_sql($secondary_table_alias_with_model_chain_prefix)
85
-    {
86
-        $primary_table_name = $this->get_table_to_join_with()->get_table_name();
87
-        $primary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($secondary_table_alias_with_model_chain_prefix) . $this->get_table_to_join_with()->get_table_alias();
88
-        $primary_table_pk = $this->get_table_to_join_with()->get_pk_column();// $this->get_pk_column();
89
-        $fk = $this->get_fk_on_table();
90
-        $join_sql = " LEFT JOIN $primary_table_name AS $primary_table_alias ON $primary_table_alias.$primary_table_pk = $secondary_table_alias_with_model_chain_prefix.$fk ";
91
-        if ($this->get_extra_join_conditions()) {
92
-            $join_sql .= "AND " . $this->get_extra_join_conditions();
93
-        }
94
-        return $join_sql;
95
-    }
76
+	/**
77
+	 * Produces join SQL like get_join_sql, except instead of joining the primary table to the
78
+	 * secondary table, does the inverse: joins the secondary table to the primary one. (Eg, isntead of
79
+	 * " LEFT JOIN secondary_table_table AS Secondary ON ..." like get_join_sql, this function returns
80
+	 * " LEFT JOIN primary_table AS Primary ON ...".
81
+	 * This is useful if the secondary table is already included in the SQL, but the primary table is not yet.
82
+	 * @return string
83
+	 */
84
+	public function get_inverse_join_sql($secondary_table_alias_with_model_chain_prefix)
85
+	{
86
+		$primary_table_name = $this->get_table_to_join_with()->get_table_name();
87
+		$primary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($secondary_table_alias_with_model_chain_prefix) . $this->get_table_to_join_with()->get_table_alias();
88
+		$primary_table_pk = $this->get_table_to_join_with()->get_pk_column();// $this->get_pk_column();
89
+		$fk = $this->get_fk_on_table();
90
+		$join_sql = " LEFT JOIN $primary_table_name AS $primary_table_alias ON $primary_table_alias.$primary_table_pk = $secondary_table_alias_with_model_chain_prefix.$fk ";
91
+		if ($this->get_extra_join_conditions()) {
92
+			$join_sql .= "AND " . $this->get_extra_join_conditions();
93
+		}
94
+		return $join_sql;
95
+	}
96 96
 
97
-    /**
98
-     * This prepares the join on the other table using a select with a internal limit.
99
-     * @param  mixed (array|string) $limit limit
100
-     * @return string                       SQL to return
101
-     */
102
-    public function get_select_join_limit_join($limit)
103
-    {
104
-        // first get the select
105
-        $select = $this->get_select_join_limit($limit);
106
-        $join_sql = $this->get_join_sql($select);
107
-        return $join_sql;
108
-    }
97
+	/**
98
+	 * This prepares the join on the other table using a select with a internal limit.
99
+	 * @param  mixed (array|string) $limit limit
100
+	 * @return string                       SQL to return
101
+	 */
102
+	public function get_select_join_limit_join($limit)
103
+	{
104
+		// first get the select
105
+		$select = $this->get_select_join_limit($limit);
106
+		$join_sql = $this->get_join_sql($select);
107
+		return $join_sql;
108
+	}
109 109
 
110 110
 
111 111
 
112
-    public function get_fully_qualified_fk_column()
113
-    {
114
-        $table_alias = $this->get_table_alias();
115
-        $fk = $this->get_fk_on_table();
116
-        return $table_alias . '.' . $fk;
117
-    }
112
+	public function get_fully_qualified_fk_column()
113
+	{
114
+		$table_alias = $this->get_table_alias();
115
+		$fk = $this->get_fk_on_table();
116
+		return $table_alias . '.' . $fk;
117
+	}
118 118
 
119
-    public function get_fully_qualified_pk_on_fk_table()
120
-    {
121
-        $table_alias = $this->get_table_to_join_with()->get_table_alias();
122
-        $pk = $this->get_table_to_join_with()->get_pk_column();
123
-        return $table_alias . '.' . $pk;
124
-    }
119
+	public function get_fully_qualified_pk_on_fk_table()
120
+	{
121
+		$table_alias = $this->get_table_to_join_with()->get_table_alias();
122
+		$pk = $this->get_table_to_join_with()->get_pk_column();
123
+		return $table_alias . '.' . $pk;
124
+	}
125 125
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -62,12 +62,12 @@  discard block
 block discarded – undo
62 62
     {
63 63
 
64 64
         $table_name = $this->get_table_name();
65
-        $secondary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($primary_table_alias_with_model_chain_prefix) . $this->get_table_alias();
65
+        $secondary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($primary_table_alias_with_model_chain_prefix).$this->get_table_alias();
66 66
         $other_table_pk = $this->get_table_to_join_with()->get_pk_column();
67 67
         $fk = $this->get_fk_on_table();
68 68
         $join_sql = " LEFT JOIN $table_name AS $secondary_table_alias ON $primary_table_alias_with_model_chain_prefix.$other_table_pk = $secondary_table_alias.$fk ";
69 69
         if ($this->get_extra_join_conditions()) {
70
-            $join_sql .= "AND " . $this->get_extra_join_conditions();
70
+            $join_sql .= "AND ".$this->get_extra_join_conditions();
71 71
         }
72 72
         return $join_sql;
73 73
     }
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
     public function get_inverse_join_sql($secondary_table_alias_with_model_chain_prefix)
85 85
     {
86 86
         $primary_table_name = $this->get_table_to_join_with()->get_table_name();
87
-        $primary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($secondary_table_alias_with_model_chain_prefix) . $this->get_table_to_join_with()->get_table_alias();
88
-        $primary_table_pk = $this->get_table_to_join_with()->get_pk_column();// $this->get_pk_column();
87
+        $primary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($secondary_table_alias_with_model_chain_prefix).$this->get_table_to_join_with()->get_table_alias();
88
+        $primary_table_pk = $this->get_table_to_join_with()->get_pk_column(); // $this->get_pk_column();
89 89
         $fk = $this->get_fk_on_table();
90 90
         $join_sql = " LEFT JOIN $primary_table_name AS $primary_table_alias ON $primary_table_alias.$primary_table_pk = $secondary_table_alias_with_model_chain_prefix.$fk ";
91 91
         if ($this->get_extra_join_conditions()) {
92
-            $join_sql .= "AND " . $this->get_extra_join_conditions();
92
+            $join_sql .= "AND ".$this->get_extra_join_conditions();
93 93
         }
94 94
         return $join_sql;
95 95
     }
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
     {
114 114
         $table_alias = $this->get_table_alias();
115 115
         $fk = $this->get_fk_on_table();
116
-        return $table_alias . '.' . $fk;
116
+        return $table_alias.'.'.$fk;
117 117
     }
118 118
 
119 119
     public function get_fully_qualified_pk_on_fk_table()
120 120
     {
121 121
         $table_alias = $this->get_table_to_join_with()->get_table_alias();
122 122
         $pk = $this->get_table_to_join_with()->get_pk_column();
123
-        return $table_alias . '.' . $pk;
123
+        return $table_alias.'.'.$pk;
124 124
     }
125 125
 }
Please login to merge, or discard this patch.
core/db_models/helpers/EE_Index.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -6,45 +6,45 @@
 block discarded – undo
6 6
  */
7 7
 class EE_Index
8 8
 {
9
-    protected $_name;
10
-    protected $_field_names;
11
-    protected $_model_name;
12
-    public function __construct($fields)
13
-    {
14
-        $this->_field_names = $fields;
15
-    }
16
-    public function _construct_finalize($name, $model_name)
17
-    {
18
-        $this->_name = $name;
19
-        $this->_model_name = $model_name;
20
-    }
21
-    public function field_names()
22
-    {
23
-        return $this->_field_names;
24
-    }
25
-    /**
26
-     * Internally used by get_this_model() and get_other_model()
27
-     * @param string $model_name like Event, Question_Group, etc. omit the EEM_
28
-     * @return EEM_Base
29
-     */
30
-    protected function _get_model($model_name)
31
-    {
32
-        $modelInstance = call_user_func("EEM_" . $model_name . "::instance");
33
-        return $modelInstance;
34
-    }
35
-    /**
36
-     * Gets all the fields for this index
37
-     * @return EE_Model_Field_Base[]
38
-     */
39
-    public function fields()
40
-    {
41
-        $fields = array();
42
-        $model = $this->_get_model($this->_model_name);
43
-        foreach ($model->field_settings() as $field_name => $field_obj) {
44
-            if (in_array($field_name, $this->field_names())) {
45
-                $fields[ $field_name ] = $field_obj;
46
-            }
47
-        }
48
-        return $fields;
49
-    }
9
+	protected $_name;
10
+	protected $_field_names;
11
+	protected $_model_name;
12
+	public function __construct($fields)
13
+	{
14
+		$this->_field_names = $fields;
15
+	}
16
+	public function _construct_finalize($name, $model_name)
17
+	{
18
+		$this->_name = $name;
19
+		$this->_model_name = $model_name;
20
+	}
21
+	public function field_names()
22
+	{
23
+		return $this->_field_names;
24
+	}
25
+	/**
26
+	 * Internally used by get_this_model() and get_other_model()
27
+	 * @param string $model_name like Event, Question_Group, etc. omit the EEM_
28
+	 * @return EEM_Base
29
+	 */
30
+	protected function _get_model($model_name)
31
+	{
32
+		$modelInstance = call_user_func("EEM_" . $model_name . "::instance");
33
+		return $modelInstance;
34
+	}
35
+	/**
36
+	 * Gets all the fields for this index
37
+	 * @return EE_Model_Field_Base[]
38
+	 */
39
+	public function fields()
40
+	{
41
+		$fields = array();
42
+		$model = $this->_get_model($this->_model_name);
43
+		foreach ($model->field_settings() as $field_name => $field_obj) {
44
+			if (in_array($field_name, $this->field_names())) {
45
+				$fields[ $field_name ] = $field_obj;
46
+			}
47
+		}
48
+		return $fields;
49
+	}
50 50
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      */
30 30
     protected function _get_model($model_name)
31 31
     {
32
-        $modelInstance = call_user_func("EEM_" . $model_name . "::instance");
32
+        $modelInstance = call_user_func("EEM_".$model_name."::instance");
33 33
         return $modelInstance;
34 34
     }
35 35
     /**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         $model = $this->_get_model($this->_model_name);
43 43
         foreach ($model->field_settings() as $field_name => $field_obj) {
44 44
             if (in_array($field_name, $this->field_names())) {
45
-                $fields[ $field_name ] = $field_obj;
45
+                $fields[$field_name] = $field_obj;
46 46
             }
47 47
         }
48 48
         return $fields;
Please login to merge, or discard this patch.
core/db_models/helpers/EE_Primary_Table.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,6 +25,6 @@
 block discarded – undo
25 25
      */
26 26
     public function get_table_sql()
27 27
     {
28
-        return " " . $this->get_table_name() . " AS " . $this->get_table_alias() . " ";
28
+        return " ".$this->get_table_name()." AS ".$this->get_table_alias()." ";
29 29
     }
30 30
 }
Please login to merge, or discard this patch.
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,24 +6,24 @@
 block discarded – undo
6 6
  */
7 7
 class EE_Primary_Table extends EE_Table_Base
8 8
 {
9
-    /**
10
-     *
11
-     * @global type $wpdb
12
-     * @param string $table_name with or without wpdb prefix
13
-     * @param string $pk_column name of primary key column
14
-     * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite install,
15
-     *                  or whether each site on a multisite install has a copy of this table
16
-     */
17
-    public function __construct($table_name, $pk_column = null, $global = false)
18
-    {
19
-        parent::__construct($table_name, $pk_column, $global);
20
-    }
21
-    /**
22
-     * Gets SQL for this table and assigning it an alias. Eg " wp_esp_attendee AS Attendee "
23
-     * @return string
24
-     */
25
-    public function get_table_sql()
26
-    {
27
-        return " " . $this->get_table_name() . " AS " . $this->get_table_alias() . " ";
28
-    }
9
+	/**
10
+	 *
11
+	 * @global type $wpdb
12
+	 * @param string $table_name with or without wpdb prefix
13
+	 * @param string $pk_column name of primary key column
14
+	 * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite install,
15
+	 *                  or whether each site on a multisite install has a copy of this table
16
+	 */
17
+	public function __construct($table_name, $pk_column = null, $global = false)
18
+	{
19
+		parent::__construct($table_name, $pk_column, $global);
20
+	}
21
+	/**
22
+	 * Gets SQL for this table and assigning it an alias. Eg " wp_esp_attendee AS Attendee "
23
+	 * @return string
24
+	 */
25
+	public function get_table_sql()
26
+	{
27
+		return " " . $this->get_table_name() . " AS " . $this->get_table_alias() . " ";
28
+	}
29 29
 }
Please login to merge, or discard this patch.
core/db_models/EEM_State.model.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             'Venue' => new EE_Has_Many_Relation(),
43 43
         );
44 44
         // this model is generally available for reading
45
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
45
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
46 46
         // @todo: only show STA_active
47 47
         parent::__construct($timezone);
48 48
     }
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
     */
74 74
     public function get_all_states()
75 75
     {
76
-        if (! self::$_all_states) {
77
-            self::$_all_states = $this->get_all(array( 'order_by' => array( 'STA_name' => 'ASC' ), 'limit' => array( 0, 99999 )));
76
+        if ( ! self::$_all_states) {
77
+            self::$_all_states = $this->get_all(array('order_by' => array('STA_name' => 'ASC'), 'limit' => array(0, 99999)));
78 78
         }
79 79
         return self::$_all_states;
80 80
     }
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function get_all_active_states($countries = array(), $flush_cache = false)
93 93
     {
94
-        if (! self::$_active_states || $flush_cache) {
94
+        if ( ! self::$_active_states || $flush_cache) {
95 95
             $countries = is_array($countries) && ! empty($countries) ? $countries : EEM_Country::instance()->get_all_active_countries();
96
-            self::$_active_states =  $this->get_all(array(
97
-                array( 'STA_active' => true, 'CNT_ISO' => array( 'IN', array_keys($countries))),
98
-                'order_by' => array( 'STA_name' => 'ASC' ),
99
-                'limit' => array( 0, 99999 ),
100
-                'force_join' => array( 'Country' )
96
+            self::$_active_states = $this->get_all(array(
97
+                array('STA_active' => true, 'CNT_ISO' => array('IN', array_keys($countries))),
98
+                'order_by' => array('STA_name' => 'ASC'),
99
+                'limit' => array(0, 99999),
100
+                'force_join' => array('Country')
101 101
             ));
102 102
         }
103 103
         return self::$_active_states;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function get_all_states_of_active_countries()
113 113
     {
114
-        if ($states = $this->get_all(array( array( 'Country.CNT_active' => true, 'STA_active' => true ),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
114
+        if ($states = $this->get_all(array(array('Country.CNT_active' => true, 'STA_active' => true), 'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')))) {
115 115
             return $states;
116 116
         }
117 117
         return false;
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function get_all_active_states_for_these_countries($countries)
127 127
     {
128
-        if (! $countries) {
128
+        if ( ! $countries) {
129 129
             return false;
130 130
         }
131
-        if ($states = $this->get_all(array(  array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries)), 'STA_active' => true ),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
131
+        if ($states = $this->get_all(array(array('Country.CNT_ISO' => array('IN', array_keys($countries)), 'STA_active' => true), 'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')))) {
132 132
             return $states;
133 133
         }
134 134
         return false;
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
      */
143 143
     public function get_all_states_for_these_countries($countries)
144 144
     {
145
-        if (! $countries) {
145
+        if ( ! $countries) {
146 146
             return false;
147 147
         }
148
-        if ($states = $this->get_all(array( array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries))),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
148
+        if ($states = $this->get_all(array(array('Country.CNT_ISO' => array('IN', array_keys($countries))), 'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')))) {
149 149
             return $states;
150 150
         }
151 151
         return false;
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
     public function get_state_name_by_ID($state_ID)
160 160
     {
161 161
         if (
162
-            isset(self::$_all_states[ $state_ID ]) &&
163
-                self::$_all_states[ $state_ID ] instanceof EE_State
162
+            isset(self::$_all_states[$state_ID]) &&
163
+                self::$_all_states[$state_ID] instanceof EE_State
164 164
         ) {
165
-            return self::$_all_states[ $state_ID ]->name();
165
+            return self::$_all_states[$state_ID]->name();
166 166
         }
167
-        $names = $this->get_col(array( array( 'STA_ID' => $state_ID ), 'limit' => 1), 'STA_name');
167
+        $names = $this->get_col(array(array('STA_ID' => $state_ID), 'limit' => 1), 'STA_name');
168 168
         if (is_array($names) && ! empty($names)) {
169 169
             return reset($names);
170 170
         } else {
Please login to merge, or discard this patch.
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -11,163 +11,163 @@
 block discarded – undo
11 11
  */
12 12
 class EEM_State extends EEM_Base
13 13
 {
14
-    // private instance of the Attendee object
15
-    protected static $_instance = null;
16
-    // array of all states
17
-    private static $_all_states = false;
18
-    // array of all active states
19
-    private static $_active_states = false;
20
-
21
-    protected function __construct($timezone = null)
22
-    {
23
-        $this->singular_item = esc_html__('State/Province', 'event_espresso');
24
-        $this->plural_item = esc_html__('States/Provinces', 'event_espresso');
25
-
26
-        $this->_tables = array(
27
-            'State' => new EE_Primary_Table('esp_state', 'STA_ID')
28
-        );
29
-
30
-        $this->_fields = array(
31
-            'State' => array(
32
-                'STA_ID' => new EE_Primary_Key_Int_Field('STA_ID', esc_html__('State ID', 'event_espresso')),
33
-                'CNT_ISO' => new EE_Foreign_Key_String_Field('CNT_ISO', esc_html__('Country ISO Code', 'event_espresso'), false, null, 'Country'),
34
-                'STA_abbrev' => new EE_Plain_Text_Field('STA_abbrev', esc_html__('State Abbreviation', 'event_espresso'), false, ''),
35
-                'STA_name' => new EE_Plain_Text_Field('STA_name', esc_html__('State Name', 'event_espresso'), false, ''),
36
-                'STA_active' => new EE_Boolean_Field('STA_active', esc_html__('State Active Flag', 'event_espresso'), false, false)
37
-                ));
38
-        $this->_model_relations = array(
39
-            'Attendee' => new EE_Has_Many_Relation(),
40
-            'Country' => new EE_Belongs_To_Relation(),
41
-            'Venue' => new EE_Has_Many_Relation(),
42
-        );
43
-        // this model is generally available for reading
44
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
45
-        // @todo: only show STA_active
46
-        parent::__construct($timezone);
47
-    }
48
-
49
-
50
-
51
-
52
-    /**
53
-    *   reset_cached_states
54
-    *
55
-    *   @access     private
56
-    *   @return         void
57
-    */
58
-    public function reset_cached_states()
59
-    {
60
-        EEM_State::$_active_states = array();
61
-        EEM_State::$_all_states = array();
62
-    }
63
-
64
-
65
-
66
-
67
-    /**
68
-    *       _get_states
69
-    *
70
-    *       @access     private
71
-    *       @return         array
72
-    */
73
-    public function get_all_states()
74
-    {
75
-        if (! self::$_all_states) {
76
-            self::$_all_states = $this->get_all(array( 'order_by' => array( 'STA_name' => 'ASC' ), 'limit' => array( 0, 99999 )));
77
-        }
78
-        return self::$_all_states;
79
-    }
80
-
81
-
82
-
83
-    /**
84
-     *        _get_states
85
-     *
86
-     * @access        public
87
-     * @param array $countries
88
-     * @param bool  $flush_cache
89
-     * @return        array
90
-     */
91
-    public function get_all_active_states($countries = array(), $flush_cache = false)
92
-    {
93
-        if (! self::$_active_states || $flush_cache) {
94
-            $countries = is_array($countries) && ! empty($countries) ? $countries : EEM_Country::instance()->get_all_active_countries();
95
-            self::$_active_states =  $this->get_all(array(
96
-                array( 'STA_active' => true, 'CNT_ISO' => array( 'IN', array_keys($countries))),
97
-                'order_by' => array( 'STA_name' => 'ASC' ),
98
-                'limit' => array( 0, 99999 ),
99
-                'force_join' => array( 'Country' )
100
-            ));
101
-        }
102
-        return self::$_active_states;
103
-    }
104
-
105
-
106
-
107
-    /**
108
-     *  get_all_states_of_active_countries
109
-     * @return array
110
-     */
111
-    public function get_all_states_of_active_countries()
112
-    {
113
-        if ($states = $this->get_all(array( array( 'Country.CNT_active' => true, 'STA_active' => true ),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
114
-            return $states;
115
-        }
116
-        return false;
117
-    }
118
-
119
-
120
-
121
-    /**
122
-     *  get_all_states_of_active_countries
123
-     * @return array
124
-     */
125
-    public function get_all_active_states_for_these_countries($countries)
126
-    {
127
-        if (! $countries) {
128
-            return false;
129
-        }
130
-        if ($states = $this->get_all(array(  array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries)), 'STA_active' => true ),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
131
-            return $states;
132
-        }
133
-        return false;
134
-    }
135
-
136
-
137
-
138
-    /**
139
-     *  get_all_states_of_active_countries
140
-     * @return array
141
-     */
142
-    public function get_all_states_for_these_countries($countries)
143
-    {
144
-        if (! $countries) {
145
-            return false;
146
-        }
147
-        if ($states = $this->get_all(array( array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries))),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
148
-            return $states;
149
-        }
150
-        return false;
151
-    }
152
-
153
-    /**
154
-     * Gets the state's name by its ID
155
-     * @param string $state_ID
156
-     * @return string
157
-     */
158
-    public function get_state_name_by_ID($state_ID)
159
-    {
160
-        if (
161
-            isset(self::$_all_states[ $state_ID ]) &&
162
-                self::$_all_states[ $state_ID ] instanceof EE_State
163
-        ) {
164
-            return self::$_all_states[ $state_ID ]->name();
165
-        }
166
-        $names = $this->get_col(array( array( 'STA_ID' => $state_ID ), 'limit' => 1), 'STA_name');
167
-        if (is_array($names) && ! empty($names)) {
168
-            return reset($names);
169
-        } else {
170
-            return '';
171
-        }
172
-    }
14
+	// private instance of the Attendee object
15
+	protected static $_instance = null;
16
+	// array of all states
17
+	private static $_all_states = false;
18
+	// array of all active states
19
+	private static $_active_states = false;
20
+
21
+	protected function __construct($timezone = null)
22
+	{
23
+		$this->singular_item = esc_html__('State/Province', 'event_espresso');
24
+		$this->plural_item = esc_html__('States/Provinces', 'event_espresso');
25
+
26
+		$this->_tables = array(
27
+			'State' => new EE_Primary_Table('esp_state', 'STA_ID')
28
+		);
29
+
30
+		$this->_fields = array(
31
+			'State' => array(
32
+				'STA_ID' => new EE_Primary_Key_Int_Field('STA_ID', esc_html__('State ID', 'event_espresso')),
33
+				'CNT_ISO' => new EE_Foreign_Key_String_Field('CNT_ISO', esc_html__('Country ISO Code', 'event_espresso'), false, null, 'Country'),
34
+				'STA_abbrev' => new EE_Plain_Text_Field('STA_abbrev', esc_html__('State Abbreviation', 'event_espresso'), false, ''),
35
+				'STA_name' => new EE_Plain_Text_Field('STA_name', esc_html__('State Name', 'event_espresso'), false, ''),
36
+				'STA_active' => new EE_Boolean_Field('STA_active', esc_html__('State Active Flag', 'event_espresso'), false, false)
37
+				));
38
+		$this->_model_relations = array(
39
+			'Attendee' => new EE_Has_Many_Relation(),
40
+			'Country' => new EE_Belongs_To_Relation(),
41
+			'Venue' => new EE_Has_Many_Relation(),
42
+		);
43
+		// this model is generally available for reading
44
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
45
+		// @todo: only show STA_active
46
+		parent::__construct($timezone);
47
+	}
48
+
49
+
50
+
51
+
52
+	/**
53
+	 *   reset_cached_states
54
+	 *
55
+	 *   @access     private
56
+	 *   @return         void
57
+	 */
58
+	public function reset_cached_states()
59
+	{
60
+		EEM_State::$_active_states = array();
61
+		EEM_State::$_all_states = array();
62
+	}
63
+
64
+
65
+
66
+
67
+	/**
68
+	 *       _get_states
69
+	 *
70
+	 *       @access     private
71
+	 *       @return         array
72
+	 */
73
+	public function get_all_states()
74
+	{
75
+		if (! self::$_all_states) {
76
+			self::$_all_states = $this->get_all(array( 'order_by' => array( 'STA_name' => 'ASC' ), 'limit' => array( 0, 99999 )));
77
+		}
78
+		return self::$_all_states;
79
+	}
80
+
81
+
82
+
83
+	/**
84
+	 *        _get_states
85
+	 *
86
+	 * @access        public
87
+	 * @param array $countries
88
+	 * @param bool  $flush_cache
89
+	 * @return        array
90
+	 */
91
+	public function get_all_active_states($countries = array(), $flush_cache = false)
92
+	{
93
+		if (! self::$_active_states || $flush_cache) {
94
+			$countries = is_array($countries) && ! empty($countries) ? $countries : EEM_Country::instance()->get_all_active_countries();
95
+			self::$_active_states =  $this->get_all(array(
96
+				array( 'STA_active' => true, 'CNT_ISO' => array( 'IN', array_keys($countries))),
97
+				'order_by' => array( 'STA_name' => 'ASC' ),
98
+				'limit' => array( 0, 99999 ),
99
+				'force_join' => array( 'Country' )
100
+			));
101
+		}
102
+		return self::$_active_states;
103
+	}
104
+
105
+
106
+
107
+	/**
108
+	 *  get_all_states_of_active_countries
109
+	 * @return array
110
+	 */
111
+	public function get_all_states_of_active_countries()
112
+	{
113
+		if ($states = $this->get_all(array( array( 'Country.CNT_active' => true, 'STA_active' => true ),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
114
+			return $states;
115
+		}
116
+		return false;
117
+	}
118
+
119
+
120
+
121
+	/**
122
+	 *  get_all_states_of_active_countries
123
+	 * @return array
124
+	 */
125
+	public function get_all_active_states_for_these_countries($countries)
126
+	{
127
+		if (! $countries) {
128
+			return false;
129
+		}
130
+		if ($states = $this->get_all(array(  array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries)), 'STA_active' => true ),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
131
+			return $states;
132
+		}
133
+		return false;
134
+	}
135
+
136
+
137
+
138
+	/**
139
+	 *  get_all_states_of_active_countries
140
+	 * @return array
141
+	 */
142
+	public function get_all_states_for_these_countries($countries)
143
+	{
144
+		if (! $countries) {
145
+			return false;
146
+		}
147
+		if ($states = $this->get_all(array( array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries))),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
148
+			return $states;
149
+		}
150
+		return false;
151
+	}
152
+
153
+	/**
154
+	 * Gets the state's name by its ID
155
+	 * @param string $state_ID
156
+	 * @return string
157
+	 */
158
+	public function get_state_name_by_ID($state_ID)
159
+	{
160
+		if (
161
+			isset(self::$_all_states[ $state_ID ]) &&
162
+				self::$_all_states[ $state_ID ] instanceof EE_State
163
+		) {
164
+			return self::$_all_states[ $state_ID ]->name();
165
+		}
166
+		$names = $this->get_col(array( array( 'STA_ID' => $state_ID ), 'limit' => 1), 'STA_name');
167
+		if (is_array($names) && ! empty($names)) {
168
+			return reset($names);
169
+		} else {
170
+			return '';
171
+		}
172
+	}
173 173
 }
Please login to merge, or discard this patch.