Completed
Branch models-cleanup/main (de94a1)
by
unknown
96:57 queued 87:28
created
core/db_models/EEM_Question_Group.model.php 1 patch
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -9,148 +9,148 @@
 block discarded – undo
9 9
  */
10 10
 class EEM_Question_Group extends EEM_Soft_Delete_Base
11 11
 {
12
-    /**
13
-     * personal information question group identifier
14
-     *
15
-     * @const int
16
-     */
17
-    const system_personal = 1;
12
+	/**
13
+	 * personal information question group identifier
14
+	 *
15
+	 * @const int
16
+	 */
17
+	const system_personal = 1;
18 18
 
19
-    /**
20
-     * address information question group identifier
21
-     *
22
-     * @const int
23
-     */
24
-    const system_address = 2;
19
+	/**
20
+	 * address information question group identifier
21
+	 *
22
+	 * @const int
23
+	 */
24
+	const system_address = 2;
25 25
 
26
-    /**
27
-     * private instance of the EEM_Question_Group object
28
-     *
29
-     * @var EEM_Question_Group
30
-     */
31
-    protected static $_instance;
26
+	/**
27
+	 * private instance of the EEM_Question_Group object
28
+	 *
29
+	 * @var EEM_Question_Group
30
+	 */
31
+	protected static $_instance;
32 32
 
33 33
 
34
-    /**
35
-     * EEM_Question_Group constructor.
36
-     *
37
-     * @param string $timezone
38
-     * @throws EE_Error
39
-     */
40
-    protected function __construct(string $timezone = '')
41
-    {
42
-        $this->singular_item = esc_html__('Question Group', 'event_espresso');
43
-        $this->plural_item   = esc_html__('Question Groups', 'event_espresso');
34
+	/**
35
+	 * EEM_Question_Group constructor.
36
+	 *
37
+	 * @param string $timezone
38
+	 * @throws EE_Error
39
+	 */
40
+	protected function __construct(string $timezone = '')
41
+	{
42
+		$this->singular_item = esc_html__('Question Group', 'event_espresso');
43
+		$this->plural_item   = esc_html__('Question Groups', 'event_espresso');
44 44
 
45
-        $this->_tables          = [
46
-            'Question_Group' => new EE_Primary_Table('esp_question_group', 'QSG_ID'),
47
-        ];
48
-        $this->_fields          = [
49
-            'Question_Group' => [
50
-                'QSG_ID'              => new EE_Primary_Key_Int_Field(
51
-                    'QSG_ID',
52
-                    esc_html__('Question Group ID', 'event_espresso')
53
-                ),
54
-                'QSG_deleted'         => new EE_Trashed_Flag_Field(
55
-                    'QSG_deleted',
56
-                    esc_html__('Flag indicating this question group was deleted', 'event_espresso'),
57
-                    false,
58
-                    false
59
-                ),
60
-                'QSG_desc'            => new EE_Post_Content_Field(
61
-                    'QSG_desc',
62
-                    esc_html__('Description of Question Group', 'event_espresso'),
63
-                    true,
64
-                    ''
65
-                ),
66
-                'QSG_identifier'      => new EE_Plain_Text_Field(
67
-                    'QSG_identifier',
68
-                    esc_html__('Text ID for question Group', 'event_espresso'),
69
-                    false,
70
-                    ''
71
-                ),
72
-                'QSG_name'            => new EE_Plain_Text_Field(
73
-                    'QSG_name',
74
-                    esc_html__('Question Group Name', 'event_espresso'),
75
-                    false,
76
-                    ''
77
-                ),
78
-                'QSG_order'           => new EE_Integer_Field(
79
-                    'QSG_order',
80
-                    esc_html__('Order in which to show the question group', 'event_espresso'),
81
-                    true,
82
-                    0
83
-                ),
84
-                'QSG_show_group_desc' => new EE_Boolean_Field(
85
-                    'QSG_show_group_desc',
86
-                    esc_html__(
87
-                        'Flag indicating whether to show the group\s description on the registration page',
88
-                        'event_espresso'
89
-                    ),
90
-                    false,
91
-                    false
92
-                ),
93
-                'QSG_show_group_name' => new EE_Boolean_Field(
94
-                    'QSG_show_group_name',
95
-                    esc_html__(
96
-                        'Flag indicating whether to show the group\'s name on the registration page',
97
-                        'event_espresso'
98
-                    ),
99
-                    false,
100
-                    true
101
-                ),
102
-                'QSG_system'          => new EE_Integer_Field(
103
-                    'QSG_system',
104
-                    esc_html__(
105
-                        'Indicate IF this is a system group and if it is what system group it corresponds to.',
106
-                        'event_espresso'
107
-                    ),
108
-                    false,
109
-                    0
110
-                ),
111
-                'QSG_wp_user'         => new EE_WP_User_Field(
112
-                    'QSG_wp_user',
113
-                    esc_html__('Question Group Creator ID', 'event_espresso'),
114
-                    false
115
-                ),
116
-            ],
117
-        ];
118
-        $this->_model_relations = [
119
-            'Event'                => new EE_HABTM_Relation('Event_Question_Group'),
120
-            'Event_Question_Group' => new EE_Has_Many_Relation(),
121
-            'Question'             => new EE_HABTM_Relation('Question_Group_Question'),
122
-            'WP_User'              => new EE_Belongs_To_Relation(),
123
-        ];
124
-        // this model is generally available for reading
125
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]       =
126
-            new EE_Restriction_Generator_Public();
127
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
128
-            new EE_Restriction_Generator_Reg_Form('QSG_system');
129
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
130
-            new EE_Restriction_Generator_Reg_Form('QSG_system');
131
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
132
-            new EE_Restriction_Generator_Reg_Form('QSG_system');
45
+		$this->_tables          = [
46
+			'Question_Group' => new EE_Primary_Table('esp_question_group', 'QSG_ID'),
47
+		];
48
+		$this->_fields          = [
49
+			'Question_Group' => [
50
+				'QSG_ID'              => new EE_Primary_Key_Int_Field(
51
+					'QSG_ID',
52
+					esc_html__('Question Group ID', 'event_espresso')
53
+				),
54
+				'QSG_deleted'         => new EE_Trashed_Flag_Field(
55
+					'QSG_deleted',
56
+					esc_html__('Flag indicating this question group was deleted', 'event_espresso'),
57
+					false,
58
+					false
59
+				),
60
+				'QSG_desc'            => new EE_Post_Content_Field(
61
+					'QSG_desc',
62
+					esc_html__('Description of Question Group', 'event_espresso'),
63
+					true,
64
+					''
65
+				),
66
+				'QSG_identifier'      => new EE_Plain_Text_Field(
67
+					'QSG_identifier',
68
+					esc_html__('Text ID for question Group', 'event_espresso'),
69
+					false,
70
+					''
71
+				),
72
+				'QSG_name'            => new EE_Plain_Text_Field(
73
+					'QSG_name',
74
+					esc_html__('Question Group Name', 'event_espresso'),
75
+					false,
76
+					''
77
+				),
78
+				'QSG_order'           => new EE_Integer_Field(
79
+					'QSG_order',
80
+					esc_html__('Order in which to show the question group', 'event_espresso'),
81
+					true,
82
+					0
83
+				),
84
+				'QSG_show_group_desc' => new EE_Boolean_Field(
85
+					'QSG_show_group_desc',
86
+					esc_html__(
87
+						'Flag indicating whether to show the group\s description on the registration page',
88
+						'event_espresso'
89
+					),
90
+					false,
91
+					false
92
+				),
93
+				'QSG_show_group_name' => new EE_Boolean_Field(
94
+					'QSG_show_group_name',
95
+					esc_html__(
96
+						'Flag indicating whether to show the group\'s name on the registration page',
97
+						'event_espresso'
98
+					),
99
+					false,
100
+					true
101
+				),
102
+				'QSG_system'          => new EE_Integer_Field(
103
+					'QSG_system',
104
+					esc_html__(
105
+						'Indicate IF this is a system group and if it is what system group it corresponds to.',
106
+						'event_espresso'
107
+					),
108
+					false,
109
+					0
110
+				),
111
+				'QSG_wp_user'         => new EE_WP_User_Field(
112
+					'QSG_wp_user',
113
+					esc_html__('Question Group Creator ID', 'event_espresso'),
114
+					false
115
+				),
116
+			],
117
+		];
118
+		$this->_model_relations = [
119
+			'Event'                => new EE_HABTM_Relation('Event_Question_Group'),
120
+			'Event_Question_Group' => new EE_Has_Many_Relation(),
121
+			'Question'             => new EE_HABTM_Relation('Question_Group_Question'),
122
+			'WP_User'              => new EE_Belongs_To_Relation(),
123
+		];
124
+		// this model is generally available for reading
125
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ]       =
126
+			new EE_Restriction_Generator_Public();
127
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
128
+			new EE_Restriction_Generator_Reg_Form('QSG_system');
129
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
130
+			new EE_Restriction_Generator_Reg_Form('QSG_system');
131
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
132
+			new EE_Restriction_Generator_Reg_Form('QSG_system');
133 133
 
134
-        parent::__construct($timezone);
135
-    }
134
+		parent::__construct($timezone);
135
+	}
136 136
 
137 137
 
138
-    /**
139
-     * searches the db for the question group with the latest question order and returns that value.
140
-     *
141
-     * @return int
142
-     * @throws EE_Error
143
-     * @throws ReflectionException
144
-     */
145
-    public function get_latest_question_group_order(): int
146
-    {
147
-        $max = $this->_get_all_wpdb_results(
148
-            [],
149
-            ARRAY_A,
150
-            [
151
-                'max_order' => ["MAX(QSG_order)", "%d"],
152
-            ]
153
-        );
154
-        return $max[0]['max_order'];
155
-    }
138
+	/**
139
+	 * searches the db for the question group with the latest question order and returns that value.
140
+	 *
141
+	 * @return int
142
+	 * @throws EE_Error
143
+	 * @throws ReflectionException
144
+	 */
145
+	public function get_latest_question_group_order(): int
146
+	{
147
+		$max = $this->_get_all_wpdb_results(
148
+			[],
149
+			ARRAY_A,
150
+			[
151
+				'max_order' => ["MAX(QSG_order)", "%d"],
152
+			]
153
+		);
154
+		return $max[0]['max_order'];
155
+	}
156 156
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Registration_Payment.model.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -14,62 +14,62 @@
 block discarded – undo
14 14
 class EEM_Registration_Payment extends EEM_Base
15 15
 {
16 16
 
17
-    /**
18
-     * @var EEM_Registration_Payment
19
-     */
20
-    protected static $_instance;
17
+	/**
18
+	 * @var EEM_Registration_Payment
19
+	 */
20
+	protected static $_instance;
21 21
 
22 22
 
23
-    /**
24
-     * EEM_Registration_Payment constructor.
25
-     *
26
-     * @param string $timezone
27
-     * @throws EE_Error
28
-     */
29
-    protected function __construct(string $timezone = '')
30
-    {
23
+	/**
24
+	 * EEM_Registration_Payment constructor.
25
+	 *
26
+	 * @param string $timezone
27
+	 * @throws EE_Error
28
+	 */
29
+	protected function __construct(string $timezone = '')
30
+	{
31 31
 
32
-        $this->singular_item = esc_html__('Registration Payment', 'event_espresso');
33
-        $this->plural_item   = esc_html__('Registration Payments', 'event_espresso');
32
+		$this->singular_item = esc_html__('Registration Payment', 'event_espresso');
33
+		$this->plural_item   = esc_html__('Registration Payments', 'event_espresso');
34 34
 
35
-        $this->_tables = [
36
-            'Registration_Payment' => new EE_Primary_Table('esp_registration_payment', 'RPY_ID'),
37
-        ];
35
+		$this->_tables = [
36
+			'Registration_Payment' => new EE_Primary_Table('esp_registration_payment', 'RPY_ID'),
37
+		];
38 38
 
39
-        $this->_fields = [
40
-            'Registration_Payment' => [
41
-                'RPY_ID'     => new EE_Primary_Key_Int_Field(
42
-                    'RPY_ID',
43
-                    esc_html__('Registration Payment ID', 'event_espresso')
44
-                ),
45
-                'REG_ID'     => new EE_Foreign_Key_Int_Field(
46
-                    'REG_ID',
47
-                    esc_html__('Registration ID', 'event_espresso'),
48
-                    false,
49
-                    0,
50
-                    'Registration'
51
-                ),
52
-                'PAY_ID'     => new EE_Foreign_Key_Int_Field(
53
-                    'PAY_ID',
54
-                    esc_html__('Payment ID', 'event_espresso'),
55
-                    true,
56
-                    null,
57
-                    'Payment'
58
-                ),
59
-                'RPY_amount' => new EE_Money_Field(
60
-                    'RPY_amount',
61
-                    esc_html__('Amount attributed to the registration', 'event_espresso'),
62
-                    false,
63
-                    0
64
-                ),
65
-            ],
66
-        ];
39
+		$this->_fields = [
40
+			'Registration_Payment' => [
41
+				'RPY_ID'     => new EE_Primary_Key_Int_Field(
42
+					'RPY_ID',
43
+					esc_html__('Registration Payment ID', 'event_espresso')
44
+				),
45
+				'REG_ID'     => new EE_Foreign_Key_Int_Field(
46
+					'REG_ID',
47
+					esc_html__('Registration ID', 'event_espresso'),
48
+					false,
49
+					0,
50
+					'Registration'
51
+				),
52
+				'PAY_ID'     => new EE_Foreign_Key_Int_Field(
53
+					'PAY_ID',
54
+					esc_html__('Payment ID', 'event_espresso'),
55
+					true,
56
+					null,
57
+					'Payment'
58
+				),
59
+				'RPY_amount' => new EE_Money_Field(
60
+					'RPY_amount',
61
+					esc_html__('Amount attributed to the registration', 'event_espresso'),
62
+					false,
63
+					0
64
+				),
65
+			],
66
+		];
67 67
 
68
-        $this->_model_relations = [
69
-            'Registration' => new EE_Belongs_To_Relation(),
70
-            'Payment'      => new EE_Belongs_To_Relation(),
71
-        ];
68
+		$this->_model_relations = [
69
+			'Registration' => new EE_Belongs_To_Relation(),
70
+			'Payment'      => new EE_Belongs_To_Relation(),
71
+		];
72 72
 
73
-        parent::__construct($timezone);
74
-    }
73
+		parent::__construct($timezone);
74
+	}
75 75
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Extra_Meta.model.php 2 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -15,70 +15,70 @@
 block discarded – undo
15 15
 class EEM_Extra_Meta extends EEM_Base
16 16
 {
17 17
 
18
-    /**
19
-     * @var EEM_Extra_Meta
20
-     */
21
-    protected static $_instance;
18
+	/**
19
+	 * @var EEM_Extra_Meta
20
+	 */
21
+	protected static $_instance;
22 22
 
23 23
 
24
-    /**
25
-     * EEM_Extra_Meta constructor.
26
-     *
27
-     * @param string $timezone
28
-     * @throws EE_Error
29
-     */
30
-    protected function __construct(string $timezone = '')
31
-    {
32
-        $this->singular_item       = esc_html__('Extra Meta', 'event_espresso');
33
-        $this->plural_item         = esc_html__('Extra Metas', 'event_espresso');
34
-        $this->_tables             = [
35
-            'Extra_Meta' => new EE_Primary_Table('esp_extra_meta', 'EXM_ID'),
36
-        ];
37
-        $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models);
38
-        $this->_fields             = [
39
-            'Extra_Meta' => [
40
-                'EXM_ID'    => new EE_Primary_Key_Int_Field(
41
-                    'EXM_ID',
42
-                    esc_html__("Extra Meta ID", "event_espresso")
43
-                ),
44
-                'OBJ_ID'    => new EE_Foreign_Key_Int_Field(
45
-                    'OBJ_ID',
46
-                    esc_html__("Primary Key of Attached Thing", "event_espresso"),
47
-                    false,
48
-                    0,
49
-                    $models_this_can_attach_to
50
-                ),
51
-                'EXM_type'  => new EE_Any_Foreign_Model_Name_Field(
52
-                    'EXM_type',
53
-                    esc_html__("Model of Attached Thing", "event_espresso"),
54
-                    false,
55
-                    'Transaction',
56
-                    $models_this_can_attach_to
57
-                ),
58
-                'EXM_key'   => new EE_Plain_Text_Field(
59
-                    'EXM_key',
60
-                    esc_html__("Meta Key", "event_espresso"),
61
-                    false,
62
-                    ''
63
-                ),
64
-                'EXM_value' => new EE_Maybe_Serialized_Text_Field(
65
-                    'EXM_value',
66
-                    esc_html__("Meta Value", "event_espresso"),
67
-                    true
68
-                ),
24
+	/**
25
+	 * EEM_Extra_Meta constructor.
26
+	 *
27
+	 * @param string $timezone
28
+	 * @throws EE_Error
29
+	 */
30
+	protected function __construct(string $timezone = '')
31
+	{
32
+		$this->singular_item       = esc_html__('Extra Meta', 'event_espresso');
33
+		$this->plural_item         = esc_html__('Extra Metas', 'event_espresso');
34
+		$this->_tables             = [
35
+			'Extra_Meta' => new EE_Primary_Table('esp_extra_meta', 'EXM_ID'),
36
+		];
37
+		$models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models);
38
+		$this->_fields             = [
39
+			'Extra_Meta' => [
40
+				'EXM_ID'    => new EE_Primary_Key_Int_Field(
41
+					'EXM_ID',
42
+					esc_html__("Extra Meta ID", "event_espresso")
43
+				),
44
+				'OBJ_ID'    => new EE_Foreign_Key_Int_Field(
45
+					'OBJ_ID',
46
+					esc_html__("Primary Key of Attached Thing", "event_espresso"),
47
+					false,
48
+					0,
49
+					$models_this_can_attach_to
50
+				),
51
+				'EXM_type'  => new EE_Any_Foreign_Model_Name_Field(
52
+					'EXM_type',
53
+					esc_html__("Model of Attached Thing", "event_espresso"),
54
+					false,
55
+					'Transaction',
56
+					$models_this_can_attach_to
57
+				),
58
+				'EXM_key'   => new EE_Plain_Text_Field(
59
+					'EXM_key',
60
+					esc_html__("Meta Key", "event_espresso"),
61
+					false,
62
+					''
63
+				),
64
+				'EXM_value' => new EE_Maybe_Serialized_Text_Field(
65
+					'EXM_value',
66
+					esc_html__("Meta Value", "event_espresso"),
67
+					true
68
+				),
69 69
 
70
-            ],
71
-        ];
72
-        $this->_model_relations    = [];
73
-        foreach ($models_this_can_attach_to as $model) {
74
-            $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
75
-        }
76
-        foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
77
-            $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta(
78
-                'EXM_key',
79
-                'EXM_value'
80
-            );
81
-        }
82
-        parent::__construct($timezone);
83
-    }
70
+			],
71
+		];
72
+		$this->_model_relations    = [];
73
+		foreach ($models_this_can_attach_to as $model) {
74
+			$this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
75
+		}
76
+		foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
77
+			$this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta(
78
+				'EXM_key',
79
+				'EXM_value'
80
+			);
81
+		}
82
+		parent::__construct($timezone);
83
+	}
84 84
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -69,12 +69,12 @@
 block discarded – undo
69 69
 
70 70
             ],
71 71
         ];
72
-        $this->_model_relations    = [];
72
+        $this->_model_relations = [];
73 73
         foreach ($models_this_can_attach_to as $model) {
74
-            $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
74
+            $this->_model_relations[$model] = new EE_Belongs_To_Any_Relation();
75 75
         }
76 76
         foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
77
-            $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta(
77
+            $this->_cap_restriction_generators[$cap_context] = new EE_Restriction_Generator_Meta(
78 78
                 'EXM_key',
79 79
                 'EXM_value'
80 80
             );
Please login to merge, or discard this patch.
core/db_models/EEM_Checkin.model.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -12,69 +12,69 @@
 block discarded – undo
12 12
 class EEM_Checkin extends EEM_Base
13 13
 {
14 14
 
15
-    // private instance of the EEM_Checkin object
16
-    protected static $_instance;
15
+	// private instance of the EEM_Checkin object
16
+	protected static $_instance;
17 17
 
18 18
 
19
-    /**
20
-     * private constructor to prevent direct creation
21
-     *
22
-     * @param string|null $timezone string representing the timezone we want to set for returned Date Time Strings
23
-     *                              (and any incoming timezone data that gets saved).
24
-     *                              Note this just sends the timezone info to the date time model field objects.
25
-     *                              will use 'timezone_string' wp option as default
26
-     * @return void
27
-     * @throws EE_Error
28
-     * @throws EE_Error
29
-     */
30
-    protected function __construct(string $timezone = '')
31
-    {
32
-        $this->singular_item = esc_html__('Check-In', 'event_espresso');
33
-        $this->plural_item   = esc_html__('Check-Ins', 'event_espresso');
19
+	/**
20
+	 * private constructor to prevent direct creation
21
+	 *
22
+	 * @param string|null $timezone string representing the timezone we want to set for returned Date Time Strings
23
+	 *                              (and any incoming timezone data that gets saved).
24
+	 *                              Note this just sends the timezone info to the date time model field objects.
25
+	 *                              will use 'timezone_string' wp option as default
26
+	 * @return void
27
+	 * @throws EE_Error
28
+	 * @throws EE_Error
29
+	 */
30
+	protected function __construct(string $timezone = '')
31
+	{
32
+		$this->singular_item = esc_html__('Check-In', 'event_espresso');
33
+		$this->plural_item   = esc_html__('Check-Ins', 'event_espresso');
34 34
 
35
-        $this->_tables                 = [
36
-            'Checkin' => new EE_Primary_Table('esp_checkin', 'CHK_ID'),
37
-        ];
38
-        $this->_fields                 = [
39
-            'Checkin' => [
40
-                'CHK_ID'        => new EE_Primary_Key_Int_Field(
41
-                    'CHK_ID',
42
-                    esc_html__('Check-in ID', 'event_espresso')
43
-                ),
44
-                'REG_ID'        => new EE_Foreign_Key_Int_Field(
45
-                    'REG_ID',
46
-                    esc_html__('Registration Id', 'event_espresso'),
47
-                    false,
48
-                    0,
49
-                    'Registration'
50
-                ),
51
-                'DTT_ID'        => new EE_Foreign_Key_Int_Field(
52
-                    'DTT_ID',
53
-                    esc_html__('Datetime Id', 'event_espresso'),
54
-                    false,
55
-                    0,
56
-                    'Datetime'
57
-                ),
58
-                'CHK_in'        => new EE_Boolean_Field(
59
-                    'CHK_in',
60
-                    esc_html__('Whether a person has checked in or checked out', 'event_espresso'),
61
-                    false,
62
-                    true
63
-                ),
64
-                'CHK_timestamp' => new EE_Datetime_Field(
65
-                    'CHK_timestamp',
66
-                    esc_html__('When the row was modified', 'event_espresso'),
67
-                    false,
68
-                    EE_Datetime_Field::now,
69
-                    $timezone
70
-                ),
71
-            ],
72
-        ];
73
-        $this->_model_relations        = [
74
-            'Registration' => new EE_Belongs_To_Relation(),
75
-            'Datetime'     => new EE_Belongs_To_Relation(),
76
-        ];
77
-        $this->_model_chain_to_wp_user = 'Registration.Event';
78
-        parent::__construct($timezone);
79
-    }
35
+		$this->_tables                 = [
36
+			'Checkin' => new EE_Primary_Table('esp_checkin', 'CHK_ID'),
37
+		];
38
+		$this->_fields                 = [
39
+			'Checkin' => [
40
+				'CHK_ID'        => new EE_Primary_Key_Int_Field(
41
+					'CHK_ID',
42
+					esc_html__('Check-in ID', 'event_espresso')
43
+				),
44
+				'REG_ID'        => new EE_Foreign_Key_Int_Field(
45
+					'REG_ID',
46
+					esc_html__('Registration Id', 'event_espresso'),
47
+					false,
48
+					0,
49
+					'Registration'
50
+				),
51
+				'DTT_ID'        => new EE_Foreign_Key_Int_Field(
52
+					'DTT_ID',
53
+					esc_html__('Datetime Id', 'event_espresso'),
54
+					false,
55
+					0,
56
+					'Datetime'
57
+				),
58
+				'CHK_in'        => new EE_Boolean_Field(
59
+					'CHK_in',
60
+					esc_html__('Whether a person has checked in or checked out', 'event_espresso'),
61
+					false,
62
+					true
63
+				),
64
+				'CHK_timestamp' => new EE_Datetime_Field(
65
+					'CHK_timestamp',
66
+					esc_html__('When the row was modified', 'event_espresso'),
67
+					false,
68
+					EE_Datetime_Field::now,
69
+					$timezone
70
+				),
71
+			],
72
+		];
73
+		$this->_model_relations        = [
74
+			'Registration' => new EE_Belongs_To_Relation(),
75
+			'Datetime'     => new EE_Belongs_To_Relation(),
76
+		];
77
+		$this->_model_chain_to_wp_user = 'Registration.Event';
78
+		parent::__construct($timezone);
79
+	}
80 80
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
                 ),
71 71
             ],
72 72
         ];
73
-        $this->_model_relations        = [
73
+        $this->_model_relations = [
74 74
             'Registration' => new EE_Belongs_To_Relation(),
75 75
             'Datetime'     => new EE_Belongs_To_Relation(),
76 76
         ];
Please login to merge, or discard this patch.
core/db_models/EEM_Payment.model.php 2 patches
Indentation   +326 added lines, -326 removed lines patch added patch discarded remove patch
@@ -12,330 +12,330 @@
 block discarded – undo
12 12
 class EEM_Payment extends EEM_Base implements EEMI_Payment
13 13
 {
14 14
 
15
-    /**
16
-     * @var EEM_Payment
17
-     */
18
-    protected static $_instance;
19
-
20
-
21
-    /**
22
-     * Status id in esp_status table that represents an approved payment
23
-     */
24
-    const status_id_approved = 'PAP';
25
-
26
-
27
-    /**
28
-     * Status id in esp_status table that represents a pending payment
29
-     */
30
-    const status_id_pending = 'PPN';
31
-
32
-
33
-    /**
34
-     * Status id in esp_status table that represents a cancelled payment (eg, the
35
-     * user went to PayPal, but on the paypal site decided to cancel the payment)
36
-     */
37
-    const status_id_cancelled = 'PCN';
38
-
39
-
40
-    /**
41
-     * Status id in esp_status table that represents a payment that was declined by
42
-     * the gateway. (eg, the user's card had no funds, or it was a fraudulent card)
43
-     */
44
-    const status_id_declined = 'PDC';
45
-
46
-
47
-    /**
48
-     * Status id in esp_status table that represents a payment that failed for technical reasons.
49
-     * (Eg, there was some error in communicating with the payment gateway.)
50
-     */
51
-    const status_id_failed = 'PFL';
52
-
53
-
54
-    /**
55
-     * private constructor to prevent direct creation
56
-     *
57
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
58
-     *                         incoming timezone data that gets saved).  Note this just sends the timezone info to the
59
-     *                         date time model field objects.  Default is NULL (and will be assumed using the set
60
-     *                         timezone in the 'timezone_string' wp option)
61
-     * @throws EE_Error
62
-     * @throws EE_Error
63
-     */
64
-    protected function __construct(string $timezone = '')
65
-    {
66
-
67
-        $this->singular_item = esc_html__('Payment', 'event_espresso');
68
-        $this->plural_item   = esc_html__('Payments', 'event_espresso');
69
-
70
-        $this->_tables                 = [
71
-            'Payment' => new EE_Primary_Table('esp_payment', 'PAY_ID'),
72
-        ];
73
-        $this->_fields                 = [
74
-            'Payment' => [
75
-                'PAY_ID'               => new EE_Primary_Key_Int_Field(
76
-                    'PAY_ID',
77
-                    esc_html__('Payment ID', 'event_espresso')
78
-                ),
79
-                'TXN_ID'               => new EE_Foreign_Key_Int_Field(
80
-                    'TXN_ID',
81
-                    esc_html__('Transaction ID', 'event_espresso'),
82
-                    false,
83
-                    0,
84
-                    'Transaction'
85
-                ),
86
-                'STS_ID'               => new EE_Foreign_Key_String_Field(
87
-                    'STS_ID',
88
-                    esc_html__('Status ID', 'event_espresso'),
89
-                    false,
90
-                    EEM_Payment::status_id_failed,
91
-                    'Status'
92
-                ),
93
-                'PAY_timestamp'        => new EE_Datetime_Field(
94
-                    'PAY_timestamp',
95
-                    esc_html__('Timestamp of when payment was attempted', 'event_espresso'),
96
-                    false,
97
-                    EE_Datetime_Field::now,
98
-                    $timezone
99
-                ),
100
-                'PAY_source'           => new EE_All_Caps_Text_Field(
101
-                    'PAY_source',
102
-                    esc_html__('User-friendly description of payment', 'event_espresso'),
103
-                    false,
104
-                    'CART'
105
-                ),
106
-                'PAY_amount'           => new EE_Money_Field(
107
-                    'PAY_amount',
108
-                    esc_html__('Amount Payment should be for', 'event_espresso'),
109
-                    false,
110
-                    0
111
-                ),
112
-                'PMD_ID'               => new EE_Foreign_Key_Int_Field(
113
-                    'PMD_ID',
114
-                    esc_html__("Payment Method ID", 'event_espresso'),
115
-                    false,
116
-                    null,
117
-                    'Payment_Method'
118
-                ),
119
-                'PAY_gateway_response' => new EE_Plain_Text_Field(
120
-                    'PAY_gateway_response',
121
-                    esc_html__('Response from Gateway about the payment', 'event_espresso'),
122
-                    false,
123
-                    ''
124
-                ),
125
-                'PAY_txn_id_chq_nmbr'  => new EE_Plain_Text_Field(
126
-                    'PAY_txn_id_chq_nmbr',
127
-                    esc_html__('Gateway Transaction ID or Cheque Number', 'event_espresso'),
128
-                    true,
129
-                    ''
130
-                ),
131
-                'PAY_po_number'        => new EE_Plain_Text_Field(
132
-                    'PAY_po_number',
133
-                    esc_html__('Purchase or Sales Number', 'event_espresso'),
134
-                    true,
135
-                    ''
136
-                ),
137
-                'PAY_extra_accntng'    => new EE_Simple_HTML_Field(
138
-                    'PAY_extra_accntng',
139
-                    esc_html__('Extra Account Info', 'event_espresso'),
140
-                    true,
141
-                    ''
142
-                ),
143
-                'PAY_details'          => new EE_Serialized_Text_Field(
144
-                    'PAY_details',
145
-                    esc_html__('Full Gateway response about payment', 'event_espresso'),
146
-                    true,
147
-                    ''
148
-                ),
149
-                'PAY_redirect_url'     => new EE_Plain_Text_Field(
150
-                    'PAY_redirect_url',
151
-                    esc_html__("Redirect URL", 'event_espresso'),
152
-                    true
153
-                ),
154
-                'PAY_redirect_args'    => new EE_Serialized_Text_Field(
155
-                    'PAY_redirect_args',
156
-                    esc_html__("Key-Value POST vars to send along with redirect", 'event_espresso'),
157
-                    true
158
-                ),
159
-            ],
160
-        ];
161
-        $this->_model_relations        = [
162
-            'Transaction'          => new EE_Belongs_To_Relation(),
163
-            'Status'               => new EE_Belongs_To_Relation(),
164
-            'Payment_Method'       => new EE_Belongs_To_Relation(),
165
-            'Registration_Payment' => new EE_Has_Many_Relation(),
166
-            'Registration'         => new EE_HABTM_Relation('Registration_Payment'),
167
-        ];
168
-        $this->_model_chain_to_wp_user = 'Payment_Method';
169
-        $this->_caps_slug              = 'transactions';
170
-        parent::__construct($timezone);
171
-    }
172
-
173
-
174
-    /**
175
-     * Gets the payment by the gateway server's unique ID. Eg, the unique ID PayPal assigned
176
-     * to the payment. This is handy for verifying an IPN hasn't already been processed.
177
-     *
178
-     * @param int|string $PAY_txn_id_chq_nmbr
179
-     * @return EE_Payment
180
-     * @throws EE_Error
181
-     * @throws ReflectionException
182
-     */
183
-    public function get_payment_by_txn_id_chq_nmbr($PAY_txn_id_chq_nmbr): EE_Payment
184
-    {
185
-        return $this->get_one([['PAY_txn_id_chq_nmbr' => $PAY_txn_id_chq_nmbr]]);
186
-    }
187
-
188
-
189
-    /**
190
-     *       retrieve  all payments from db for a particular transaction, optionally with
191
-     *      a particular status
192
-     *
193
-     * @param int $TXN_ID
194
-     * @param string $status_of_payment   one of EEM_Payment::status_id_*, like 'PAP','PCN',etc. If none is provided,
195
-     *                                  gets payments with any status
196
-     * @return EE_Payment[]
197
-     * @throws EE_Error
198
-     * @throws ReflectionException
199
-     */
200
-    public function get_payments_for_transaction(int $TXN_ID, string $status_of_payment = ''): array
201
-    {
202
-        // all payments for a TXN ordered chronologically
203
-        $query_params = [['TXN_ID' => $TXN_ID], 'order_by' => ['PAY_timestamp' => 'ASC']];
204
-        // if provided with a status, search specifically for that status. Otherwise get them all
205
-        if ($status_of_payment) {
206
-            $query_params[0]['STS_ID'] = $status_of_payment;
207
-        }
208
-        // retrieve payments
209
-        return $this->get_all($query_params);
210
-    }
211
-
212
-
213
-    /**
214
-     * Only gets payments which have been approved
215
-     *
216
-     * @param int $TXN_ID
217
-     * @return EE_Payment[]
218
-     * @throws EE_Error
219
-     * @throws ReflectionException
220
-     */
221
-    public function get_approved_payments_for_transaction(int $TXN_ID = 0): array
222
-    {
223
-        return $this->get_payments_for_transaction($TXN_ID, EEM_Payment::status_id_approved);
224
-    }
225
-
226
-
227
-    /**
228
-     * retrieve  all payments from db between two dates,
229
-     *
230
-     * @param string $start_date        incoming start date. If empty the beginning of today is used.
231
-     * @param string $end_date          incoming end date. If empty the end of today is used.
232
-     * @param string $format            If you include $start_date or $end_date then you must include the format string
233
-     *                                  for the format your date is in.
234
-     * @param string $timezone          If your range is in a different timezone then the current setting on this
235
-     *                                  WordPress install, then include it here.
236
-     * @return EE_Payment[]
237
-     * @throws ReflectionException
238
-     *
239
-     * @throws EE_Error
240
-     */
241
-    public function get_payments_made_between_dates(
242
-        string $start_date = '',
243
-        string $end_date = '',
244
-        string $format = '',
245
-        string $timezone = ''
246
-    ): array {
247
-        $timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
248
-        // if $start_date or $end date, verify $format is included.
249
-        if ((! empty($start_date) || ! empty($end_date)) && empty($format)) {
250
-            throw new EE_Error(__('You included a start date and/or a end date for this method but did not include a format string.  The format string is needed for setting up the query',
251
-                                  'event_espresso'));
252
-        }
253
-        $now = new DateTime('now');
254
-        // setup timezone objects once
255
-        $modelDateTimeZone  = new DateTimeZone($this->_timezone);
256
-        $passedDateTimeZone = new DateTimeZone($timezone);
257
-        // setup start date
258
-        $start_date = ! empty($start_date) ? date_create_from_format($format, $start_date, $passedDateTimeZone) : $now;
259
-        EEH_DTT_Helper::setTimezone($start_date, $modelDateTimeZone);
260
-        $start_date = $start_date->format('Y-m-d') . ' 00:00:00';
261
-        $start_date = strtotime($start_date);
262
-        // setup end date
263
-        $end_date = ! empty($end_date) ? date_create_from_format($format, $end_date, $passedDateTimeZone) : $now;
264
-        EEH_DTT_Helper::setTimezone($end_date, $modelDateTimeZone);
265
-        $end_date = $end_date->format('Y-m-d') . ' 23:59:59';
266
-        $end_date = strtotime($end_date);
267
-
268
-        // make sure our start date is the lowest value and vice versa
269
-        $start = min($start_date, $end_date);
270
-        $end   = max($start_date, $end_date);
271
-
272
-        // yes we generated the date and time string in utc but we WANT this start date and time used in the set timezone on the model.
273
-        $start_date = $this->convert_datetime_for_query('PAY_timestamp',
274
-                                                        date('Y-m-d', $start) . ' 00:00:00',
275
-                                                        'Y-m-d H:i:s',
276
-                                                        $this->get_timezone());
277
-        $end_date   = $this->convert_datetime_for_query('PAY_timestamp',
278
-                                                        date('Y-m-d', $end) . ' 23:59:59',
279
-                                                        'Y-m-d H:i:s',
280
-                                                        $this->get_timezone());
281
-
282
-        return $this->get_all([['PAY_timestamp' => ['>=', $start_date], 'PAY_timestamp*' => ['<=', $end_date]]]);
283
-    }
284
-
285
-    /**
286
-     * methods for EEMI_Payment
287
-     */
288
-    /**
289
-     * returns a string for the approved status
290
-     *
291
-     * @return  string
292
-     */
293
-    public function approved_status(): string
294
-    {
295
-        return self::status_id_approved;
296
-    }
297
-
298
-
299
-    /**
300
-     * returns a string for the pending status
301
-     *
302
-     * @return  string
303
-     */
304
-    public function pending_status(): string
305
-    {
306
-        return self::status_id_pending;
307
-    }
308
-
309
-
310
-    /**
311
-     * returns a string for the cancelled status
312
-     *
313
-     * @return  string
314
-     */
315
-    public function cancelled_status(): string
316
-    {
317
-        return self::status_id_cancelled;
318
-    }
319
-
320
-
321
-    /**
322
-     * returns a string for the failed status
323
-     *
324
-     * @return  string
325
-     */
326
-    public function failed_status(): string
327
-    {
328
-        return self::status_id_failed;
329
-    }
330
-
331
-
332
-    /**
333
-     * returns a string for the declined status
334
-     *
335
-     * @return  string
336
-     */
337
-    public function declined_status(): string
338
-    {
339
-        return self::status_id_declined;
340
-    }
15
+	/**
16
+	 * @var EEM_Payment
17
+	 */
18
+	protected static $_instance;
19
+
20
+
21
+	/**
22
+	 * Status id in esp_status table that represents an approved payment
23
+	 */
24
+	const status_id_approved = 'PAP';
25
+
26
+
27
+	/**
28
+	 * Status id in esp_status table that represents a pending payment
29
+	 */
30
+	const status_id_pending = 'PPN';
31
+
32
+
33
+	/**
34
+	 * Status id in esp_status table that represents a cancelled payment (eg, the
35
+	 * user went to PayPal, but on the paypal site decided to cancel the payment)
36
+	 */
37
+	const status_id_cancelled = 'PCN';
38
+
39
+
40
+	/**
41
+	 * Status id in esp_status table that represents a payment that was declined by
42
+	 * the gateway. (eg, the user's card had no funds, or it was a fraudulent card)
43
+	 */
44
+	const status_id_declined = 'PDC';
45
+
46
+
47
+	/**
48
+	 * Status id in esp_status table that represents a payment that failed for technical reasons.
49
+	 * (Eg, there was some error in communicating with the payment gateway.)
50
+	 */
51
+	const status_id_failed = 'PFL';
52
+
53
+
54
+	/**
55
+	 * private constructor to prevent direct creation
56
+	 *
57
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
58
+	 *                         incoming timezone data that gets saved).  Note this just sends the timezone info to the
59
+	 *                         date time model field objects.  Default is NULL (and will be assumed using the set
60
+	 *                         timezone in the 'timezone_string' wp option)
61
+	 * @throws EE_Error
62
+	 * @throws EE_Error
63
+	 */
64
+	protected function __construct(string $timezone = '')
65
+	{
66
+
67
+		$this->singular_item = esc_html__('Payment', 'event_espresso');
68
+		$this->plural_item   = esc_html__('Payments', 'event_espresso');
69
+
70
+		$this->_tables                 = [
71
+			'Payment' => new EE_Primary_Table('esp_payment', 'PAY_ID'),
72
+		];
73
+		$this->_fields                 = [
74
+			'Payment' => [
75
+				'PAY_ID'               => new EE_Primary_Key_Int_Field(
76
+					'PAY_ID',
77
+					esc_html__('Payment ID', 'event_espresso')
78
+				),
79
+				'TXN_ID'               => new EE_Foreign_Key_Int_Field(
80
+					'TXN_ID',
81
+					esc_html__('Transaction ID', 'event_espresso'),
82
+					false,
83
+					0,
84
+					'Transaction'
85
+				),
86
+				'STS_ID'               => new EE_Foreign_Key_String_Field(
87
+					'STS_ID',
88
+					esc_html__('Status ID', 'event_espresso'),
89
+					false,
90
+					EEM_Payment::status_id_failed,
91
+					'Status'
92
+				),
93
+				'PAY_timestamp'        => new EE_Datetime_Field(
94
+					'PAY_timestamp',
95
+					esc_html__('Timestamp of when payment was attempted', 'event_espresso'),
96
+					false,
97
+					EE_Datetime_Field::now,
98
+					$timezone
99
+				),
100
+				'PAY_source'           => new EE_All_Caps_Text_Field(
101
+					'PAY_source',
102
+					esc_html__('User-friendly description of payment', 'event_espresso'),
103
+					false,
104
+					'CART'
105
+				),
106
+				'PAY_amount'           => new EE_Money_Field(
107
+					'PAY_amount',
108
+					esc_html__('Amount Payment should be for', 'event_espresso'),
109
+					false,
110
+					0
111
+				),
112
+				'PMD_ID'               => new EE_Foreign_Key_Int_Field(
113
+					'PMD_ID',
114
+					esc_html__("Payment Method ID", 'event_espresso'),
115
+					false,
116
+					null,
117
+					'Payment_Method'
118
+				),
119
+				'PAY_gateway_response' => new EE_Plain_Text_Field(
120
+					'PAY_gateway_response',
121
+					esc_html__('Response from Gateway about the payment', 'event_espresso'),
122
+					false,
123
+					''
124
+				),
125
+				'PAY_txn_id_chq_nmbr'  => new EE_Plain_Text_Field(
126
+					'PAY_txn_id_chq_nmbr',
127
+					esc_html__('Gateway Transaction ID or Cheque Number', 'event_espresso'),
128
+					true,
129
+					''
130
+				),
131
+				'PAY_po_number'        => new EE_Plain_Text_Field(
132
+					'PAY_po_number',
133
+					esc_html__('Purchase or Sales Number', 'event_espresso'),
134
+					true,
135
+					''
136
+				),
137
+				'PAY_extra_accntng'    => new EE_Simple_HTML_Field(
138
+					'PAY_extra_accntng',
139
+					esc_html__('Extra Account Info', 'event_espresso'),
140
+					true,
141
+					''
142
+				),
143
+				'PAY_details'          => new EE_Serialized_Text_Field(
144
+					'PAY_details',
145
+					esc_html__('Full Gateway response about payment', 'event_espresso'),
146
+					true,
147
+					''
148
+				),
149
+				'PAY_redirect_url'     => new EE_Plain_Text_Field(
150
+					'PAY_redirect_url',
151
+					esc_html__("Redirect URL", 'event_espresso'),
152
+					true
153
+				),
154
+				'PAY_redirect_args'    => new EE_Serialized_Text_Field(
155
+					'PAY_redirect_args',
156
+					esc_html__("Key-Value POST vars to send along with redirect", 'event_espresso'),
157
+					true
158
+				),
159
+			],
160
+		];
161
+		$this->_model_relations        = [
162
+			'Transaction'          => new EE_Belongs_To_Relation(),
163
+			'Status'               => new EE_Belongs_To_Relation(),
164
+			'Payment_Method'       => new EE_Belongs_To_Relation(),
165
+			'Registration_Payment' => new EE_Has_Many_Relation(),
166
+			'Registration'         => new EE_HABTM_Relation('Registration_Payment'),
167
+		];
168
+		$this->_model_chain_to_wp_user = 'Payment_Method';
169
+		$this->_caps_slug              = 'transactions';
170
+		parent::__construct($timezone);
171
+	}
172
+
173
+
174
+	/**
175
+	 * Gets the payment by the gateway server's unique ID. Eg, the unique ID PayPal assigned
176
+	 * to the payment. This is handy for verifying an IPN hasn't already been processed.
177
+	 *
178
+	 * @param int|string $PAY_txn_id_chq_nmbr
179
+	 * @return EE_Payment
180
+	 * @throws EE_Error
181
+	 * @throws ReflectionException
182
+	 */
183
+	public function get_payment_by_txn_id_chq_nmbr($PAY_txn_id_chq_nmbr): EE_Payment
184
+	{
185
+		return $this->get_one([['PAY_txn_id_chq_nmbr' => $PAY_txn_id_chq_nmbr]]);
186
+	}
187
+
188
+
189
+	/**
190
+	 *       retrieve  all payments from db for a particular transaction, optionally with
191
+	 *      a particular status
192
+	 *
193
+	 * @param int $TXN_ID
194
+	 * @param string $status_of_payment   one of EEM_Payment::status_id_*, like 'PAP','PCN',etc. If none is provided,
195
+	 *                                  gets payments with any status
196
+	 * @return EE_Payment[]
197
+	 * @throws EE_Error
198
+	 * @throws ReflectionException
199
+	 */
200
+	public function get_payments_for_transaction(int $TXN_ID, string $status_of_payment = ''): array
201
+	{
202
+		// all payments for a TXN ordered chronologically
203
+		$query_params = [['TXN_ID' => $TXN_ID], 'order_by' => ['PAY_timestamp' => 'ASC']];
204
+		// if provided with a status, search specifically for that status. Otherwise get them all
205
+		if ($status_of_payment) {
206
+			$query_params[0]['STS_ID'] = $status_of_payment;
207
+		}
208
+		// retrieve payments
209
+		return $this->get_all($query_params);
210
+	}
211
+
212
+
213
+	/**
214
+	 * Only gets payments which have been approved
215
+	 *
216
+	 * @param int $TXN_ID
217
+	 * @return EE_Payment[]
218
+	 * @throws EE_Error
219
+	 * @throws ReflectionException
220
+	 */
221
+	public function get_approved_payments_for_transaction(int $TXN_ID = 0): array
222
+	{
223
+		return $this->get_payments_for_transaction($TXN_ID, EEM_Payment::status_id_approved);
224
+	}
225
+
226
+
227
+	/**
228
+	 * retrieve  all payments from db between two dates,
229
+	 *
230
+	 * @param string $start_date        incoming start date. If empty the beginning of today is used.
231
+	 * @param string $end_date          incoming end date. If empty the end of today is used.
232
+	 * @param string $format            If you include $start_date or $end_date then you must include the format string
233
+	 *                                  for the format your date is in.
234
+	 * @param string $timezone          If your range is in a different timezone then the current setting on this
235
+	 *                                  WordPress install, then include it here.
236
+	 * @return EE_Payment[]
237
+	 * @throws ReflectionException
238
+	 *
239
+	 * @throws EE_Error
240
+	 */
241
+	public function get_payments_made_between_dates(
242
+		string $start_date = '',
243
+		string $end_date = '',
244
+		string $format = '',
245
+		string $timezone = ''
246
+	): array {
247
+		$timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
248
+		// if $start_date or $end date, verify $format is included.
249
+		if ((! empty($start_date) || ! empty($end_date)) && empty($format)) {
250
+			throw new EE_Error(__('You included a start date and/or a end date for this method but did not include a format string.  The format string is needed for setting up the query',
251
+								  'event_espresso'));
252
+		}
253
+		$now = new DateTime('now');
254
+		// setup timezone objects once
255
+		$modelDateTimeZone  = new DateTimeZone($this->_timezone);
256
+		$passedDateTimeZone = new DateTimeZone($timezone);
257
+		// setup start date
258
+		$start_date = ! empty($start_date) ? date_create_from_format($format, $start_date, $passedDateTimeZone) : $now;
259
+		EEH_DTT_Helper::setTimezone($start_date, $modelDateTimeZone);
260
+		$start_date = $start_date->format('Y-m-d') . ' 00:00:00';
261
+		$start_date = strtotime($start_date);
262
+		// setup end date
263
+		$end_date = ! empty($end_date) ? date_create_from_format($format, $end_date, $passedDateTimeZone) : $now;
264
+		EEH_DTT_Helper::setTimezone($end_date, $modelDateTimeZone);
265
+		$end_date = $end_date->format('Y-m-d') . ' 23:59:59';
266
+		$end_date = strtotime($end_date);
267
+
268
+		// make sure our start date is the lowest value and vice versa
269
+		$start = min($start_date, $end_date);
270
+		$end   = max($start_date, $end_date);
271
+
272
+		// yes we generated the date and time string in utc but we WANT this start date and time used in the set timezone on the model.
273
+		$start_date = $this->convert_datetime_for_query('PAY_timestamp',
274
+														date('Y-m-d', $start) . ' 00:00:00',
275
+														'Y-m-d H:i:s',
276
+														$this->get_timezone());
277
+		$end_date   = $this->convert_datetime_for_query('PAY_timestamp',
278
+														date('Y-m-d', $end) . ' 23:59:59',
279
+														'Y-m-d H:i:s',
280
+														$this->get_timezone());
281
+
282
+		return $this->get_all([['PAY_timestamp' => ['>=', $start_date], 'PAY_timestamp*' => ['<=', $end_date]]]);
283
+	}
284
+
285
+	/**
286
+	 * methods for EEMI_Payment
287
+	 */
288
+	/**
289
+	 * returns a string for the approved status
290
+	 *
291
+	 * @return  string
292
+	 */
293
+	public function approved_status(): string
294
+	{
295
+		return self::status_id_approved;
296
+	}
297
+
298
+
299
+	/**
300
+	 * returns a string for the pending status
301
+	 *
302
+	 * @return  string
303
+	 */
304
+	public function pending_status(): string
305
+	{
306
+		return self::status_id_pending;
307
+	}
308
+
309
+
310
+	/**
311
+	 * returns a string for the cancelled status
312
+	 *
313
+	 * @return  string
314
+	 */
315
+	public function cancelled_status(): string
316
+	{
317
+		return self::status_id_cancelled;
318
+	}
319
+
320
+
321
+	/**
322
+	 * returns a string for the failed status
323
+	 *
324
+	 * @return  string
325
+	 */
326
+	public function failed_status(): string
327
+	{
328
+		return self::status_id_failed;
329
+	}
330
+
331
+
332
+	/**
333
+	 * returns a string for the declined status
334
+	 *
335
+	 * @return  string
336
+	 */
337
+	public function declined_status(): string
338
+	{
339
+		return self::status_id_declined;
340
+	}
341 341
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
                 ),
159 159
             ],
160 160
         ];
161
-        $this->_model_relations        = [
161
+        $this->_model_relations = [
162 162
             'Transaction'          => new EE_Belongs_To_Relation(),
163 163
             'Status'               => new EE_Belongs_To_Relation(),
164 164
             'Payment_Method'       => new EE_Belongs_To_Relation(),
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
     ): array {
247 247
         $timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
248 248
         // if $start_date or $end date, verify $format is included.
249
-        if ((! empty($start_date) || ! empty($end_date)) && empty($format)) {
249
+        if (( ! empty($start_date) || ! empty($end_date)) && empty($format)) {
250 250
             throw new EE_Error(__('You included a start date and/or a end date for this method but did not include a format string.  The format string is needed for setting up the query',
251 251
                                   'event_espresso'));
252 252
         }
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
         // setup start date
258 258
         $start_date = ! empty($start_date) ? date_create_from_format($format, $start_date, $passedDateTimeZone) : $now;
259 259
         EEH_DTT_Helper::setTimezone($start_date, $modelDateTimeZone);
260
-        $start_date = $start_date->format('Y-m-d') . ' 00:00:00';
260
+        $start_date = $start_date->format('Y-m-d').' 00:00:00';
261 261
         $start_date = strtotime($start_date);
262 262
         // setup end date
263 263
         $end_date = ! empty($end_date) ? date_create_from_format($format, $end_date, $passedDateTimeZone) : $now;
264 264
         EEH_DTT_Helper::setTimezone($end_date, $modelDateTimeZone);
265
-        $end_date = $end_date->format('Y-m-d') . ' 23:59:59';
265
+        $end_date = $end_date->format('Y-m-d').' 23:59:59';
266 266
         $end_date = strtotime($end_date);
267 267
 
268 268
         // make sure our start date is the lowest value and vice versa
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 
272 272
         // yes we generated the date and time string in utc but we WANT this start date and time used in the set timezone on the model.
273 273
         $start_date = $this->convert_datetime_for_query('PAY_timestamp',
274
-                                                        date('Y-m-d', $start) . ' 00:00:00',
274
+                                                        date('Y-m-d', $start).' 00:00:00',
275 275
                                                         'Y-m-d H:i:s',
276 276
                                                         $this->get_timezone());
277
-        $end_date   = $this->convert_datetime_for_query('PAY_timestamp',
278
-                                                        date('Y-m-d', $end) . ' 23:59:59',
277
+        $end_date = $this->convert_datetime_for_query('PAY_timestamp',
278
+                                                        date('Y-m-d', $end).' 23:59:59',
279 279
                                                         'Y-m-d H:i:s',
280 280
                                                         $this->get_timezone());
281 281
 
Please login to merge, or discard this patch.
core/db_models/EEM_Venue.model.php 2 patches
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -10,209 +10,209 @@
 block discarded – undo
10 10
 class EEM_Venue extends EEM_CPT_Base
11 11
 {
12 12
 
13
-    /**
14
-     * @var EEM_Venue
15
-     */
16
-    protected static $_instance;
13
+	/**
14
+	 * @var EEM_Venue
15
+	 */
16
+	protected static $_instance;
17 17
 
18 18
 
19
-    /**
20
-     * EEM_Venue constructor.
21
-     *
22
-     * @param string $timezone
23
-     * @throws EE_Error
24
-     */
25
-    protected function __construct(string $timezone = '')
26
-    {
27
-        $this->singular_item    = esc_html__('Venue', 'event_espresso');
28
-        $this->plural_item      = esc_html__('Venues', 'event_espresso');
29
-        $this->_tables          = [
30
-            'Venue_CPT'  => new EE_Primary_Table('posts', 'ID'),
31
-            'Venue_Meta' => new EE_Secondary_Table('esp_venue_meta', 'VNUM_ID', 'VNU_ID'),
32
-        ];
33
-        $this->_fields          = [
34
-            'Venue_CPT'  => [
35
-                'VNU_ID'         => new EE_Primary_Key_Int_Field(
36
-                    'ID',
37
-                    esc_html__("Venue ID", "event_espresso")
38
-                ),
39
-                'VNU_name'       => new EE_Plain_Text_Field(
40
-                    'post_title',
41
-                    esc_html__("Venue Name", "event_espresso"),
42
-                    false,
43
-                    ''
44
-                ),
45
-                'VNU_desc'       => new EE_Post_Content_Field(
46
-                    'post_content',
47
-                    esc_html__("Venue Description", "event_espresso"),
48
-                    false,
49
-                    ''
50
-                ),
51
-                'VNU_identifier' => new EE_Slug_Field(
52
-                    'post_name',
53
-                    esc_html__("Venue Identifier", "event_espresso"),
54
-                    false,
55
-                    ''
56
-                ),
57
-                'VNU_created'    => new EE_Datetime_Field(
58
-                    'post_date',
59
-                    esc_html__("Date Venue Created", "event_espresso"),
60
-                    false,
61
-                    EE_Datetime_Field::now
62
-                ),
63
-                'VNU_short_desc' => new EE_Plain_Text_Field(
64
-                    'post_excerpt',
65
-                    esc_html__("Short Description of Venue", "event_espresso"),
66
-                    true,
67
-                    ''
68
-                ),
69
-                'VNU_modified'   => new EE_Datetime_Field(
70
-                    'post_modified',
71
-                    esc_html__("Venue Modified Date", "event_espresso"),
72
-                    false,
73
-                    EE_Datetime_Field::now
74
-                ),
75
-                'VNU_wp_user'    => new EE_WP_User_Field(
76
-                    'post_author',
77
-                    esc_html__("Venue Creator ID", "event_espresso"),
78
-                    false
79
-                ),
80
-                'parent'         => new EE_Integer_Field(
81
-                    'post_parent',
82
-                    esc_html__("Venue Parent ID", "event_espresso"),
83
-                    false,
84
-                    0
85
-                ),
86
-                'VNU_order'      => new EE_Integer_Field(
87
-                    'menu_order',
88
-                    esc_html__("Venue order", "event_espresso"),
89
-                    false,
90
-                    1
91
-                ),
92
-                'post_type'      => new EE_WP_Post_Type_Field('espresso_venues'),
93
-                'password'       => new EE_Password_Field(
94
-                    'post_password',
95
-                    esc_html__('Password', 'event_espresso'),
96
-                    false,
97
-                    '',
98
-                    [
99
-                        'VNU_desc',
100
-                        'VNU_short_desc',
101
-                        'VNU_address',
102
-                        'VNU_address2',
103
-                        'VNU_city',
104
-                        'STA_ID',
105
-                        'CNT_ISO',
106
-                        'VNU_zip',
107
-                        'VNU_phone',
108
-                        'VNU_capacity',
109
-                        'VNU_url',
110
-                        'VNU_virtual_phone',
111
-                        'VNU_virtual_url',
112
-                        'VNU_google_map_link',
113
-                        'VNU_enable_for_gmap',
114
-                    ]
115
-                ),
116
-            ],
117
-            'Venue_Meta' => [
118
-                'VNUM_ID'             => new EE_DB_Only_Int_Field(
119
-                    'VNUM_ID',
120
-                    esc_html__("ID of Venue Meta Row", "event_espresso"),
121
-                    false
122
-                ),
123
-                'VNU_ID_fk'           => new EE_DB_Only_Int_Field(
124
-                    'VNU_ID',
125
-                    esc_html__("Foreign Key to Venue Post ", "event_espresso"),
126
-                    false
127
-                ),
128
-                'VNU_address'         => new EE_Plain_Text_Field(
129
-                    'VNU_address',
130
-                    esc_html__("Venue Address line 1", "event_espresso"),
131
-                    true,
132
-                    ''
133
-                ),
134
-                'VNU_address2'        => new EE_Plain_Text_Field(
135
-                    'VNU_address2',
136
-                    esc_html__("Venue Address line 2", "event_espresso"),
137
-                    true,
138
-                    ''
139
-                ),
140
-                'VNU_city'            => new EE_Plain_Text_Field(
141
-                    'VNU_city',
142
-                    esc_html__("Venue City", "event_espresso"),
143
-                    true,
144
-                    ''
145
-                ),
146
-                'STA_ID'              => new EE_Foreign_Key_Int_Field(
147
-                    'STA_ID',
148
-                    esc_html__("State ID", "event_espresso"),
149
-                    true,
150
-                    null,
151
-                    'State'
152
-                ),
153
-                'CNT_ISO'             => new EE_Foreign_Key_String_Field(
154
-                    'CNT_ISO',
155
-                    esc_html__("Country Code", "event_espresso"),
156
-                    true,
157
-                    null,
158
-                    'Country'
159
-                ),
160
-                'VNU_zip'             => new EE_Plain_Text_Field(
161
-                    'VNU_zip',
162
-                    esc_html__("Venue Zip/Postal Code", "event_espresso"),
163
-                    true
164
-                ),
165
-                'VNU_phone'           => new EE_Plain_Text_Field(
166
-                    'VNU_phone',
167
-                    esc_html__("Venue Phone", "event_espresso"),
168
-                    true
169
-                ),
170
-                'VNU_capacity'        => new EE_Infinite_Integer_Field(
171
-                    'VNU_capacity',
172
-                    esc_html__("Venue Capacity", "event_espresso"),
173
-                    true,
174
-                    EE_INF
175
-                ),
176
-                'VNU_url'             => new EE_Plain_Text_Field(
177
-                    'VNU_url',
178
-                    esc_html__('Venue Website', 'event_espresso'),
179
-                    true
180
-                ),
181
-                'VNU_virtual_phone'   => new EE_Plain_Text_Field(
182
-                    'VNU_virtual_phone',
183
-                    esc_html__('Call in Number', 'event_espresso'),
184
-                    true
185
-                ),
186
-                'VNU_virtual_url'     => new EE_Plain_Text_Field(
187
-                    'VNU_virtual_url',
188
-                    esc_html__('Virtual URL', 'event_espresso'),
189
-                    true
190
-                ),
191
-                'VNU_google_map_link' => new EE_Plain_Text_Field(
192
-                    'VNU_google_map_link',
193
-                    esc_html__('Google Map Link', 'event_espresso'),
194
-                    true
195
-                ),
196
-                'VNU_enable_for_gmap' => new EE_Boolean_Field(
197
-                    'VNU_enable_for_gmap',
198
-                    esc_html__('Show Google Map?', 'event_espresso'),
199
-                    false,
200
-                    false
201
-                ),
202
-            ],
203
-        ];
204
-        $this->_model_relations = [
205
-            'Event'             => new EE_HABTM_Relation('Event_Venue'),
206
-            'State'             => new EE_Belongs_To_Relation(),
207
-            'Country'           => new EE_Belongs_To_Relation(),
208
-            'Event_Venue'       => new EE_Has_Many_Relation(),
209
-            'WP_User'           => new EE_Belongs_To_Relation(),
210
-            'Term_Relationship' => new EE_Has_Many_Relation(),
211
-            'Term_Taxonomy'     => new EE_HABTM_Relation('Term_Relationship'),
212
-        ];
213
-        // this model is generally available for reading
214
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
215
-        $this->model_chain_to_password                            = '';
216
-        parent::__construct($timezone);
217
-    }
19
+	/**
20
+	 * EEM_Venue constructor.
21
+	 *
22
+	 * @param string $timezone
23
+	 * @throws EE_Error
24
+	 */
25
+	protected function __construct(string $timezone = '')
26
+	{
27
+		$this->singular_item    = esc_html__('Venue', 'event_espresso');
28
+		$this->plural_item      = esc_html__('Venues', 'event_espresso');
29
+		$this->_tables          = [
30
+			'Venue_CPT'  => new EE_Primary_Table('posts', 'ID'),
31
+			'Venue_Meta' => new EE_Secondary_Table('esp_venue_meta', 'VNUM_ID', 'VNU_ID'),
32
+		];
33
+		$this->_fields          = [
34
+			'Venue_CPT'  => [
35
+				'VNU_ID'         => new EE_Primary_Key_Int_Field(
36
+					'ID',
37
+					esc_html__("Venue ID", "event_espresso")
38
+				),
39
+				'VNU_name'       => new EE_Plain_Text_Field(
40
+					'post_title',
41
+					esc_html__("Venue Name", "event_espresso"),
42
+					false,
43
+					''
44
+				),
45
+				'VNU_desc'       => new EE_Post_Content_Field(
46
+					'post_content',
47
+					esc_html__("Venue Description", "event_espresso"),
48
+					false,
49
+					''
50
+				),
51
+				'VNU_identifier' => new EE_Slug_Field(
52
+					'post_name',
53
+					esc_html__("Venue Identifier", "event_espresso"),
54
+					false,
55
+					''
56
+				),
57
+				'VNU_created'    => new EE_Datetime_Field(
58
+					'post_date',
59
+					esc_html__("Date Venue Created", "event_espresso"),
60
+					false,
61
+					EE_Datetime_Field::now
62
+				),
63
+				'VNU_short_desc' => new EE_Plain_Text_Field(
64
+					'post_excerpt',
65
+					esc_html__("Short Description of Venue", "event_espresso"),
66
+					true,
67
+					''
68
+				),
69
+				'VNU_modified'   => new EE_Datetime_Field(
70
+					'post_modified',
71
+					esc_html__("Venue Modified Date", "event_espresso"),
72
+					false,
73
+					EE_Datetime_Field::now
74
+				),
75
+				'VNU_wp_user'    => new EE_WP_User_Field(
76
+					'post_author',
77
+					esc_html__("Venue Creator ID", "event_espresso"),
78
+					false
79
+				),
80
+				'parent'         => new EE_Integer_Field(
81
+					'post_parent',
82
+					esc_html__("Venue Parent ID", "event_espresso"),
83
+					false,
84
+					0
85
+				),
86
+				'VNU_order'      => new EE_Integer_Field(
87
+					'menu_order',
88
+					esc_html__("Venue order", "event_espresso"),
89
+					false,
90
+					1
91
+				),
92
+				'post_type'      => new EE_WP_Post_Type_Field('espresso_venues'),
93
+				'password'       => new EE_Password_Field(
94
+					'post_password',
95
+					esc_html__('Password', 'event_espresso'),
96
+					false,
97
+					'',
98
+					[
99
+						'VNU_desc',
100
+						'VNU_short_desc',
101
+						'VNU_address',
102
+						'VNU_address2',
103
+						'VNU_city',
104
+						'STA_ID',
105
+						'CNT_ISO',
106
+						'VNU_zip',
107
+						'VNU_phone',
108
+						'VNU_capacity',
109
+						'VNU_url',
110
+						'VNU_virtual_phone',
111
+						'VNU_virtual_url',
112
+						'VNU_google_map_link',
113
+						'VNU_enable_for_gmap',
114
+					]
115
+				),
116
+			],
117
+			'Venue_Meta' => [
118
+				'VNUM_ID'             => new EE_DB_Only_Int_Field(
119
+					'VNUM_ID',
120
+					esc_html__("ID of Venue Meta Row", "event_espresso"),
121
+					false
122
+				),
123
+				'VNU_ID_fk'           => new EE_DB_Only_Int_Field(
124
+					'VNU_ID',
125
+					esc_html__("Foreign Key to Venue Post ", "event_espresso"),
126
+					false
127
+				),
128
+				'VNU_address'         => new EE_Plain_Text_Field(
129
+					'VNU_address',
130
+					esc_html__("Venue Address line 1", "event_espresso"),
131
+					true,
132
+					''
133
+				),
134
+				'VNU_address2'        => new EE_Plain_Text_Field(
135
+					'VNU_address2',
136
+					esc_html__("Venue Address line 2", "event_espresso"),
137
+					true,
138
+					''
139
+				),
140
+				'VNU_city'            => new EE_Plain_Text_Field(
141
+					'VNU_city',
142
+					esc_html__("Venue City", "event_espresso"),
143
+					true,
144
+					''
145
+				),
146
+				'STA_ID'              => new EE_Foreign_Key_Int_Field(
147
+					'STA_ID',
148
+					esc_html__("State ID", "event_espresso"),
149
+					true,
150
+					null,
151
+					'State'
152
+				),
153
+				'CNT_ISO'             => new EE_Foreign_Key_String_Field(
154
+					'CNT_ISO',
155
+					esc_html__("Country Code", "event_espresso"),
156
+					true,
157
+					null,
158
+					'Country'
159
+				),
160
+				'VNU_zip'             => new EE_Plain_Text_Field(
161
+					'VNU_zip',
162
+					esc_html__("Venue Zip/Postal Code", "event_espresso"),
163
+					true
164
+				),
165
+				'VNU_phone'           => new EE_Plain_Text_Field(
166
+					'VNU_phone',
167
+					esc_html__("Venue Phone", "event_espresso"),
168
+					true
169
+				),
170
+				'VNU_capacity'        => new EE_Infinite_Integer_Field(
171
+					'VNU_capacity',
172
+					esc_html__("Venue Capacity", "event_espresso"),
173
+					true,
174
+					EE_INF
175
+				),
176
+				'VNU_url'             => new EE_Plain_Text_Field(
177
+					'VNU_url',
178
+					esc_html__('Venue Website', 'event_espresso'),
179
+					true
180
+				),
181
+				'VNU_virtual_phone'   => new EE_Plain_Text_Field(
182
+					'VNU_virtual_phone',
183
+					esc_html__('Call in Number', 'event_espresso'),
184
+					true
185
+				),
186
+				'VNU_virtual_url'     => new EE_Plain_Text_Field(
187
+					'VNU_virtual_url',
188
+					esc_html__('Virtual URL', 'event_espresso'),
189
+					true
190
+				),
191
+				'VNU_google_map_link' => new EE_Plain_Text_Field(
192
+					'VNU_google_map_link',
193
+					esc_html__('Google Map Link', 'event_espresso'),
194
+					true
195
+				),
196
+				'VNU_enable_for_gmap' => new EE_Boolean_Field(
197
+					'VNU_enable_for_gmap',
198
+					esc_html__('Show Google Map?', 'event_espresso'),
199
+					false,
200
+					false
201
+				),
202
+			],
203
+		];
204
+		$this->_model_relations = [
205
+			'Event'             => new EE_HABTM_Relation('Event_Venue'),
206
+			'State'             => new EE_Belongs_To_Relation(),
207
+			'Country'           => new EE_Belongs_To_Relation(),
208
+			'Event_Venue'       => new EE_Has_Many_Relation(),
209
+			'WP_User'           => new EE_Belongs_To_Relation(),
210
+			'Term_Relationship' => new EE_Has_Many_Relation(),
211
+			'Term_Taxonomy'     => new EE_HABTM_Relation('Term_Relationship'),
212
+		];
213
+		// this model is generally available for reading
214
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
215
+		$this->model_chain_to_password                            = '';
216
+		parent::__construct($timezone);
217
+	}
218 218
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
             'Venue_CPT'  => new EE_Primary_Table('posts', 'ID'),
31 31
             'Venue_Meta' => new EE_Secondary_Table('esp_venue_meta', 'VNUM_ID', 'VNU_ID'),
32 32
         ];
33
-        $this->_fields          = [
33
+        $this->_fields = [
34 34
             'Venue_CPT'  => [
35 35
                 'VNU_ID'         => new EE_Primary_Key_Int_Field(
36 36
                     'ID',
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
             'Term_Taxonomy'     => new EE_HABTM_Relation('Term_Relationship'),
212 212
         ];
213 213
         // this model is generally available for reading
214
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
214
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
215 215
         $this->model_chain_to_password                            = '';
216 216
         parent::__construct($timezone);
217 217
     }
Please login to merge, or discard this patch.
core/db_models/EEM_Extra_Join.model.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -21,65 +21,65 @@
 block discarded – undo
21 21
  */
22 22
 class EEM_Extra_Join extends EEM_Base
23 23
 {
24
-    // private instance of the Extra Join object
25
-    protected static $_instance;
24
+	// private instance of the Extra Join object
25
+	protected static $_instance;
26 26
 
27 27
 
28
-    /**
29
-     * EEM_Extra_Join constructor.
30
-     *
31
-     * @param string $timezone
32
-     * @throws EE_Error
33
-     */
34
-    public function __construct(string $timezone = '')
35
-    {
36
-        $models_this_can_join = array_keys(EE_Registry::instance()->non_abstract_db_models);
37
-        $this->_tables        = [
38
-            'Extra_Join' => new EE_Primary_Table('esp_extra_join', 'EXJ_ID'),
39
-        ];
40
-        $this->_fields        = [
41
-            'Extra_Join' => [
42
-                'EXJ_ID'                => new EE_Primary_Key_Int_Field(
43
-                    'EXJ_ID', esc_html__('Extra Join ID', 'event_espresso')
44
-                ),
45
-                'EXJ_first_model_ID'    => new EE_Foreign_Key_String_Field(
46
-                    'EXJ_first_model_ID',
47
-                    esc_html__('First Model ID', 'event_espresso'),
48
-                    true,
49
-                    0,
50
-                    $models_this_can_join
51
-                ),
52
-                'EXJ_first_model_name'  => new EE_Any_Foreign_Model_Name_Field(
53
-                    'EXJ_first_model_name',
54
-                    esc_html__('First Model Name', 'event_espresso'),
55
-                    true,
56
-                    '',
57
-                    $models_this_can_join
58
-                ),
59
-                'EXJ_second_model_ID'   => new EE_Foreign_Key_String_Field(
60
-                    'EXJ_second_model_ID',
61
-                    esc_html__('Second Model ID', 'event_espresso'),
62
-                    true,
63
-                    0,
64
-                    $models_this_can_join
65
-                ),
66
-                'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field(
67
-                    'EXJ_second_model_name',
68
-                    esc_html__('Second Model Name', 'event_espresso'),
69
-                    true,
70
-                    '',
71
-                    $models_this_can_join
72
-                ),
28
+	/**
29
+	 * EEM_Extra_Join constructor.
30
+	 *
31
+	 * @param string $timezone
32
+	 * @throws EE_Error
33
+	 */
34
+	public function __construct(string $timezone = '')
35
+	{
36
+		$models_this_can_join = array_keys(EE_Registry::instance()->non_abstract_db_models);
37
+		$this->_tables        = [
38
+			'Extra_Join' => new EE_Primary_Table('esp_extra_join', 'EXJ_ID'),
39
+		];
40
+		$this->_fields        = [
41
+			'Extra_Join' => [
42
+				'EXJ_ID'                => new EE_Primary_Key_Int_Field(
43
+					'EXJ_ID', esc_html__('Extra Join ID', 'event_espresso')
44
+				),
45
+				'EXJ_first_model_ID'    => new EE_Foreign_Key_String_Field(
46
+					'EXJ_first_model_ID',
47
+					esc_html__('First Model ID', 'event_espresso'),
48
+					true,
49
+					0,
50
+					$models_this_can_join
51
+				),
52
+				'EXJ_first_model_name'  => new EE_Any_Foreign_Model_Name_Field(
53
+					'EXJ_first_model_name',
54
+					esc_html__('First Model Name', 'event_espresso'),
55
+					true,
56
+					'',
57
+					$models_this_can_join
58
+				),
59
+				'EXJ_second_model_ID'   => new EE_Foreign_Key_String_Field(
60
+					'EXJ_second_model_ID',
61
+					esc_html__('Second Model ID', 'event_espresso'),
62
+					true,
63
+					0,
64
+					$models_this_can_join
65
+				),
66
+				'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field(
67
+					'EXJ_second_model_name',
68
+					esc_html__('Second Model Name', 'event_espresso'),
69
+					true,
70
+					'',
71
+					$models_this_can_join
72
+				),
73 73
 
74
-            ],
75
-        ];
76
-        // this model is weird in that it has two foreign key columns which can point to any model/table.
77
-        // eg a foreign key to event will be in "EXJ_first_model_ID", provided the other
78
-        // model linked to is alphabetically greater than event (eg venue).
79
-        // but if the model linked to is alphabetically lower (eg attendee),
80
-        // the foreign key to the event will be in "EXJ_second_model_ID"
81
-        // so normal usage of foreign keys is weird. So don't define any
82
-        // relations to other models because they won't work properly with this model
83
-        parent::__construct($timezone);
84
-    }
74
+			],
75
+		];
76
+		// this model is weird in that it has two foreign key columns which can point to any model/table.
77
+		// eg a foreign key to event will be in "EXJ_first_model_ID", provided the other
78
+		// model linked to is alphabetically greater than event (eg venue).
79
+		// but if the model linked to is alphabetically lower (eg attendee),
80
+		// the foreign key to the event will be in "EXJ_second_model_ID"
81
+		// so normal usage of foreign keys is weird. So don't define any
82
+		// relations to other models because they won't work properly with this model
83
+		parent::__construct($timezone);
84
+	}
85 85
 }
Please login to merge, or discard this patch.
core/db_models/EEM_State.model.php 2 patches
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -10,213 +10,213 @@
 block discarded – undo
10 10
 class EEM_State extends EEM_Base
11 11
 {
12 12
 
13
-    /**
14
-     * @var EEM_State
15
-     */
16
-    protected static $_instance;
17
-
18
-    /**
19
-     * @var EE_State[]
20
-     */
21
-    private static $_all_states;
22
-
23
-    /**
24
-     * @var EE_State[]
25
-     */
26
-    private static $_active_states;
27
-
28
-
29
-    protected function __construct(string $timezone = '')
30
-    {
31
-        $this->singular_item = esc_html__('State/Province', 'event_espresso');
32
-        $this->plural_item   = esc_html__('States/Provinces', 'event_espresso');
33
-
34
-        $this->_tables = [
35
-            'State' => new EE_Primary_Table('esp_state', 'STA_ID'),
36
-        ];
37
-
38
-        $this->_fields          = [
39
-            'State' => [
40
-                'STA_ID'     => new EE_Primary_Key_Int_Field(
41
-                    'STA_ID',
42
-                    esc_html__('State ID', 'event_espresso')
43
-                ),
44
-                'CNT_ISO'    => new EE_Foreign_Key_String_Field(
45
-                    'CNT_ISO',
46
-                    esc_html__('Country ISO Code', 'event_espresso'),
47
-                    false,
48
-                    null,
49
-                    'Country'
50
-                ),
51
-                'STA_abbrev' => new EE_Plain_Text_Field(
52
-                    'STA_abbrev',
53
-                    esc_html__('State Abbreviation', 'event_espresso'),
54
-                    false,
55
-                    ''
56
-                ),
57
-                'STA_name'   => new EE_Plain_Text_Field(
58
-                    'STA_name',
59
-                    esc_html__('State Name', 'event_espresso'),
60
-                    false,
61
-                    ''
62
-                ),
63
-                'STA_active' => new EE_Boolean_Field(
64
-                    'STA_active',
65
-                    esc_html__('State Active Flag', 'event_espresso'),
66
-                    false,
67
-                    false
68
-                ),
69
-            ],
70
-        ];
71
-        $this->_model_relations = [
72
-            'Attendee' => new EE_Has_Many_Relation(),
73
-            'Country'  => new EE_Belongs_To_Relation(),
74
-            'Venue'    => new EE_Has_Many_Relation(),
75
-        ];
76
-        // this model is generally available for reading
77
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
78
-        // @todo: only show STA_active
79
-        parent::__construct($timezone);
80
-    }
81
-
82
-
83
-    /**
84
-     * reset_cached_states
85
-     *
86
-     * @return void
87
-     */
88
-    public function reset_cached_states()
89
-    {
90
-        EEM_State::$_active_states = null;
91
-        EEM_State::$_all_states    = null;
92
-    }
93
-
94
-
95
-    /**
96
-     * _get_states
97
-     *
98
-     * @return EE_State[]
99
-     * @throws EE_Error
100
-     * @throws ReflectionException
101
-     */
102
-    public function get_all_states(): array
103
-    {
104
-        if (self::$_all_states === null) {
105
-            self::$_all_states = $this->get_all(['order_by' => ['STA_name' => 'ASC'], 'limit' => [0, 99999]]);
106
-        }
107
-        return self::$_all_states;
108
-    }
109
-
110
-
111
-    /**
112
-     * @param EE_Country[] $countries
113
-     * @param bool         $flush_cache
114
-     * @return EE_State[]
115
-     * @throws EE_Error
116
-     * @throws ReflectionException
117
-     */
118
-    public function get_all_active_states(array $countries = [], bool $flush_cache = false): array
119
-    {
120
-        if (! self::$_active_states || $flush_cache) {
121
-            $countries            = ! empty($countries) && is_array($countries)
122
-                ? $countries
123
-                : EEM_Country::instance()->get_all_active_countries();
124
-            self::$_active_states = $this->get_all(
125
-                [
126
-                    [
127
-                        'STA_active' => true,
128
-                        'CNT_ISO'    => ['IN', array_keys($countries)],
129
-                    ],
130
-                    'order_by'   => ['STA_name' => 'ASC'],
131
-                    'limit'      => [0, 99999],
132
-                    'force_join' => ['Country'],
133
-                ]
134
-            );
135
-        }
136
-        return self::$_active_states;
137
-    }
138
-
139
-
140
-    /**
141
-     *  get_all_states_of_active_countries
142
-     *
143
-     * @return EE_State[]
144
-     * @throws EE_Error
145
-     * @throws ReflectionException
146
-     */
147
-    public function get_all_states_of_active_countries(): array
148
-    {
149
-        return $this->get_all(
150
-            [
151
-                ['Country.CNT_active' => true, 'STA_active' => true],
152
-                'order_by' => ['Country.CNT_name' => 'ASC', 'STA_name' => 'ASC'],
153
-            ]
154
-        );
155
-    }
156
-
157
-
158
-    /**
159
-     *  get_all_states_of_active_countries
160
-     *
161
-     * @param $countries
162
-     * @return EE_State[]
163
-     * @throws EE_Error
164
-     * @throws ReflectionException
165
-     */
166
-    public function get_all_active_states_for_these_countries($countries): array
167
-    {
168
-        if (! $countries) {
169
-            return [];
170
-        }
171
-        return $this->get_all(
172
-            [
173
-                ['Country.CNT_ISO' => ['IN', array_keys($countries)], 'STA_active' => true],
174
-                'order_by' => ['Country.CNT_name' => 'ASC', 'STA_name' => 'ASC'],
175
-            ]
176
-        );
177
-    }
178
-
179
-
180
-    /**
181
-     *  get_all_states_of_active_countries
182
-     *
183
-     * @param $countries
184
-     * @return EE_State[]
185
-     * @throws EE_Error
186
-     * @throws ReflectionException
187
-     */
188
-    public function get_all_states_for_these_countries($countries): array
189
-    {
190
-        if (! $countries) {
191
-            return [];
192
-        }
193
-        return $this->get_all(
194
-            [
195
-                ['Country.CNT_ISO' => ['IN', array_keys($countries)]],
196
-                'order_by' => ['Country.CNT_name' => 'ASC', 'STA_name' => 'ASC'],
197
-            ]
198
-        );
199
-    }
200
-
201
-
202
-    /**
203
-     * Gets the state's name by its ID
204
-     *
205
-     * @param string $state_ID
206
-     * @return string
207
-     * @throws EE_Error
208
-     * @throws ReflectionException
209
-     */
210
-    public function get_state_name_by_ID(string $state_ID): string
211
-    {
212
-        if (
213
-            isset(self::$_all_states[ $state_ID ]) && self::$_all_states[ $state_ID ] instanceof EE_State
214
-        ) {
215
-            return self::$_all_states[ $state_ID ]->name();
216
-        }
217
-        $names = $this->get_col([['STA_ID' => $state_ID], 'limit' => 1], 'STA_name');
218
-        return is_array($names) && ! empty($names)
219
-            ? reset($names)
220
-            : '';
221
-    }
13
+	/**
14
+	 * @var EEM_State
15
+	 */
16
+	protected static $_instance;
17
+
18
+	/**
19
+	 * @var EE_State[]
20
+	 */
21
+	private static $_all_states;
22
+
23
+	/**
24
+	 * @var EE_State[]
25
+	 */
26
+	private static $_active_states;
27
+
28
+
29
+	protected function __construct(string $timezone = '')
30
+	{
31
+		$this->singular_item = esc_html__('State/Province', 'event_espresso');
32
+		$this->plural_item   = esc_html__('States/Provinces', 'event_espresso');
33
+
34
+		$this->_tables = [
35
+			'State' => new EE_Primary_Table('esp_state', 'STA_ID'),
36
+		];
37
+
38
+		$this->_fields          = [
39
+			'State' => [
40
+				'STA_ID'     => new EE_Primary_Key_Int_Field(
41
+					'STA_ID',
42
+					esc_html__('State ID', 'event_espresso')
43
+				),
44
+				'CNT_ISO'    => new EE_Foreign_Key_String_Field(
45
+					'CNT_ISO',
46
+					esc_html__('Country ISO Code', 'event_espresso'),
47
+					false,
48
+					null,
49
+					'Country'
50
+				),
51
+				'STA_abbrev' => new EE_Plain_Text_Field(
52
+					'STA_abbrev',
53
+					esc_html__('State Abbreviation', 'event_espresso'),
54
+					false,
55
+					''
56
+				),
57
+				'STA_name'   => new EE_Plain_Text_Field(
58
+					'STA_name',
59
+					esc_html__('State Name', 'event_espresso'),
60
+					false,
61
+					''
62
+				),
63
+				'STA_active' => new EE_Boolean_Field(
64
+					'STA_active',
65
+					esc_html__('State Active Flag', 'event_espresso'),
66
+					false,
67
+					false
68
+				),
69
+			],
70
+		];
71
+		$this->_model_relations = [
72
+			'Attendee' => new EE_Has_Many_Relation(),
73
+			'Country'  => new EE_Belongs_To_Relation(),
74
+			'Venue'    => new EE_Has_Many_Relation(),
75
+		];
76
+		// this model is generally available for reading
77
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
78
+		// @todo: only show STA_active
79
+		parent::__construct($timezone);
80
+	}
81
+
82
+
83
+	/**
84
+	 * reset_cached_states
85
+	 *
86
+	 * @return void
87
+	 */
88
+	public function reset_cached_states()
89
+	{
90
+		EEM_State::$_active_states = null;
91
+		EEM_State::$_all_states    = null;
92
+	}
93
+
94
+
95
+	/**
96
+	 * _get_states
97
+	 *
98
+	 * @return EE_State[]
99
+	 * @throws EE_Error
100
+	 * @throws ReflectionException
101
+	 */
102
+	public function get_all_states(): array
103
+	{
104
+		if (self::$_all_states === null) {
105
+			self::$_all_states = $this->get_all(['order_by' => ['STA_name' => 'ASC'], 'limit' => [0, 99999]]);
106
+		}
107
+		return self::$_all_states;
108
+	}
109
+
110
+
111
+	/**
112
+	 * @param EE_Country[] $countries
113
+	 * @param bool         $flush_cache
114
+	 * @return EE_State[]
115
+	 * @throws EE_Error
116
+	 * @throws ReflectionException
117
+	 */
118
+	public function get_all_active_states(array $countries = [], bool $flush_cache = false): array
119
+	{
120
+		if (! self::$_active_states || $flush_cache) {
121
+			$countries            = ! empty($countries) && is_array($countries)
122
+				? $countries
123
+				: EEM_Country::instance()->get_all_active_countries();
124
+			self::$_active_states = $this->get_all(
125
+				[
126
+					[
127
+						'STA_active' => true,
128
+						'CNT_ISO'    => ['IN', array_keys($countries)],
129
+					],
130
+					'order_by'   => ['STA_name' => 'ASC'],
131
+					'limit'      => [0, 99999],
132
+					'force_join' => ['Country'],
133
+				]
134
+			);
135
+		}
136
+		return self::$_active_states;
137
+	}
138
+
139
+
140
+	/**
141
+	 *  get_all_states_of_active_countries
142
+	 *
143
+	 * @return EE_State[]
144
+	 * @throws EE_Error
145
+	 * @throws ReflectionException
146
+	 */
147
+	public function get_all_states_of_active_countries(): array
148
+	{
149
+		return $this->get_all(
150
+			[
151
+				['Country.CNT_active' => true, 'STA_active' => true],
152
+				'order_by' => ['Country.CNT_name' => 'ASC', 'STA_name' => 'ASC'],
153
+			]
154
+		);
155
+	}
156
+
157
+
158
+	/**
159
+	 *  get_all_states_of_active_countries
160
+	 *
161
+	 * @param $countries
162
+	 * @return EE_State[]
163
+	 * @throws EE_Error
164
+	 * @throws ReflectionException
165
+	 */
166
+	public function get_all_active_states_for_these_countries($countries): array
167
+	{
168
+		if (! $countries) {
169
+			return [];
170
+		}
171
+		return $this->get_all(
172
+			[
173
+				['Country.CNT_ISO' => ['IN', array_keys($countries)], 'STA_active' => true],
174
+				'order_by' => ['Country.CNT_name' => 'ASC', 'STA_name' => 'ASC'],
175
+			]
176
+		);
177
+	}
178
+
179
+
180
+	/**
181
+	 *  get_all_states_of_active_countries
182
+	 *
183
+	 * @param $countries
184
+	 * @return EE_State[]
185
+	 * @throws EE_Error
186
+	 * @throws ReflectionException
187
+	 */
188
+	public function get_all_states_for_these_countries($countries): array
189
+	{
190
+		if (! $countries) {
191
+			return [];
192
+		}
193
+		return $this->get_all(
194
+			[
195
+				['Country.CNT_ISO' => ['IN', array_keys($countries)]],
196
+				'order_by' => ['Country.CNT_name' => 'ASC', 'STA_name' => 'ASC'],
197
+			]
198
+		);
199
+	}
200
+
201
+
202
+	/**
203
+	 * Gets the state's name by its ID
204
+	 *
205
+	 * @param string $state_ID
206
+	 * @return string
207
+	 * @throws EE_Error
208
+	 * @throws ReflectionException
209
+	 */
210
+	public function get_state_name_by_ID(string $state_ID): string
211
+	{
212
+		if (
213
+			isset(self::$_all_states[ $state_ID ]) && self::$_all_states[ $state_ID ] instanceof EE_State
214
+		) {
215
+			return self::$_all_states[ $state_ID ]->name();
216
+		}
217
+		$names = $this->get_col([['STA_ID' => $state_ID], 'limit' => 1], 'STA_name');
218
+		return is_array($names) && ! empty($names)
219
+			? reset($names)
220
+			: '';
221
+	}
222 222
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
             'State' => new EE_Primary_Table('esp_state', 'STA_ID'),
36 36
         ];
37 37
 
38
-        $this->_fields          = [
38
+        $this->_fields = [
39 39
             'State' => [
40 40
                 'STA_ID'     => new EE_Primary_Key_Int_Field(
41 41
                     'STA_ID',
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             'Venue'    => new EE_Has_Many_Relation(),
75 75
         ];
76 76
         // this model is generally available for reading
77
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
77
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
78 78
         // @todo: only show STA_active
79 79
         parent::__construct($timezone);
80 80
     }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
      */
118 118
     public function get_all_active_states(array $countries = [], bool $flush_cache = false): array
119 119
     {
120
-        if (! self::$_active_states || $flush_cache) {
120
+        if ( ! self::$_active_states || $flush_cache) {
121 121
             $countries            = ! empty($countries) && is_array($countries)
122 122
                 ? $countries
123 123
                 : EEM_Country::instance()->get_all_active_countries();
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      */
166 166
     public function get_all_active_states_for_these_countries($countries): array
167 167
     {
168
-        if (! $countries) {
168
+        if ( ! $countries) {
169 169
             return [];
170 170
         }
171 171
         return $this->get_all(
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
      */
188 188
     public function get_all_states_for_these_countries($countries): array
189 189
     {
190
-        if (! $countries) {
190
+        if ( ! $countries) {
191 191
             return [];
192 192
         }
193 193
         return $this->get_all(
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
     public function get_state_name_by_ID(string $state_ID): string
211 211
     {
212 212
         if (
213
-            isset(self::$_all_states[ $state_ID ]) && self::$_all_states[ $state_ID ] instanceof EE_State
213
+            isset(self::$_all_states[$state_ID]) && self::$_all_states[$state_ID] instanceof EE_State
214 214
         ) {
215
-            return self::$_all_states[ $state_ID ]->name();
215
+            return self::$_all_states[$state_ID]->name();
216 216
         }
217 217
         $names = $this->get_col([['STA_ID' => $state_ID], 'limit' => 1], 'STA_name');
218 218
         return is_array($names) && ! empty($names)
Please login to merge, or discard this patch.
core/db_models/EEM_Post_Meta.model.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -18,56 +18,56 @@
 block discarded – undo
18 18
 class EEM_Post_Meta extends EEM_Base
19 19
 {
20 20
 
21
-    // private instance of the EE_Post_Meta object
22
-    protected static $_instance;
21
+	// private instance of the EE_Post_Meta object
22
+	protected static $_instance;
23 23
 
24 24
 
25 25
 
26
-    protected function __construct(string $timezone = '')
27
-    {
28
-        $this->singular_item = esc_html__('Post Meta', 'event_espresso');
29
-        $this->plural_item = esc_html__('Post Metas', 'event_espresso');
30
-        $this->_tables = array(
31
-            'Post_Meta' => new EE_Primary_Table('postmeta', 'meta_id'),
32
-        );
33
-        $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models());
34
-        $this->_fields = array(
35
-            'Post_Meta' => array(
36
-                'meta_id'    => new EE_Primary_Key_Int_Field(
37
-                    'meta_id',
38
-                    esc_html__("Meta ID", "event_espresso")
39
-                ),
40
-                'post_id'    => new EE_Foreign_Key_Int_Field(
41
-                    'post_id',
42
-                    esc_html__("Primary Key of Post", "event_espresso"),
43
-                    false,
44
-                    0,
45
-                    $models_this_can_attach_to
46
-                ),
47
-                'meta_key'   => new EE_Plain_Text_Field(
48
-                    'meta_key',
49
-                    esc_html__("Meta Key", "event_espresso"),
50
-                    false,
51
-                    ''
52
-                ),
53
-                'meta_value' => new EE_Maybe_Serialized_Text_Field(
54
-                    'meta_value',
55
-                    esc_html__("Meta Value", "event_espresso"),
56
-                    true
57
-                ),
58
-            ),
59
-        );
60
-        $this->_model_relations = array();
61
-        foreach ($models_this_can_attach_to as $model) {
62
-            $this->_model_relations[ $model ] = new EE_Belongs_To_Relation();
63
-        }
64
-        $this->_wp_core_model = true;
65
-        foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
66
-            $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta(
67
-                'meta_key',
68
-                'meta_value'
69
-            );
70
-        }
71
-        parent::__construct($timezone);
72
-    }
26
+	protected function __construct(string $timezone = '')
27
+	{
28
+		$this->singular_item = esc_html__('Post Meta', 'event_espresso');
29
+		$this->plural_item = esc_html__('Post Metas', 'event_espresso');
30
+		$this->_tables = array(
31
+			'Post_Meta' => new EE_Primary_Table('postmeta', 'meta_id'),
32
+		);
33
+		$models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models());
34
+		$this->_fields = array(
35
+			'Post_Meta' => array(
36
+				'meta_id'    => new EE_Primary_Key_Int_Field(
37
+					'meta_id',
38
+					esc_html__("Meta ID", "event_espresso")
39
+				),
40
+				'post_id'    => new EE_Foreign_Key_Int_Field(
41
+					'post_id',
42
+					esc_html__("Primary Key of Post", "event_espresso"),
43
+					false,
44
+					0,
45
+					$models_this_can_attach_to
46
+				),
47
+				'meta_key'   => new EE_Plain_Text_Field(
48
+					'meta_key',
49
+					esc_html__("Meta Key", "event_espresso"),
50
+					false,
51
+					''
52
+				),
53
+				'meta_value' => new EE_Maybe_Serialized_Text_Field(
54
+					'meta_value',
55
+					esc_html__("Meta Value", "event_espresso"),
56
+					true
57
+				),
58
+			),
59
+		);
60
+		$this->_model_relations = array();
61
+		foreach ($models_this_can_attach_to as $model) {
62
+			$this->_model_relations[ $model ] = new EE_Belongs_To_Relation();
63
+		}
64
+		$this->_wp_core_model = true;
65
+		foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
66
+			$this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta(
67
+				'meta_key',
68
+				'meta_value'
69
+			);
70
+		}
71
+		parent::__construct($timezone);
72
+	}
73 73
 }
Please login to merge, or discard this patch.