Completed
Branch models-cleanup/main (de94a1)
by
unknown
96:57 queued 87:28
created
core/db_models/fields/EE_Full_HTML_Field.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -14,57 +14,57 @@
 block discarded – undo
14 14
 class EE_Full_HTML_Field extends EE_Text_Field_Base
15 15
 {
16 16
 
17
-    /**
18
-     * @param string $table_column
19
-     * @param string $nicename
20
-     * @param bool   $nullable
21
-     * @param null   $default_value
22
-     */
23
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
24
-    {
25
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
26
-        $this->setSchemaType('object');
27
-    }
17
+	/**
18
+	 * @param string $table_column
19
+	 * @param string $nicename
20
+	 * @param bool   $nullable
21
+	 * @param null   $default_value
22
+	 */
23
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
24
+	{
25
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
26
+		$this->setSchemaType('object');
27
+	}
28 28
 
29 29
 
30
-    /**
31
-     * Does shortcodes and auto-paragraphs the content (unless schema is 'no_wpautop')
32
-     *
33
-     * @param type $value_on_field_to_be_outputted
34
-     * @param type $schema
35
-     * @return string
36
-     */
37
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
38
-    {
39
-        if ($schema == 'form_input') {
40
-            return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
41
-        } elseif ($schema == 'no_wpautop') {
42
-            return do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema));
43
-        } else {
44
-            return wpautop(do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema)));
45
-        }
46
-    }
30
+	/**
31
+	 * Does shortcodes and auto-paragraphs the content (unless schema is 'no_wpautop')
32
+	 *
33
+	 * @param type $value_on_field_to_be_outputted
34
+	 * @param type $schema
35
+	 * @return string
36
+	 */
37
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
38
+	{
39
+		if ($schema == 'form_input') {
40
+			return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
41
+		} elseif ($schema == 'no_wpautop') {
42
+			return do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema));
43
+		} else {
44
+			return wpautop(do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema)));
45
+		}
46
+	}
47 47
 
48 48
 
49 49
 
50
-    public function getSchemaProperties()
51
-    {
52
-        return array(
53
-            'raw' => array(
54
-                'description' =>  sprintf(
55
-                    esc_html__('%s - the value in the database.', 'event_espresso'),
56
-                    $this->get_nicename()
57
-                ),
58
-                'type' => 'string'
59
-            ),
60
-            'rendered' => array(
61
-                'description' =>  sprintf(
62
-                    esc_html__('%s - transformed for display.', 'event_espresso'),
63
-                    $this->get_nicename()
64
-                ),
65
-                'type' => 'string',
66
-                'readonly' => true
67
-            )
68
-        );
69
-    }
50
+	public function getSchemaProperties()
51
+	{
52
+		return array(
53
+			'raw' => array(
54
+				'description' =>  sprintf(
55
+					esc_html__('%s - the value in the database.', 'event_espresso'),
56
+					$this->get_nicename()
57
+				),
58
+				'type' => 'string'
59
+			),
60
+			'rendered' => array(
61
+				'description' =>  sprintf(
62
+					esc_html__('%s - transformed for display.', 'event_espresso'),
63
+					$this->get_nicename()
64
+				),
65
+				'type' => 'string',
66
+				'readonly' => true
67
+			)
68
+		);
69
+	}
70 70
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Infinite_Integer_Field.php 1 patch
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -10,78 +10,78 @@
 block discarded – undo
10 10
 class EE_Infinite_Integer_Field extends EE_Model_Field_Base
11 11
 {
12 12
 
13
-    /**
14
-     * @param string $table_column
15
-     * @param string $nicename
16
-     * @param bool   $nullable
17
-     * @param null   $default_value
18
-     */
19
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
20
-    {
21
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
22
-        $this->setSchemaType(array('integer', 'null'));
23
-    }
13
+	/**
14
+	 * @param string $table_column
15
+	 * @param string $nicename
16
+	 * @param bool   $nullable
17
+	 * @param null   $default_value
18
+	 */
19
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
20
+	{
21
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
22
+		$this->setSchemaType(array('integer', 'null'));
23
+	}
24 24
 
25 25
 
26
-    public function prepare_for_use_in_db($value_of_field_on_model_object)
27
-    {
28
-        if ($value_of_field_on_model_object === EE_INF) {
29
-            return EE_INF_IN_DB;
30
-        } else {
31
-            return intval($value_of_field_on_model_object);
32
-        }
33
-    }
26
+	public function prepare_for_use_in_db($value_of_field_on_model_object)
27
+	{
28
+		if ($value_of_field_on_model_object === EE_INF) {
29
+			return EE_INF_IN_DB;
30
+		} else {
31
+			return intval($value_of_field_on_model_object);
32
+		}
33
+	}
34 34
 
35
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
36
-    {
37
-        if (
38
-            $value_inputted_for_field_on_model_object === EE_INF_IN_DB ||
39
-            $value_inputted_for_field_on_model_object === EE_INF ||
40
-            $value_inputted_for_field_on_model_object === "EE_INF" ||
41
-            $value_inputted_for_field_on_model_object === ""
42
-        ) {
43
-            return EE_INF;
44
-        } else {
45
-            return intval($value_inputted_for_field_on_model_object);
46
-        }
47
-    }
35
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
36
+	{
37
+		if (
38
+			$value_inputted_for_field_on_model_object === EE_INF_IN_DB ||
39
+			$value_inputted_for_field_on_model_object === EE_INF ||
40
+			$value_inputted_for_field_on_model_object === "EE_INF" ||
41
+			$value_inputted_for_field_on_model_object === ""
42
+		) {
43
+			return EE_INF;
44
+		} else {
45
+			return intval($value_inputted_for_field_on_model_object);
46
+		}
47
+	}
48 48
 
49
-    public function prepare_for_set_from_db($value_inputted_for_field_on_model_object)
50
-    {
51
-        $intval = intval($value_inputted_for_field_on_model_object);
52
-        if ($intval == EE_INF_IN_DB) {
53
-            return EE_INF;
54
-        } else {
55
-            return $intval;
56
-        }
57
-    }
49
+	public function prepare_for_set_from_db($value_inputted_for_field_on_model_object)
50
+	{
51
+		$intval = intval($value_inputted_for_field_on_model_object);
52
+		if ($intval == EE_INF_IN_DB) {
53
+			return EE_INF;
54
+		} else {
55
+			return $intval;
56
+		}
57
+	}
58 58
 
59
-    /**
60
-     * For outputting this field's value. If you want to output it into an input or something,
61
-     * use $schema=='input', as it will replace EE_INF with ''. If you want a readable version, use $schema=='text'
62
-     * as it will replace EE_INF with i18n Infinite
63
-     *
64
-     * @param type   $value_on_field_to_be_outputted
65
-     * @param string $schema input, symbol, text; or any string you want to show if the value equals EE_INF
66
-     * @return string
67
-     */
68
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
69
-    {
70
-        if ($value_on_field_to_be_outputted === EE_INF) {
71
-            switch ($schema) {
72
-                case 'input':
73
-                case 'form_input':
74
-                    return '';
75
-                case 'symbol':
76
-                    return "∞";
77
-                case 'text':
78
-                case null:
79
-                    return esc_html__("Unlimited", "event_espresso");
80
-                default:
81
-                    return $schema;
82
-            }
83
-        } else {
84
-            return $value_on_field_to_be_outputted;
85
-        }
86
-    }
59
+	/**
60
+	 * For outputting this field's value. If you want to output it into an input or something,
61
+	 * use $schema=='input', as it will replace EE_INF with ''. If you want a readable version, use $schema=='text'
62
+	 * as it will replace EE_INF with i18n Infinite
63
+	 *
64
+	 * @param type   $value_on_field_to_be_outputted
65
+	 * @param string $schema input, symbol, text; or any string you want to show if the value equals EE_INF
66
+	 * @return string
67
+	 */
68
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
69
+	{
70
+		if ($value_on_field_to_be_outputted === EE_INF) {
71
+			switch ($schema) {
72
+				case 'input':
73
+				case 'form_input':
74
+					return '';
75
+				case 'symbol':
76
+					return "∞";
77
+				case 'text':
78
+				case null:
79
+					return esc_html__("Unlimited", "event_espresso");
80
+				default:
81
+					return $schema;
82
+			}
83
+		} else {
84
+			return $value_on_field_to_be_outputted;
85
+		}
86
+	}
87 87
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Foreign_Key_Int_Field.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -3,39 +3,39 @@
 block discarded – undo
3 3
 class EE_Foreign_Key_Int_Field extends EE_Foreign_Key_Field_Base
4 4
 {
5 5
 
6
-    /**
7
-     * @param string       $table_column  name fo column for field
8
-     * @param string       $nice_name     should eb internationalized with esc_html__('blah','event_espresso')
9
-     * @param boolean      $nullable
10
-     * @param mixed        $default_value if this is a integer field, it should be an int.
11
-     *                                    if it's a string field, it should be a string
12
-     * @param string|array $model_name    eg 'Event','Answer','Term', etc.
13
-     *                                    Basically its the model class's name without the "EEM_"
14
-     */
15
-    public function __construct($table_column, $nice_name, $nullable, $default_value, $model_name)
16
-    {
17
-        parent::__construct($table_column, $nice_name, $nullable, $default_value, $model_name);
18
-        $this->setSchemaType('integer');
19
-    }
6
+	/**
7
+	 * @param string       $table_column  name fo column for field
8
+	 * @param string       $nice_name     should eb internationalized with esc_html__('blah','event_espresso')
9
+	 * @param boolean      $nullable
10
+	 * @param mixed        $default_value if this is a integer field, it should be an int.
11
+	 *                                    if it's a string field, it should be a string
12
+	 * @param string|array $model_name    eg 'Event','Answer','Term', etc.
13
+	 *                                    Basically its the model class's name without the "EEM_"
14
+	 */
15
+	public function __construct($table_column, $nice_name, $nullable, $default_value, $model_name)
16
+	{
17
+		parent::__construct($table_column, $nice_name, $nullable, $default_value, $model_name);
18
+		$this->setSchemaType('integer');
19
+	}
20 20
 
21 21
 
22
-    /**
23
-     * @param int|EE_Base_Class $value_inputted_for_field_on_model_object
24
-     * @return int
25
-     * @throws EE_Error
26
-     * @throws EE_Error
27
-     */
28
-    public function prepare_for_set($value_inputted_for_field_on_model_object): int
29
-    {
30
-        if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) {
31
-            $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID();
32
-        }
33
-        return absint($value_inputted_for_field_on_model_object);
34
-    }
22
+	/**
23
+	 * @param int|EE_Base_Class $value_inputted_for_field_on_model_object
24
+	 * @return int
25
+	 * @throws EE_Error
26
+	 * @throws EE_Error
27
+	 */
28
+	public function prepare_for_set($value_inputted_for_field_on_model_object): int
29
+	{
30
+		if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) {
31
+			$value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID();
32
+		}
33
+		return absint($value_inputted_for_field_on_model_object);
34
+	}
35 35
 
36 36
 
37
-    public function prepare_for_set_from_db($value_found_in_db_for_model_object)
38
-    {
39
-        return intval($value_found_in_db_for_model_object);
40
-    }
37
+	public function prepare_for_set_from_db($value_found_in_db_for_model_object)
38
+	{
39
+		return intval($value_found_in_db_for_model_object);
40
+	}
41 41
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_WP_User_Field.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -13,39 +13,39 @@
 block discarded – undo
13 13
  */
14 14
 class EE_WP_User_Field extends EE_Foreign_Key_Int_Field
15 15
 {
16
-    /**
17
-     * No need to provide a default or the model pointed to- the default is
18
-     * always get_current_user_id() and the model pointed to is always WP_User
19
-     *
20
-     * @param string  $table_column name fo column for field
21
-     * @param string  $nice_name     should eb internationalized with esc_html__('blah','event_espresso')
22
-     * @param boolean $nullable
23
-     */
24
-    public function __construct($table_column, $nice_name, $nullable)
25
-    {
26
-        parent::__construct($table_column, $nice_name, $nullable, get_current_user_id(), 'WP_User');
27
-    }
16
+	/**
17
+	 * No need to provide a default or the model pointed to- the default is
18
+	 * always get_current_user_id() and the model pointed to is always WP_User
19
+	 *
20
+	 * @param string  $table_column name fo column for field
21
+	 * @param string  $nice_name     should eb internationalized with esc_html__('blah','event_espresso')
22
+	 * @param boolean $nullable
23
+	 */
24
+	public function __construct($table_column, $nice_name, $nullable)
25
+	{
26
+		parent::__construct($table_column, $nice_name, $nullable, get_current_user_id(), 'WP_User');
27
+	}
28 28
 
29
-    /**
30
-     * Gets the default which is always the current user. This can't be set when initially
31
-     * constructing the model field because that's done before $current_user is set
32
-     *
33
-     * @return mixed
34
-     */
35
-    public function get_default_value()
36
-    {
37
-        if (did_action('init')) {
38
-            return get_current_user_id();
39
-        } else {
40
-            EE_Error::doing_it_wrong(
41
-                'EE_WP_User_Field::get_default_value',
42
-                esc_html__(
43
-                    'You cant get a default value for a wp_User_Field because the "init" action is called, because current_user global hasnt yet been setup. Consider doing your business logic on the "init" hook or later.',
44
-                    'event_espresso'
45
-                ),
46
-                '4.6.20'
47
-            );
48
-            return 1;
49
-        }
50
-    }
29
+	/**
30
+	 * Gets the default which is always the current user. This can't be set when initially
31
+	 * constructing the model field because that's done before $current_user is set
32
+	 *
33
+	 * @return mixed
34
+	 */
35
+	public function get_default_value()
36
+	{
37
+		if (did_action('init')) {
38
+			return get_current_user_id();
39
+		} else {
40
+			EE_Error::doing_it_wrong(
41
+				'EE_WP_User_Field::get_default_value',
42
+				esc_html__(
43
+					'You cant get a default value for a wp_User_Field because the "init" action is called, because current_user global hasnt yet been setup. Consider doing your business logic on the "init" hook or later.',
44
+					'event_espresso'
45
+				),
46
+				'4.6.20'
47
+			);
48
+			return 1;
49
+		}
50
+	}
51 51
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Money_Field.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -7,92 +7,92 @@
 block discarded – undo
7 7
 class EE_Money_Field extends EE_Float_Field
8 8
 {
9 9
 
10
-    /**
11
-     * @param string $table_column
12
-     * @param string $nicename
13
-     * @param bool   $nullable
14
-     * @param null   $default_value
15
-     */
16
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
17
-    {
18
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
19
-        $this->setSchemaType('object');
20
-    }
10
+	/**
11
+	 * @param string $table_column
12
+	 * @param string $nicename
13
+	 * @param bool   $nullable
14
+	 * @param null   $default_value
15
+	 */
16
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
17
+	{
18
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
19
+		$this->setSchemaType('object');
20
+	}
21 21
 
22 22
 
23
-    /**
24
-     * Schemas:
25
-     *    'localized_float': "3,023.00"
26
-     *    'no_currency_code': "$3,023.00"
27
-     *    null: "$3,023.00<span>USD</span>"
28
-     *
29
-     * @param string $value_on_field_to_be_outputted
30
-     * @param string $schema
31
-     * @return string
32
-     */
33
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
34
-    {
35
-        $pretty_float = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted);
23
+	/**
24
+	 * Schemas:
25
+	 *    'localized_float': "3,023.00"
26
+	 *    'no_currency_code': "$3,023.00"
27
+	 *    null: "$3,023.00<span>USD</span>"
28
+	 *
29
+	 * @param string $value_on_field_to_be_outputted
30
+	 * @param string $schema
31
+	 * @return string
32
+	 */
33
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
34
+	{
35
+		$pretty_float = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted);
36 36
 
37
-        if ($schema == 'localized_float') {
38
-            return $pretty_float;
39
-        }
40
-        if ($schema == 'no_currency_code') {
37
+		if ($schema == 'localized_float') {
38
+			return $pretty_float;
39
+		}
40
+		if ($schema == 'no_currency_code') {
41 41
 //          echo "schema no currency!";
42
-            $display_code = false;
43
-        } else {
44
-            $display_code = true;
45
-        }
46
-        // we don't use the $pretty_float because format_currency will take care of it.
47
-        return EEH_Template::format_currency($value_on_field_to_be_outputted, false, $display_code);
48
-    }
42
+			$display_code = false;
43
+		} else {
44
+			$display_code = true;
45
+		}
46
+		// we don't use the $pretty_float because format_currency will take care of it.
47
+		return EEH_Template::format_currency($value_on_field_to_be_outputted, false, $display_code);
48
+	}
49 49
 
50
-    /**
51
-     * If provided with a string, strips out money-related formatting to turn it into a proper float.
52
-     * Rounds the float to the correct number of decimal places for this country's currency.
53
-     * Also, interprets periods and commas according to the country's currency settings.
54
-     * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first.
55
-     *
56
-     * @param string $value_inputted_for_field_on_model_object
57
-     * @return float
58
-     */
59
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
60
-    {
61
-        // remove any currencies etc.
50
+	/**
51
+	 * If provided with a string, strips out money-related formatting to turn it into a proper float.
52
+	 * Rounds the float to the correct number of decimal places for this country's currency.
53
+	 * Also, interprets periods and commas according to the country's currency settings.
54
+	 * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first.
55
+	 *
56
+	 * @param string $value_inputted_for_field_on_model_object
57
+	 * @return float
58
+	 */
59
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
60
+	{
61
+		// remove any currencies etc.
62 62
 //      if(is_string($value_inputted_for_field_on_model_object)){
63 63
 //          $value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "", $value_inputted_for_field_on_model_object);
64 64
 //      }
65
-        // now it's a float-style string or number
66
-        $float_val = parent::prepare_for_set($value_inputted_for_field_on_model_object);
67
-        // round to the correctly number of decimal places for this  currency
68
-        $rounded_value = round($float_val, EE_Registry::instance()->CFG->currency->dec_plc);
69
-        return $rounded_value;
70
-    }
65
+		// now it's a float-style string or number
66
+		$float_val = parent::prepare_for_set($value_inputted_for_field_on_model_object);
67
+		// round to the correctly number of decimal places for this  currency
68
+		$rounded_value = round($float_val, EE_Registry::instance()->CFG->currency->dec_plc);
69
+		return $rounded_value;
70
+	}
71 71
 
72
-    public function prepare_for_get($value_of_field_on_model_object)
73
-    {
74
-        $c = EE_Registry::instance()->CFG->currency;
75
-        return round(parent::prepare_for_get($value_of_field_on_model_object), $c->dec_plc);
76
-    }
72
+	public function prepare_for_get($value_of_field_on_model_object)
73
+	{
74
+		$c = EE_Registry::instance()->CFG->currency;
75
+		return round(parent::prepare_for_get($value_of_field_on_model_object), $c->dec_plc);
76
+	}
77 77
 
78
-    public function getSchemaProperties()
79
-    {
80
-        return array(
81
-            'raw' => array(
82
-                'description' =>  sprintf(
83
-                    esc_html__('%s - the raw value as it exists in the database as a simple float.', 'event_espresso'),
84
-                    $this->get_nicename()
85
-                ),
86
-                'type' => 'number',
87
-            ),
88
-            'pretty' => array(
89
-                'description' =>  sprintf(
90
-                    esc_html__('%s - formatted for display in the set currency and decimal places.', 'event_espresso'),
91
-                    $this->get_nicename()
92
-                ),
93
-                'type' => 'string',
94
-                'format' => 'money'
95
-            )
96
-        );
97
-    }
78
+	public function getSchemaProperties()
79
+	{
80
+		return array(
81
+			'raw' => array(
82
+				'description' =>  sprintf(
83
+					esc_html__('%s - the raw value as it exists in the database as a simple float.', 'event_espresso'),
84
+					$this->get_nicename()
85
+				),
86
+				'type' => 'number',
87
+			),
88
+			'pretty' => array(
89
+				'description' =>  sprintf(
90
+					esc_html__('%s - formatted for display in the set currency and decimal places.', 'event_espresso'),
91
+					$this->get_nicename()
92
+				),
93
+				'type' => 'string',
94
+				'format' => 'money'
95
+			)
96
+		);
97
+	}
98 98
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Primary_Key_Field_Base.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -2,24 +2,24 @@
 block discarded – undo
2 2
 
3 3
 abstract class EE_Primary_Key_Field_Base extends EE_Field_With_Model_Name
4 4
 {
5
-    /**
6
-     * Overrides parent so it doesn't need to provide so many non-applicable fields
7
-     *
8
-     * @param string $table_column
9
-     * @param string $nicename
10
-     */
11
-    public function __construct($table_column, $nicename, $default)
12
-    {
13
-        parent::__construct($table_column, $nicename, false, $default, '');
14
-    }
5
+	/**
6
+	 * Overrides parent so it doesn't need to provide so many non-applicable fields
7
+	 *
8
+	 * @param string $table_column
9
+	 * @param string $nicename
10
+	 */
11
+	public function __construct($table_column, $nicename, $default)
12
+	{
13
+		parent::__construct($table_column, $nicename, false, $default, '');
14
+	}
15 15
 
16
-    /**
17
-     * @param $table_alias
18
-     * @param $name
19
-     */
20
-    public function _construct_finalize($table_alias, $name, $model_name)
21
-    {
22
-        $this->_model_name_pointed_to = $model_name;
23
-        parent::_construct_finalize($table_alias, $name, $model_name);
24
-    }
16
+	/**
17
+	 * @param $table_alias
18
+	 * @param $name
19
+	 */
20
+	public function _construct_finalize($table_alias, $name, $model_name)
21
+	{
22
+		$this->_model_name_pointed_to = $model_name;
23
+		parent::_construct_finalize($table_alias, $name, $model_name);
24
+	}
25 25
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_WP_Post_Status_Field.php 1 patch
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -3,114 +3,114 @@
 block discarded – undo
3 3
 class EE_WP_Post_Status_Field extends EE_Enum_Text_Field
4 4
 {
5 5
 
6
-    protected $_wp_post_stati;
6
+	protected $_wp_post_stati;
7 7
 
8 8
 
9
-    /**
10
-     * constructor
11
-     *
12
-     * @param string  $table_column       column on table
13
-     * @param string  $nicename           nice name for column(field)
14
-     * @param bool    $nullable           is this field nullable
15
-     * @param string  $default_value      default status
16
-     * @param array   $new_stati          If additional stati are to be used other than the default WP statuses then
17
-     *                                    they can be registered via this property.  The format of the array should be
18
-     *                                    as follows: array(
19
-     *                                    'status_reference' => array(
20
-     *                                    'label' => esc_html__('Status Reference Label', 'event_espresso')
21
-     *                                    'public' => true, //'Whether posts of this status should be shown on the
22
-     *                                    frontend of the site'
23
-     *                                    'exclude_from_search' => false, //'Whether posts of this status should be
24
-     *                                    excluded from wp searches'
25
-     *                                    'show_in_admin_all_list' => true, //whether posts of this status are included
26
-     *                                    in queries for the admin "all" view in list table views.
27
-     *                                    'show_in_admin_status_list' => true, //Show in the list of statuses with post
28
-     *                                    counts at the top of the admin list tables (i.e. Status Reference(2) )
29
-     *                                    'label_count' => _n_noop( 'Status Reference <span class="count">(%s)</span>',
30
-     *                                    'Status References <span class="count">(%s)</span>' ), //the text to display
31
-     *                                    on the admin screen( or you won't see your status count ).
32
-     *                                    )
33
-     *                                    )
34
-     * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info
35
-     * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is
36
-     *                                    set to true, it will be stored as an INT
37
-     */
38
-    public function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array())
39
-    {
40
-        $this->_register_new_stati($new_stati);
41
-        $this->_set_allowed_enum_values();
42
-        parent::__construct($table_column, $nicename, $nullable, $default_value, $this->_allowed_enum_values);
43
-    }
9
+	/**
10
+	 * constructor
11
+	 *
12
+	 * @param string  $table_column       column on table
13
+	 * @param string  $nicename           nice name for column(field)
14
+	 * @param bool    $nullable           is this field nullable
15
+	 * @param string  $default_value      default status
16
+	 * @param array   $new_stati          If additional stati are to be used other than the default WP statuses then
17
+	 *                                    they can be registered via this property.  The format of the array should be
18
+	 *                                    as follows: array(
19
+	 *                                    'status_reference' => array(
20
+	 *                                    'label' => esc_html__('Status Reference Label', 'event_espresso')
21
+	 *                                    'public' => true, //'Whether posts of this status should be shown on the
22
+	 *                                    frontend of the site'
23
+	 *                                    'exclude_from_search' => false, //'Whether posts of this status should be
24
+	 *                                    excluded from wp searches'
25
+	 *                                    'show_in_admin_all_list' => true, //whether posts of this status are included
26
+	 *                                    in queries for the admin "all" view in list table views.
27
+	 *                                    'show_in_admin_status_list' => true, //Show in the list of statuses with post
28
+	 *                                    counts at the top of the admin list tables (i.e. Status Reference(2) )
29
+	 *                                    'label_count' => _n_noop( 'Status Reference <span class="count">(%s)</span>',
30
+	 *                                    'Status References <span class="count">(%s)</span>' ), //the text to display
31
+	 *                                    on the admin screen( or you won't see your status count ).
32
+	 *                                    )
33
+	 *                                    )
34
+	 * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info
35
+	 * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is
36
+	 *                                    set to true, it will be stored as an INT
37
+	 */
38
+	public function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array())
39
+	{
40
+		$this->_register_new_stati($new_stati);
41
+		$this->_set_allowed_enum_values();
42
+		parent::__construct($table_column, $nicename, $nullable, $default_value, $this->_allowed_enum_values);
43
+	}
44 44
 
45 45
 
46
-    /**
47
-     * This registers any new statuses sent via the $new_stati array on construct
48
-     *
49
-     * @access protected
50
-     * @param  array $new_stati statuses
51
-     * @return void
52
-     */
53
-    protected function _register_new_stati($new_stati)
54
-    {
46
+	/**
47
+	 * This registers any new statuses sent via the $new_stati array on construct
48
+	 *
49
+	 * @access protected
50
+	 * @param  array $new_stati statuses
51
+	 * @return void
52
+	 */
53
+	protected function _register_new_stati($new_stati)
54
+	{
55 55
 
56
-        foreach ((array) $new_stati as $status_key => $status_args) {
57
-            $args = array(
58
-                'label'                     => isset($status_args['label']) ? $status_args['label'] : $status_key,
59
-                'public'                    => isset($status_args['public']) && is_bool($status_args['public']) ? $status_args['public'] : true,
60
-                'exclude_from_search'       => isset($status_args['exclude_from_search']) && is_bool($status_args['exclude_from_search']) ? $status_args['exclude_from_search'] : false,
61
-                'show_in_admin_all_list'    => isset($status_args['show_in_admin_all_list']) && is_bool($status_args['show_in_admin_all_list']) ? $status_args['show_in_admin_all_list'] : false,
62
-                'show_in_admin_status_list' => isset($status_args['show_in_admin_status_list']) && is_bool($status_args['show_in_admin_status_list']) ? $status_args['show_in_admin_status_list'] : true,
63
-                'label_count'               => isset($status_args['label_count']) ? $status_args['label_count'] : '',
64
-            );
65
-            register_post_status($status_key, $status_args);
66
-        }
67
-    }
56
+		foreach ((array) $new_stati as $status_key => $status_args) {
57
+			$args = array(
58
+				'label'                     => isset($status_args['label']) ? $status_args['label'] : $status_key,
59
+				'public'                    => isset($status_args['public']) && is_bool($status_args['public']) ? $status_args['public'] : true,
60
+				'exclude_from_search'       => isset($status_args['exclude_from_search']) && is_bool($status_args['exclude_from_search']) ? $status_args['exclude_from_search'] : false,
61
+				'show_in_admin_all_list'    => isset($status_args['show_in_admin_all_list']) && is_bool($status_args['show_in_admin_all_list']) ? $status_args['show_in_admin_all_list'] : false,
62
+				'show_in_admin_status_list' => isset($status_args['show_in_admin_status_list']) && is_bool($status_args['show_in_admin_status_list']) ? $status_args['show_in_admin_status_list'] : true,
63
+				'label_count'               => isset($status_args['label_count']) ? $status_args['label_count'] : '',
64
+			);
65
+			register_post_status($status_key, $status_args);
66
+		}
67
+	}
68 68
 
69 69
 
70
-    /**
71
-     * This sets the _allowed_enum_values property using the $wp_post_stati array
72
-     *
73
-     * @access protected
74
-     * @regurn void
75
-     */
76
-    protected function _set_allowed_enum_values()
77
-    {
78
-        // first let's get the post_statuses
79
-        global $wp_post_statuses;
80
-        $this->_wp_post_stati = $wp_post_statuses;
70
+	/**
71
+	 * This sets the _allowed_enum_values property using the $wp_post_stati array
72
+	 *
73
+	 * @access protected
74
+	 * @regurn void
75
+	 */
76
+	protected function _set_allowed_enum_values()
77
+	{
78
+		// first let's get the post_statuses
79
+		global $wp_post_statuses;
80
+		$this->_wp_post_stati = $wp_post_statuses;
81 81
 
82
-        foreach ($this->_wp_post_stati as $post_status => $args_object) {
83
-            $this->_allowed_enum_values[ $post_status ] = $args_object->label;
84
-        }
85
-    }
82
+		foreach ($this->_wp_post_stati as $post_status => $args_object) {
83
+			$this->_allowed_enum_values[ $post_status ] = $args_object->label;
84
+		}
85
+	}
86 86
 
87
-    /**
88
-     * Before calling parent, first double-checks our list of acceptable post
89
-     * types is up-to-date
90
-     *
91
-     * @param string $value_inputted_for_field_on_model_object
92
-     * @return string
93
-     */
94
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
95
-    {
96
-        $this->_set_allowed_enum_values();
97
-        return parent::prepare_for_set($value_inputted_for_field_on_model_object);
98
-    }
87
+	/**
88
+	 * Before calling parent, first double-checks our list of acceptable post
89
+	 * types is up-to-date
90
+	 *
91
+	 * @param string $value_inputted_for_field_on_model_object
92
+	 * @return string
93
+	 */
94
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
95
+	{
96
+		$this->_set_allowed_enum_values();
97
+		return parent::prepare_for_set($value_inputted_for_field_on_model_object);
98
+	}
99 99
 
100 100
 
101 101
 
102
-    // helper methods for getting various $wp_post_statuses stuff.
102
+	// helper methods for getting various $wp_post_statuses stuff.
103 103
 
104
-    /**
105
-     * This just returns the status object for the given status
106
-     *
107
-     * @access public
108
-     * @see    wp_register_post_status in wp-includes/post.php for a list of properties of the status object
109
-     * @param  string $status What status object you want
110
-     * @return std_object         the status object or FALSE if it doesn't exist.
111
-     */
112
-    public function get_status_object($status)
113
-    {
114
-        return isset($this->_wp_post_stati[ $status ]) ? $this->_wp_post_stati[ $status ] : false;
115
-    }
104
+	/**
105
+	 * This just returns the status object for the given status
106
+	 *
107
+	 * @access public
108
+	 * @see    wp_register_post_status in wp-includes/post.php for a list of properties of the status object
109
+	 * @param  string $status What status object you want
110
+	 * @return std_object         the status object or FALSE if it doesn't exist.
111
+	 */
112
+	public function get_status_object($status)
113
+	{
114
+		return isset($this->_wp_post_stati[ $status ]) ? $this->_wp_post_stati[ $status ] : false;
115
+	}
116 116
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Price.model.php 2 patches
Indentation   +351 added lines, -351 removed lines patch added patch discarded remove patch
@@ -13,382 +13,382 @@
 block discarded – undo
13 13
 class EEM_Price extends EEM_Soft_Delete_Base
14 14
 {
15 15
 
16
-    /**
17
-     * @var EEM_Price
18
-     */
19
-    protected static $_instance;
16
+	/**
17
+	 * @var EEM_Price
18
+	 */
19
+	protected static $_instance;
20 20
 
21 21
 
22
-    /**
23
-     * private constructor to prevent direct creation
24
-     *
25
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
26
-     *                         (and any incoming timezone data that gets saved).
27
-     *                         Note this just sends the timezone info to the date time model field objects.
28
-     *                         Default is NULL
29
-     *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
30
-     * @throws EE_Error
31
-     */
32
-    protected function __construct(string $timezone = '')
33
-    {
34
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
35
-        $this->singular_item = esc_html__('Price', 'event_espresso');
36
-        $this->plural_item   = esc_html__('Prices', 'event_espresso');
22
+	/**
23
+	 * private constructor to prevent direct creation
24
+	 *
25
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
26
+	 *                         (and any incoming timezone data that gets saved).
27
+	 *                         Note this just sends the timezone info to the date time model field objects.
28
+	 *                         Default is NULL
29
+	 *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
30
+	 * @throws EE_Error
31
+	 */
32
+	protected function __construct(string $timezone = '')
33
+	{
34
+		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
35
+		$this->singular_item = esc_html__('Price', 'event_espresso');
36
+		$this->plural_item   = esc_html__('Prices', 'event_espresso');
37 37
 
38
-        $this->_tables          = [
39
-            'Price' => new EE_Primary_Table('esp_price', 'PRC_ID'),
40
-        ];
41
-        $this->_fields          = [
42
-            'Price' => [
43
-                'PRC_ID'         => new EE_Primary_Key_Int_Field(
44
-                    'PRC_ID',
45
-                    'Price ID'
46
-                ),
47
-                'PRT_ID'         => new EE_Foreign_Key_Int_Field(
48
-                    'PRT_ID',
49
-                    esc_html__('Price type Id', 'event_espresso'),
50
-                    false,
51
-                    null,
52
-                    'Price_Type'
53
-                ),
54
-                'PRC_amount'     => new EE_Money_Field(
55
-                    'PRC_amount',
56
-                    esc_html__('Price Amount', 'event_espresso'),
57
-                    false,
58
-                    0
59
-                ),
60
-                'PRC_name'       => new EE_Plain_Text_Field(
61
-                    'PRC_name',
62
-                    esc_html__('Name of Price', 'event_espresso'),
63
-                    false,
64
-                    ''
65
-                ),
66
-                'PRC_desc'       => new EE_Post_Content_Field(
67
-                    'PRC_desc',
68
-                    esc_html__('Price Description', 'event_espresso'),
69
-                    false,
70
-                    ''
71
-                ),
72
-                'PRC_is_default' => new EE_Boolean_Field(
73
-                    'PRC_is_default',
74
-                    esc_html__('Flag indicating whether price is a default price', 'event_espresso'),
75
-                    false,
76
-                    false
77
-                ),
78
-                'PRC_overrides'  => new EE_Integer_Field(
79
-                    'PRC_overrides',
80
-                    esc_html__(
81
-                        'Price ID for a global Price that will be overridden by this Price  ( for replacing default prices )',
82
-                        'event_espresso'
83
-                    ),
84
-                    true,
85
-                    0
86
-                ),
87
-                'PRC_order'      => new EE_Integer_Field(
88
-                    'PRC_order',
89
-                    esc_html__(
90
-                        'Order of Application of Price (lower numbers apply first?)',
91
-                        'event_espresso'
92
-                    ),
93
-                    false,
94
-                    1
95
-                ),
96
-                'PRC_deleted'    => new EE_Trashed_Flag_Field(
97
-                    'PRC_deleted',
98
-                    esc_html__('Flag Indicating if this has been deleted or not', 'event_espresso'),
99
-                    false,
100
-                    false
101
-                ),
102
-                'PRC_parent'     => new EE_Integer_Field(
103
-                    'PRC_parent',
104
-                    esc_html__('Indicates what PRC_ID is the parent of this PRC_ID', 'event_espresso'),
105
-                    true,
106
-                    0
107
-                ),
108
-                'PRC_wp_user'    => new EE_WP_User_Field(
109
-                    'PRC_wp_user',
110
-                    esc_html__('Price Creator ID', 'event_espresso'),
111
-                    false
112
-                ),
113
-            ],
114
-        ];
115
-        $this->_model_relations = [
116
-            'Ticket'     => new EE_HABTM_Relation('Ticket_Price'),
117
-            'Price_Type' => new EE_Belongs_To_Relation(),
118
-            'WP_User'    => new EE_Belongs_To_Relation(),
119
-        ];
120
-        // this model is generally available for reading
121
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]
122
-            = new EE_Restriction_Generator_Default_Public(
123
-            'PRC_is_default',
124
-            'Ticket.Datetime.Event'
125
-        );
126
-        // account for default tickets in the caps
127
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ]
128
-            = new EE_Restriction_Generator_Default_Protected(
129
-            'PRC_is_default',
130
-            'Ticket.Datetime.Event'
131
-        );
132
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]
133
-            = new EE_Restriction_Generator_Default_Protected(
134
-            'PRC_is_default',
135
-            'Ticket.Datetime.Event'
136
-        );
137
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]
138
-            = new EE_Restriction_Generator_Default_Protected(
139
-            'PRC_is_default',
140
-            'Ticket.Datetime.Event'
141
-        );
142
-        parent::__construct($timezone);
143
-    }
38
+		$this->_tables          = [
39
+			'Price' => new EE_Primary_Table('esp_price', 'PRC_ID'),
40
+		];
41
+		$this->_fields          = [
42
+			'Price' => [
43
+				'PRC_ID'         => new EE_Primary_Key_Int_Field(
44
+					'PRC_ID',
45
+					'Price ID'
46
+				),
47
+				'PRT_ID'         => new EE_Foreign_Key_Int_Field(
48
+					'PRT_ID',
49
+					esc_html__('Price type Id', 'event_espresso'),
50
+					false,
51
+					null,
52
+					'Price_Type'
53
+				),
54
+				'PRC_amount'     => new EE_Money_Field(
55
+					'PRC_amount',
56
+					esc_html__('Price Amount', 'event_espresso'),
57
+					false,
58
+					0
59
+				),
60
+				'PRC_name'       => new EE_Plain_Text_Field(
61
+					'PRC_name',
62
+					esc_html__('Name of Price', 'event_espresso'),
63
+					false,
64
+					''
65
+				),
66
+				'PRC_desc'       => new EE_Post_Content_Field(
67
+					'PRC_desc',
68
+					esc_html__('Price Description', 'event_espresso'),
69
+					false,
70
+					''
71
+				),
72
+				'PRC_is_default' => new EE_Boolean_Field(
73
+					'PRC_is_default',
74
+					esc_html__('Flag indicating whether price is a default price', 'event_espresso'),
75
+					false,
76
+					false
77
+				),
78
+				'PRC_overrides'  => new EE_Integer_Field(
79
+					'PRC_overrides',
80
+					esc_html__(
81
+						'Price ID for a global Price that will be overridden by this Price  ( for replacing default prices )',
82
+						'event_espresso'
83
+					),
84
+					true,
85
+					0
86
+				),
87
+				'PRC_order'      => new EE_Integer_Field(
88
+					'PRC_order',
89
+					esc_html__(
90
+						'Order of Application of Price (lower numbers apply first?)',
91
+						'event_espresso'
92
+					),
93
+					false,
94
+					1
95
+				),
96
+				'PRC_deleted'    => new EE_Trashed_Flag_Field(
97
+					'PRC_deleted',
98
+					esc_html__('Flag Indicating if this has been deleted or not', 'event_espresso'),
99
+					false,
100
+					false
101
+				),
102
+				'PRC_parent'     => new EE_Integer_Field(
103
+					'PRC_parent',
104
+					esc_html__('Indicates what PRC_ID is the parent of this PRC_ID', 'event_espresso'),
105
+					true,
106
+					0
107
+				),
108
+				'PRC_wp_user'    => new EE_WP_User_Field(
109
+					'PRC_wp_user',
110
+					esc_html__('Price Creator ID', 'event_espresso'),
111
+					false
112
+				),
113
+			],
114
+		];
115
+		$this->_model_relations = [
116
+			'Ticket'     => new EE_HABTM_Relation('Ticket_Price'),
117
+			'Price_Type' => new EE_Belongs_To_Relation(),
118
+			'WP_User'    => new EE_Belongs_To_Relation(),
119
+		];
120
+		// this model is generally available for reading
121
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ]
122
+			= new EE_Restriction_Generator_Default_Public(
123
+			'PRC_is_default',
124
+			'Ticket.Datetime.Event'
125
+		);
126
+		// account for default tickets in the caps
127
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ]
128
+			= new EE_Restriction_Generator_Default_Protected(
129
+			'PRC_is_default',
130
+			'Ticket.Datetime.Event'
131
+		);
132
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ]
133
+			= new EE_Restriction_Generator_Default_Protected(
134
+			'PRC_is_default',
135
+			'Ticket.Datetime.Event'
136
+		);
137
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ]
138
+			= new EE_Restriction_Generator_Default_Protected(
139
+			'PRC_is_default',
140
+			'Ticket.Datetime.Event'
141
+		);
142
+		parent::__construct($timezone);
143
+	}
144 144
 
145 145
 
146
-    /**
147
-     * instantiate a new price object with blank/empty properties
148
-     *
149
-     * @return EE_Price
150
-     * @throws EE_Error
151
-     * @throws ReflectionException
152
-     */
153
-    public function get_new_price(): EE_Price
154
-    {
155
-        return $this->create_default_object();
156
-    }
146
+	/**
147
+	 * instantiate a new price object with blank/empty properties
148
+	 *
149
+	 * @return EE_Price
150
+	 * @throws EE_Error
151
+	 * @throws ReflectionException
152
+	 */
153
+	public function get_new_price(): EE_Price
154
+	{
155
+		return $this->create_default_object();
156
+	}
157 157
 
158 158
 
159
-    /**
160
-     * retrieve  ALL prices from db
161
-     *
162
-     * @return EE_Price[]
163
-     * @throws EE_Error
164
-     * @throws ReflectionException
165
-     */
166
-    public function get_all_prices(): array
167
-    {
168
-        // retrieve all prices
169
-        return $this->get_all(['order_by' => ['PRC_amount' => 'ASC']]);
170
-    }
159
+	/**
160
+	 * retrieve  ALL prices from db
161
+	 *
162
+	 * @return EE_Price[]
163
+	 * @throws EE_Error
164
+	 * @throws ReflectionException
165
+	 */
166
+	public function get_all_prices(): array
167
+	{
168
+		// retrieve all prices
169
+		return $this->get_all(['order_by' => ['PRC_amount' => 'ASC']]);
170
+	}
171 171
 
172 172
 
173
-    /**
174
-     * retrieve all active prices for a particular event
175
-     *
176
-     * @param int $EVT_ID
177
-     * @return array on success
178
-     * @throws EE_Error
179
-     * @throws ReflectionException
180
-     */
181
-    public function get_all_event_prices(int $EVT_ID = 0): array
182
-    {
183
-        return $this->get_all(
184
-            [
185
-                [
186
-                    'EVT_ID'            => $EVT_ID,
187
-                    'Price_Type.PBT_ID' => ['!=', EEM_Price_Type::base_type_tax],
188
-                ],
189
-                'order_by' => $this->_order_by_array_for_get_all_method(),
190
-            ]
191
-        );
192
-    }
173
+	/**
174
+	 * retrieve all active prices for a particular event
175
+	 *
176
+	 * @param int $EVT_ID
177
+	 * @return array on success
178
+	 * @throws EE_Error
179
+	 * @throws ReflectionException
180
+	 */
181
+	public function get_all_event_prices(int $EVT_ID = 0): array
182
+	{
183
+		return $this->get_all(
184
+			[
185
+				[
186
+					'EVT_ID'            => $EVT_ID,
187
+					'Price_Type.PBT_ID' => ['!=', EEM_Price_Type::base_type_tax],
188
+				],
189
+				'order_by' => $this->_order_by_array_for_get_all_method(),
190
+			]
191
+		);
192
+	}
193 193
 
194 194
 
195
-    /**
196
-     * retrieve all active global prices (that are not taxes (PBT_ID=4)) for a particular event
197
-     *
198
-     * @param boolean $count return count
199
-     * @param bool    $include_taxes
200
-     * @return int|EE_Price[]
201
-     * @throws EE_Error
202
-     * @throws ReflectionException
203
-     */
204
-    public function get_all_default_prices(bool $count = false, bool $include_taxes = false)
205
-    {
206
-        $_where = [
207
-            'PRC_deleted'    => 0,
208
-            'PRC_is_default' => 1,
209
-        ];
210
-        if (! $include_taxes) {
211
-            $_where['Price_Type.PBT_ID'] = ['!=', 4];
212
-        }
213
-        $_query_params = [
214
-            $_where,
215
-            'order_by' => $this->_order_by_array_for_get_all_method(),
216
-        ];
217
-        return $count ? $this->count([$_where]) : $this->get_all($_query_params);
218
-    }
195
+	/**
196
+	 * retrieve all active global prices (that are not taxes (PBT_ID=4)) for a particular event
197
+	 *
198
+	 * @param boolean $count return count
199
+	 * @param bool    $include_taxes
200
+	 * @return int|EE_Price[]
201
+	 * @throws EE_Error
202
+	 * @throws ReflectionException
203
+	 */
204
+	public function get_all_default_prices(bool $count = false, bool $include_taxes = false)
205
+	{
206
+		$_where = [
207
+			'PRC_deleted'    => 0,
208
+			'PRC_is_default' => 1,
209
+		];
210
+		if (! $include_taxes) {
211
+			$_where['Price_Type.PBT_ID'] = ['!=', 4];
212
+		}
213
+		$_query_params = [
214
+			$_where,
215
+			'order_by' => $this->_order_by_array_for_get_all_method(),
216
+		];
217
+		return $count ? $this->count([$_where]) : $this->get_all($_query_params);
218
+	}
219 219
 
220 220
 
221
-    /**
222
-     * retrieve all active global prices that are taxes
223
-     *
224
-     * @return EE_Price[]
225
-     * @throws EE_Error
226
-     * @throws ReflectionException
227
-     * @since   $VID:$
228
-     */
229
-    public function getAllDefaultTaxes(): array
230
-    {
231
-        return $this->get_all(
232
-            [
233
-                [
234
-                    'PRC_deleted'       => 0,
235
-                    'PRC_is_default'    => 1,
236
-                    'Price_Type.PBT_ID' => EEM_Price_Type::base_type_tax,
237
-                ],
238
-                'order_by' => [
239
-                    'Price_Type.PRT_order' => 'ASC',
240
-                    'PRC_order'            => 'ASC',
241
-                ],
242
-            ]
243
-        );
244
-    }
221
+	/**
222
+	 * retrieve all active global prices that are taxes
223
+	 *
224
+	 * @return EE_Price[]
225
+	 * @throws EE_Error
226
+	 * @throws ReflectionException
227
+	 * @since   $VID:$
228
+	 */
229
+	public function getAllDefaultTaxes(): array
230
+	{
231
+		return $this->get_all(
232
+			[
233
+				[
234
+					'PRC_deleted'       => 0,
235
+					'PRC_is_default'    => 1,
236
+					'Price_Type.PBT_ID' => EEM_Price_Type::base_type_tax,
237
+				],
238
+				'order_by' => [
239
+					'Price_Type.PRT_order' => 'ASC',
240
+					'PRC_order'            => 'ASC',
241
+				],
242
+			]
243
+		);
244
+	}
245 245
 
246 246
 
247
-    /**
248
-     * retrieve all prices that are taxes
249
-     *
250
-     * @return EE_Price[]
251
-     * @throws EE_Error
252
-     * @throws InvalidArgumentException
253
-     * @throws ReflectionException
254
-     * @throws InvalidDataTypeException
255
-     * @throws InvalidInterfaceException
256
-     */
257
-    public function get_all_prices_that_are_taxes(): array
258
-    {
259
-        $taxes     = [];
260
-        $all_taxes = $this->get_all(
261
-            [
262
-                ['Price_Type.PBT_ID' => EEM_Price_Type::base_type_tax],
263
-                'order_by' => ['Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC'],
264
-            ]
265
-        );
266
-        foreach ($all_taxes as $tax) {
267
-            if ($tax instanceof EE_Price) {
268
-                $taxes[ $tax->order() ][ $tax->ID() ] = $tax;
269
-            }
270
-        }
271
-        return $taxes;
272
-    }
247
+	/**
248
+	 * retrieve all prices that are taxes
249
+	 *
250
+	 * @return EE_Price[]
251
+	 * @throws EE_Error
252
+	 * @throws InvalidArgumentException
253
+	 * @throws ReflectionException
254
+	 * @throws InvalidDataTypeException
255
+	 * @throws InvalidInterfaceException
256
+	 */
257
+	public function get_all_prices_that_are_taxes(): array
258
+	{
259
+		$taxes     = [];
260
+		$all_taxes = $this->get_all(
261
+			[
262
+				['Price_Type.PBT_ID' => EEM_Price_Type::base_type_tax],
263
+				'order_by' => ['Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC'],
264
+			]
265
+		);
266
+		foreach ($all_taxes as $tax) {
267
+			if ($tax instanceof EE_Price) {
268
+				$taxes[ $tax->order() ][ $tax->ID() ] = $tax;
269
+			}
270
+		}
271
+		return $taxes;
272
+	}
273 273
 
274 274
 
275
-    /**
276
-     * retrieve all prices for an ticket plus default global prices, but not taxes
277
-     *
278
-     * @param int $TKT_ID the id of the event.  If not included then we assume that this is a new ticket.
279
-     * @return EE_Price[]
280
-     * @throws EE_Error
281
-     * @throws ReflectionException
282
-     */
283
-    public function get_all_ticket_prices_for_admin(int $TKT_ID = 0): array
284
-    {
285
-        $array_of_price_objects = [];
286
-        if (empty($TKT_ID)) {
287
-            // if there is no tkt, get prices with no tkt ID, are global, are not a tax, and are active
288
-            // return that list
289
-            $default_prices = $this->get_all_default_prices();
275
+	/**
276
+	 * retrieve all prices for an ticket plus default global prices, but not taxes
277
+	 *
278
+	 * @param int $TKT_ID the id of the event.  If not included then we assume that this is a new ticket.
279
+	 * @return EE_Price[]
280
+	 * @throws EE_Error
281
+	 * @throws ReflectionException
282
+	 */
283
+	public function get_all_ticket_prices_for_admin(int $TKT_ID = 0): array
284
+	{
285
+		$array_of_price_objects = [];
286
+		if (empty($TKT_ID)) {
287
+			// if there is no tkt, get prices with no tkt ID, are global, are not a tax, and are active
288
+			// return that list
289
+			$default_prices = $this->get_all_default_prices();
290 290
 
291
-            if ($default_prices) {
292
-                foreach ($default_prices as $price) {
293
-                    if ($price instanceof EE_Price) {
294
-                        $array_of_price_objects[ $price->type() ][] = $price;
295
-                    }
296
-                }
297
-                return $array_of_price_objects;
298
-            }
299
-            return [];
300
-        }
301
-        $ticket_prices = $this->get_all(
302
-            [
303
-                [
304
-                    'TKT_ID'      => $TKT_ID,
305
-                    'PRC_deleted' => 0,
306
-                ],
307
-                'order_by' => ['PRC_order' => 'ASC'],
308
-            ]
309
-        );
291
+			if ($default_prices) {
292
+				foreach ($default_prices as $price) {
293
+					if ($price instanceof EE_Price) {
294
+						$array_of_price_objects[ $price->type() ][] = $price;
295
+					}
296
+				}
297
+				return $array_of_price_objects;
298
+			}
299
+			return [];
300
+		}
301
+		$ticket_prices = $this->get_all(
302
+			[
303
+				[
304
+					'TKT_ID'      => $TKT_ID,
305
+					'PRC_deleted' => 0,
306
+				],
307
+				'order_by' => ['PRC_order' => 'ASC'],
308
+			]
309
+		);
310 310
 
311
-        if (! empty($ticket_prices)) {
312
-            foreach ($ticket_prices as $price) {
313
-                if ($price instanceof EE_Price) {
314
-                    $array_of_price_objects[ $price->type() ][] = $price;
315
-                }
316
-            }
317
-        }
318
-        return $array_of_price_objects;
319
-    }
311
+		if (! empty($ticket_prices)) {
312
+			foreach ($ticket_prices as $price) {
313
+				if ($price instanceof EE_Price) {
314
+					$array_of_price_objects[ $price->type() ][] = $price;
315
+				}
316
+			}
317
+		}
318
+		return $array_of_price_objects;
319
+	}
320 320
 
321 321
 
322
-    /**
323
-     * _sort_event_prices_by_type
324
-     *
325
-     * @param EE_Price $price_a
326
-     * @param EE_Price $price_b
327
-     * @return int
328
-     * @throws EE_Error
329
-     * @throws ReflectionException
330
-     */
331
-    public function _sort_event_prices_by_type(EE_Price $price_a, EE_Price $price_b): int
332
-    {
333
-        if ($price_a->type_obj()->order() === $price_b->type_obj()->order()) {
334
-            return $this->_sort_event_prices_by_order($price_a, $price_b);
335
-        }
336
-        return $price_a->type_obj()->order() < $price_b->type_obj()->order() ? -1 : 1;
337
-    }
322
+	/**
323
+	 * _sort_event_prices_by_type
324
+	 *
325
+	 * @param EE_Price $price_a
326
+	 * @param EE_Price $price_b
327
+	 * @return int
328
+	 * @throws EE_Error
329
+	 * @throws ReflectionException
330
+	 */
331
+	public function _sort_event_prices_by_type(EE_Price $price_a, EE_Price $price_b): int
332
+	{
333
+		if ($price_a->type_obj()->order() === $price_b->type_obj()->order()) {
334
+			return $this->_sort_event_prices_by_order($price_a, $price_b);
335
+		}
336
+		return $price_a->type_obj()->order() < $price_b->type_obj()->order() ? -1 : 1;
337
+	}
338 338
 
339 339
 
340
-    /**
341
-     *        _sort_event_prices_by_order
342
-     *
343
-     * @param EE_Price $price_a
344
-     * @param EE_Price $price_b
345
-     * @return int
346
-     * @throws EE_Error
347
-     * @throws ReflectionException
348
-     */
349
-    public function _sort_event_prices_by_order(EE_Price $price_a, EE_Price $price_b): int
350
-    {
351
-        if ($price_a->order() === $price_b->order()) {
352
-            return 0;
353
-        }
354
-        return $price_a->order() < $price_b->order() ? -1 : 1;
355
-    }
340
+	/**
341
+	 *        _sort_event_prices_by_order
342
+	 *
343
+	 * @param EE_Price $price_a
344
+	 * @param EE_Price $price_b
345
+	 * @return int
346
+	 * @throws EE_Error
347
+	 * @throws ReflectionException
348
+	 */
349
+	public function _sort_event_prices_by_order(EE_Price $price_a, EE_Price $price_b): int
350
+	{
351
+		if ($price_a->order() === $price_b->order()) {
352
+			return 0;
353
+		}
354
+		return $price_a->order() < $price_b->order() ? -1 : 1;
355
+	}
356 356
 
357 357
 
358
-    /**
359
-     * get all prices of a specific type
360
-     *
361
-     * @param int $PRT_ID - PRT_ID
362
-     * @return EE_Price[]
363
-     * @throws EE_Error
364
-     * @throws ReflectionException
365
-     */
366
-    public function get_all_prices_that_are_type(int $PRT_ID): array
367
-    {
368
-        return $this->get_all(
369
-            [
370
-                [
371
-                    'PRT_ID' => $PRT_ID,
372
-                ],
373
-                'order_by' => $this->_order_by_array_for_get_all_method(),
374
-            ]
375
-        );
376
-    }
358
+	/**
359
+	 * get all prices of a specific type
360
+	 *
361
+	 * @param int $PRT_ID - PRT_ID
362
+	 * @return EE_Price[]
363
+	 * @throws EE_Error
364
+	 * @throws ReflectionException
365
+	 */
366
+	public function get_all_prices_that_are_type(int $PRT_ID): array
367
+	{
368
+		return $this->get_all(
369
+			[
370
+				[
371
+					'PRT_ID' => $PRT_ID,
372
+				],
373
+				'order_by' => $this->_order_by_array_for_get_all_method(),
374
+			]
375
+		);
376
+	}
377 377
 
378 378
 
379
-    /**
380
-     * Returns an array of the normal 'order_by' query parameter provided to the get_all query.
381
-     * Of course you don't have to use it, but this is the order we usually want to sort prices by
382
-     *
383
-     * @return array which can be used like so: $this->get_all(array(array(...where
384
-     *               stuff...),'order_by'=>$this->_order_by_array_for_get_all_method()));
385
-     */
386
-    public function _order_by_array_for_get_all_method(): array
387
-    {
388
-        return [
389
-            'PRC_order'            => 'ASC',
390
-            'Price_Type.PRT_order' => 'ASC',
391
-            'PRC_ID'               => 'ASC',
392
-        ];
393
-    }
379
+	/**
380
+	 * Returns an array of the normal 'order_by' query parameter provided to the get_all query.
381
+	 * Of course you don't have to use it, but this is the order we usually want to sort prices by
382
+	 *
383
+	 * @return array which can be used like so: $this->get_all(array(array(...where
384
+	 *               stuff...),'order_by'=>$this->_order_by_array_for_get_all_method()));
385
+	 */
386
+	public function _order_by_array_for_get_all_method(): array
387
+	{
388
+		return [
389
+			'PRC_order'            => 'ASC',
390
+			'Price_Type.PRT_order' => 'ASC',
391
+			'PRC_ID'               => 'ASC',
392
+		];
393
+	}
394 394
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      */
32 32
     protected function __construct(string $timezone = '')
33 33
     {
34
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
34
+        require_once(EE_MODELS.'EEM_Price_Type.model.php');
35 35
         $this->singular_item = esc_html__('Price', 'event_espresso');
36 36
         $this->plural_item   = esc_html__('Prices', 'event_espresso');
37 37
 
@@ -118,23 +118,23 @@  discard block
 block discarded – undo
118 118
             'WP_User'    => new EE_Belongs_To_Relation(),
119 119
         ];
120 120
         // this model is generally available for reading
121
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]
121
+        $this->_cap_restriction_generators[EEM_Base::caps_read]
122 122
             = new EE_Restriction_Generator_Default_Public(
123 123
             'PRC_is_default',
124 124
             'Ticket.Datetime.Event'
125 125
         );
126 126
         // account for default tickets in the caps
127
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ]
127
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin]
128 128
             = new EE_Restriction_Generator_Default_Protected(
129 129
             'PRC_is_default',
130 130
             'Ticket.Datetime.Event'
131 131
         );
132
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]
132
+        $this->_cap_restriction_generators[EEM_Base::caps_edit]
133 133
             = new EE_Restriction_Generator_Default_Protected(
134 134
             'PRC_is_default',
135 135
             'Ticket.Datetime.Event'
136 136
         );
137
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]
137
+        $this->_cap_restriction_generators[EEM_Base::caps_delete]
138 138
             = new EE_Restriction_Generator_Default_Protected(
139 139
             'PRC_is_default',
140 140
             'Ticket.Datetime.Event'
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
             'PRC_deleted'    => 0,
208 208
             'PRC_is_default' => 1,
209 209
         ];
210
-        if (! $include_taxes) {
210
+        if ( ! $include_taxes) {
211 211
             $_where['Price_Type.PBT_ID'] = ['!=', 4];
212 212
         }
213 213
         $_query_params = [
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         );
266 266
         foreach ($all_taxes as $tax) {
267 267
             if ($tax instanceof EE_Price) {
268
-                $taxes[ $tax->order() ][ $tax->ID() ] = $tax;
268
+                $taxes[$tax->order()][$tax->ID()] = $tax;
269 269
             }
270 270
         }
271 271
         return $taxes;
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
             if ($default_prices) {
292 292
                 foreach ($default_prices as $price) {
293 293
                     if ($price instanceof EE_Price) {
294
-                        $array_of_price_objects[ $price->type() ][] = $price;
294
+                        $array_of_price_objects[$price->type()][] = $price;
295 295
                     }
296 296
                 }
297 297
                 return $array_of_price_objects;
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
             ]
309 309
         );
310 310
 
311
-        if (! empty($ticket_prices)) {
311
+        if ( ! empty($ticket_prices)) {
312 312
             foreach ($ticket_prices as $price) {
313 313
                 if ($price instanceof EE_Price) {
314
-                    $array_of_price_objects[ $price->type() ][] = $price;
314
+                    $array_of_price_objects[$price->type()][] = $price;
315 315
                 }
316 316
             }
317 317
         }
Please login to merge, or discard this patch.
core/db_models/EEM_Change_Log.model.php 2 patches
Indentation   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -10,99 +10,99 @@  discard block
 block discarded – undo
10 10
 class EEM_Change_Log extends EEM_Base
11 11
 {
12 12
 
13
-    /**
14
-     * the related object was created log type
15
-     */
16
-    const type_create = 'create';
13
+	/**
14
+	 * the related object was created log type
15
+	 */
16
+	const type_create = 'create';
17 17
 
18
-    /**
19
-     * the related object was updated (changed, or soft-deleted)
20
-     */
21
-    const type_update = 'update';
18
+	/**
19
+	 * the related object was updated (changed, or soft-deleted)
20
+	 */
21
+	const type_update = 'update';
22 22
 
23
-    /**
24
-     * the related object was deleted permanently
25
-     */
26
-    const type_delete = 'delete';
23
+	/**
24
+	 * the related object was deleted permanently
25
+	 */
26
+	const type_delete = 'delete';
27 27
 
28
-    /**
29
-     * the related item had something worth noting happen on it, but
30
-     * only for the purposes of debugging problems
31
-     */
32
-    const type_debug = 'debug';
28
+	/**
29
+	 * the related item had something worth noting happen on it, but
30
+	 * only for the purposes of debugging problems
31
+	 */
32
+	const type_debug = 'debug';
33 33
 
34
-    /**
35
-     * the related item had an error occur on it
36
-     */
37
-    const type_error = 'error';
34
+	/**
35
+	 * the related item had an error occur on it
36
+	 */
37
+	const type_error = 'error';
38 38
 
39
-    /**
40
-     * the related item is regarding some gateway interaction, like an IPN
41
-     * or request to process a payment
42
-     */
43
-    const type_gateway = 'gateway';
39
+	/**
40
+	 * the related item is regarding some gateway interaction, like an IPN
41
+	 * or request to process a payment
42
+	 */
43
+	const type_gateway = 'gateway';
44 44
 
45
-    /**
46
-     * private instance of the EEM_Change_Log object
47
-     *
48
-     * @access private
49
-     * @var EEM_Change_Log $_instance
50
-     */
51
-    protected static $_instance;
45
+	/**
46
+	 * private instance of the EEM_Change_Log object
47
+	 *
48
+	 * @access private
49
+	 * @var EEM_Change_Log $_instance
50
+	 */
51
+	protected static $_instance;
52 52
 
53 53
 
54
-    /**
55
-     * constructor
56
-     *
57
-     * @param string|null $timezone
58
-     * @throws EE_Error
59
-     */
60
-    protected function __construct(string $timezone = '')
61
-    {
62
-        $this->singular_item       = esc_html__('Log', 'event_espresso');
63
-        $this->plural_item         = esc_html__('Logs', 'event_espresso');
64
-        $this->_tables             = [
65
-            'Log' => new EE_Primary_Table('esp_log', 'LOG_ID'),
66
-        ];
67
-        $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models);
68
-        $this->_fields             = [
69
-            'Log' => [
70
-                'LOG_ID'      => new EE_Primary_Key_Int_Field(
71
-                    'LOG_ID',
72
-                    esc_html__('Log ID', 'event_espresso')
73
-                ),
74
-                'LOG_time'    => new EE_Datetime_Field(
75
-                    'LOG_time',
76
-                    esc_html__("Log Time", 'event_espresso'),
77
-                    false,
78
-                    EE_Datetime_Field::now
79
-                ),
80
-                'OBJ_ID'      => new EE_Foreign_Key_String_Field(
81
-                    'OBJ_ID',
82
-                    esc_html__("Object ID (int or string)", 'event_espresso'),
83
-                    true,
84
-                    null,
85
-                    $models_this_can_attach_to
86
-                ),
87
-                'OBJ_type'    => new EE_Any_Foreign_Model_Name_Field(
88
-                    'OBJ_type',
89
-                    esc_html__("Object Type", 'event_espresso'),
90
-                    true,
91
-                    null,
92
-                    $models_this_can_attach_to
93
-                ),
94
-                'LOG_type'    => new EE_Plain_Text_Field(
95
-                    'LOG_type',
96
-                    esc_html__("Type of log entry", "event_espresso"),
97
-                    false,
98
-                    self::type_debug
99
-                ),
100
-                'LOG_message' => new EE_Maybe_Serialized_Text_Field(
101
-                    'LOG_message',
102
-                    esc_html__("Log Message (body)", 'event_espresso'),
103
-                    true
104
-                ),
105
-                /*
54
+	/**
55
+	 * constructor
56
+	 *
57
+	 * @param string|null $timezone
58
+	 * @throws EE_Error
59
+	 */
60
+	protected function __construct(string $timezone = '')
61
+	{
62
+		$this->singular_item       = esc_html__('Log', 'event_espresso');
63
+		$this->plural_item         = esc_html__('Logs', 'event_espresso');
64
+		$this->_tables             = [
65
+			'Log' => new EE_Primary_Table('esp_log', 'LOG_ID'),
66
+		];
67
+		$models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models);
68
+		$this->_fields             = [
69
+			'Log' => [
70
+				'LOG_ID'      => new EE_Primary_Key_Int_Field(
71
+					'LOG_ID',
72
+					esc_html__('Log ID', 'event_espresso')
73
+				),
74
+				'LOG_time'    => new EE_Datetime_Field(
75
+					'LOG_time',
76
+					esc_html__("Log Time", 'event_espresso'),
77
+					false,
78
+					EE_Datetime_Field::now
79
+				),
80
+				'OBJ_ID'      => new EE_Foreign_Key_String_Field(
81
+					'OBJ_ID',
82
+					esc_html__("Object ID (int or string)", 'event_espresso'),
83
+					true,
84
+					null,
85
+					$models_this_can_attach_to
86
+				),
87
+				'OBJ_type'    => new EE_Any_Foreign_Model_Name_Field(
88
+					'OBJ_type',
89
+					esc_html__("Object Type", 'event_espresso'),
90
+					true,
91
+					null,
92
+					$models_this_can_attach_to
93
+				),
94
+				'LOG_type'    => new EE_Plain_Text_Field(
95
+					'LOG_type',
96
+					esc_html__("Type of log entry", "event_espresso"),
97
+					false,
98
+					self::type_debug
99
+				),
100
+				'LOG_message' => new EE_Maybe_Serialized_Text_Field(
101
+					'LOG_message',
102
+					esc_html__("Log Message (body)", 'event_espresso'),
103
+					true
104
+				),
105
+				/*
106 106
                  * Note: when querying for a change log's user, the OBJ_ID and OBJ_type fields are used,
107 107
                  * not the LOG_wp_user field. E.g.,
108 108
                  * `EEM_Change_Log::instance()->get_all(array(array('WP_User.ID'=>1)))` will actually return
@@ -111,164 +111,164 @@  discard block
 block discarded – undo
111 111
                  *  If you want the latter, you can't use the model's magic joining. E.g, you would need to do
112 112
                  * `EEM_Change_Log::instance()->get_all(array(array('LOG_wp_user' => 1)))`.
113 113
                  */
114
-                'LOG_wp_user' => new EE_WP_User_Field(
115
-                    'LOG_wp_user',
116
-                    esc_html__("User who was logged in while this occurred", 'event_espresso'),
117
-                    true
118
-                ),
119
-            ],
120
-        ];
121
-        $this->_model_relations    = [];
122
-        foreach ($models_this_can_attach_to as $model) {
123
-            if ($model != 'Change_Log') {
124
-                $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
125
-            }
126
-        }
127
-        // use completely custom caps for this
128
-        $this->_cap_restriction_generators = false;
129
-        // caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing
130
-        foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) {
131
-            $this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ]
132
-                = new EE_Return_None_Where_Conditions();
133
-        }
134
-        parent::__construct($timezone);
135
-    }
114
+				'LOG_wp_user' => new EE_WP_User_Field(
115
+					'LOG_wp_user',
116
+					esc_html__("User who was logged in while this occurred", 'event_espresso'),
117
+					true
118
+				),
119
+			],
120
+		];
121
+		$this->_model_relations    = [];
122
+		foreach ($models_this_can_attach_to as $model) {
123
+			if ($model != 'Change_Log') {
124
+				$this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
125
+			}
126
+		}
127
+		// use completely custom caps for this
128
+		$this->_cap_restriction_generators = false;
129
+		// caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing
130
+		foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) {
131
+			$this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ]
132
+				= new EE_Return_None_Where_Conditions();
133
+		}
134
+		parent::__construct($timezone);
135
+	}
136 136
 
137 137
 
138
-    /**
139
-     * @param string        $log_type !see the acceptable values of LOG_type in EEM__Change_Log::__construct
140
-     * @param mixed         $message  array|string of the message you want to record
141
-     * @param EE_Base_Class $related_model_obj
142
-     * @return EE_Change_Log
143
-     * @throws EE_Error
144
-     * @throws ReflectionException
145
-     */
146
-    public function log(string $log_type, $message, EE_Base_Class $related_model_obj): EE_Change_Log
147
-    {
148
-        if ($related_model_obj instanceof EE_Base_Class) {
149
-            $obj_id   = $related_model_obj->ID();
150
-            $obj_type = $related_model_obj->get_model()->get_this_model_name();
151
-        } else {
152
-            $obj_id   = null;
153
-            $obj_type = null;
154
-        }
155
-        $log = EE_Change_Log::new_instance(
156
-            [
157
-                'LOG_type'    => $log_type,
158
-                'LOG_message' => $message,
159
-                'OBJ_ID'      => $obj_id,
160
-                'OBJ_type'    => $obj_type,
161
-            ]
162
-        );
163
-        $log->save();
164
-        return $log;
165
-    }
138
+	/**
139
+	 * @param string        $log_type !see the acceptable values of LOG_type in EEM__Change_Log::__construct
140
+	 * @param mixed         $message  array|string of the message you want to record
141
+	 * @param EE_Base_Class $related_model_obj
142
+	 * @return EE_Change_Log
143
+	 * @throws EE_Error
144
+	 * @throws ReflectionException
145
+	 */
146
+	public function log(string $log_type, $message, EE_Base_Class $related_model_obj): EE_Change_Log
147
+	{
148
+		if ($related_model_obj instanceof EE_Base_Class) {
149
+			$obj_id   = $related_model_obj->ID();
150
+			$obj_type = $related_model_obj->get_model()->get_this_model_name();
151
+		} else {
152
+			$obj_id   = null;
153
+			$obj_type = null;
154
+		}
155
+		$log = EE_Change_Log::new_instance(
156
+			[
157
+				'LOG_type'    => $log_type,
158
+				'LOG_message' => $message,
159
+				'OBJ_ID'      => $obj_id,
160
+				'OBJ_type'    => $obj_type,
161
+			]
162
+		);
163
+		$log->save();
164
+		return $log;
165
+	}
166 166
 
167 167
 
168
-    /**
169
-     * Adds a gateway log for the specified object, given its ID and type
170
-     *
171
-     * @param string $message
172
-     * @param mixed  $related_obj_id
173
-     * @param string $related_obj_type
174
-     * @return EE_Change_Log
175
-     * @throws EE_Error
176
-     * @throws ReflectionException
177
-     */
178
-    public function gateway_log(string $message, $related_obj_id, string $related_obj_type): EE_Change_Log
179
-    {
180
-        if (! EE_Registry::instance()->is_model_name($related_obj_type)) {
181
-            throw new EE_Error(
182
-                sprintf(
183
-                    esc_html__(
184
-                        "'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc",
185
-                        "event_espresso"
186
-                    ),
187
-                    $related_obj_type
188
-                )
189
-            );
190
-        }
191
-        $log = EE_Change_Log::new_instance(
192
-            [
193
-                'LOG_type'    => EEM_Change_Log::type_gateway,
194
-                'LOG_message' => $message,
195
-                'OBJ_ID'      => $related_obj_id,
196
-                'OBJ_type'    => $related_obj_type,
197
-            ]
198
-        );
199
-        $log->save();
200
-        return $log;
201
-    }
168
+	/**
169
+	 * Adds a gateway log for the specified object, given its ID and type
170
+	 *
171
+	 * @param string $message
172
+	 * @param mixed  $related_obj_id
173
+	 * @param string $related_obj_type
174
+	 * @return EE_Change_Log
175
+	 * @throws EE_Error
176
+	 * @throws ReflectionException
177
+	 */
178
+	public function gateway_log(string $message, $related_obj_id, string $related_obj_type): EE_Change_Log
179
+	{
180
+		if (! EE_Registry::instance()->is_model_name($related_obj_type)) {
181
+			throw new EE_Error(
182
+				sprintf(
183
+					esc_html__(
184
+						"'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc",
185
+						"event_espresso"
186
+					),
187
+					$related_obj_type
188
+				)
189
+			);
190
+		}
191
+		$log = EE_Change_Log::new_instance(
192
+			[
193
+				'LOG_type'    => EEM_Change_Log::type_gateway,
194
+				'LOG_message' => $message,
195
+				'OBJ_ID'      => $related_obj_id,
196
+				'OBJ_type'    => $related_obj_type,
197
+			]
198
+		);
199
+		$log->save();
200
+		return $log;
201
+	}
202 202
 
203 203
 
204
-    /**
205
-     * Just gets the bare-bones wpdb results as an array in cases where efficiency is essential
206
-     *
207
-     * @param array $query_params
208
-     * @return array of arrays
209
-     * @throws EE_Error
210
-     * @throws ReflectionException
211
-     * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
212
-     */
213
-    public function get_all_efficiently(array $query_params): array
214
-    {
215
-        return $this->_get_all_wpdb_results($query_params);
216
-    }
204
+	/**
205
+	 * Just gets the bare-bones wpdb results as an array in cases where efficiency is essential
206
+	 *
207
+	 * @param array $query_params
208
+	 * @return array of arrays
209
+	 * @throws EE_Error
210
+	 * @throws ReflectionException
211
+	 * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
212
+	 */
213
+	public function get_all_efficiently(array $query_params): array
214
+	{
215
+		return $this->_get_all_wpdb_results($query_params);
216
+	}
217 217
 
218 218
 
219
-    /**
220
-     * Executes a database query to delete gateway logs. Does not affect model objects, so if you attempt to use
221
-     * models after this, they may be out-of-sync with the database
222
-     *
223
-     * @param DateTime $datetime
224
-     * @return false|int
225
-     * @throws EE_Error
226
-     */
227
-    public function delete_gateway_logs_older_than(DateTime $datetime)
228
-    {
229
-        global $wpdb;
230
-        return $wpdb->query(
231
-            $wpdb->prepare(
232
-                'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s',
233
-                EEM_Change_Log::type_gateway,
234
-                $datetime->format(EE_Datetime_Field::mysql_timestamp_format)
235
-            )
236
-        );
237
-    }
219
+	/**
220
+	 * Executes a database query to delete gateway logs. Does not affect model objects, so if you attempt to use
221
+	 * models after this, they may be out-of-sync with the database
222
+	 *
223
+	 * @param DateTime $datetime
224
+	 * @return false|int
225
+	 * @throws EE_Error
226
+	 */
227
+	public function delete_gateway_logs_older_than(DateTime $datetime)
228
+	{
229
+		global $wpdb;
230
+		return $wpdb->query(
231
+			$wpdb->prepare(
232
+				'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s',
233
+				EEM_Change_Log::type_gateway,
234
+				$datetime->format(EE_Datetime_Field::mysql_timestamp_format)
235
+			)
236
+		);
237
+	}
238 238
 
239 239
 
240
-    /**
241
-     * Returns the map of type to pretty label for identifiers used for `LOG_type`.  Client code can register their own
242
-     * map vai the given filter.
243
-     *
244
-     * @return array
245
-     */
246
-    public static function get_pretty_label_map_for_registered_types(): array
247
-    {
248
-        return apply_filters(
249
-            'FHEE__EEM_Change_Log__get_pretty_label_map_for_registered_types',
250
-            [
251
-                self::type_create  => esc_html__("Create", "event_espresso"),
252
-                self::type_update  => esc_html__("Update", "event_espresso"),
253
-                self::type_delete  => esc_html__("Delete", "event_espresso"),
254
-                self::type_debug   => esc_html__("Debug", "event_espresso"),
255
-                self::type_error   => esc_html__("Error", "event_espresso"),
256
-                self::type_gateway => esc_html__("Gateway Interaction (IPN or Direct Payment)", 'event_espresso'),
257
-            ]
258
-        );
259
-    }
240
+	/**
241
+	 * Returns the map of type to pretty label for identifiers used for `LOG_type`.  Client code can register their own
242
+	 * map vai the given filter.
243
+	 *
244
+	 * @return array
245
+	 */
246
+	public static function get_pretty_label_map_for_registered_types(): array
247
+	{
248
+		return apply_filters(
249
+			'FHEE__EEM_Change_Log__get_pretty_label_map_for_registered_types',
250
+			[
251
+				self::type_create  => esc_html__("Create", "event_espresso"),
252
+				self::type_update  => esc_html__("Update", "event_espresso"),
253
+				self::type_delete  => esc_html__("Delete", "event_espresso"),
254
+				self::type_debug   => esc_html__("Debug", "event_espresso"),
255
+				self::type_error   => esc_html__("Error", "event_espresso"),
256
+				self::type_gateway => esc_html__("Gateway Interaction (IPN or Direct Payment)", 'event_espresso'),
257
+			]
258
+		);
259
+	}
260 260
 
261 261
 
262
-    /**
263
-     * Return the pretty (localized) label for the given log type identifier.
264
-     *
265
-     * @param string $type_identifier
266
-     * @return string
267
-     */
268
-    public static function get_pretty_label_for_type(string $type_identifier): string
269
-    {
270
-        $type_identifier_map = self::get_pretty_label_map_for_registered_types();
271
-        // we fallback to the incoming type identifier if there is no localized label for it.
272
-        return $type_identifier_map[ $type_identifier ] ?? $type_identifier;
273
-    }
262
+	/**
263
+	 * Return the pretty (localized) label for the given log type identifier.
264
+	 *
265
+	 * @param string $type_identifier
266
+	 * @return string
267
+	 */
268
+	public static function get_pretty_label_for_type(string $type_identifier): string
269
+	{
270
+		$type_identifier_map = self::get_pretty_label_map_for_registered_types();
271
+		// we fallback to the incoming type identifier if there is no localized label for it.
272
+		return $type_identifier_map[ $type_identifier ] ?? $type_identifier;
273
+	}
274 274
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -118,17 +118,17 @@  discard block
 block discarded – undo
118 118
                 ),
119 119
             ],
120 120
         ];
121
-        $this->_model_relations    = [];
121
+        $this->_model_relations = [];
122 122
         foreach ($models_this_can_attach_to as $model) {
123 123
             if ($model != 'Change_Log') {
124
-                $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
124
+                $this->_model_relations[$model] = new EE_Belongs_To_Any_Relation();
125 125
             }
126 126
         }
127 127
         // use completely custom caps for this
128 128
         $this->_cap_restriction_generators = false;
129 129
         // caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing
130 130
         foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) {
131
-            $this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ]
131
+            $this->_cap_restrictions[$cap_context][EE_Restriction_Generator_Base::get_default_restrictions_cap()]
132 132
                 = new EE_Return_None_Where_Conditions();
133 133
         }
134 134
         parent::__construct($timezone);
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      */
178 178
     public function gateway_log(string $message, $related_obj_id, string $related_obj_type): EE_Change_Log
179 179
     {
180
-        if (! EE_Registry::instance()->is_model_name($related_obj_type)) {
180
+        if ( ! EE_Registry::instance()->is_model_name($related_obj_type)) {
181 181
             throw new EE_Error(
182 182
                 sprintf(
183 183
                     esc_html__(
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
         global $wpdb;
230 230
         return $wpdb->query(
231 231
             $wpdb->prepare(
232
-                'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s',
232
+                'DELETE FROM '.$this->table().' WHERE LOG_type = %s AND LOG_time < %s',
233 233
                 EEM_Change_Log::type_gateway,
234 234
                 $datetime->format(EE_Datetime_Field::mysql_timestamp_format)
235 235
             )
@@ -269,6 +269,6 @@  discard block
 block discarded – undo
269 269
     {
270 270
         $type_identifier_map = self::get_pretty_label_map_for_registered_types();
271 271
         // we fallback to the incoming type identifier if there is no localized label for it.
272
-        return $type_identifier_map[ $type_identifier ] ?? $type_identifier;
272
+        return $type_identifier_map[$type_identifier] ?? $type_identifier;
273 273
     }
274 274
 }
Please login to merge, or discard this patch.