Completed
Branch dependabot/composer/tijsverkoy... (491ea6)
by
unknown
32:00 queued 25:42
created
core/domain/services/capabilities/user_caps/UserCapabilities.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
      */
37 37
     protected function hasEntityCap(string $cap, string $context, $ID): bool
38 38
     {
39
-        if (! isset($this->caps[ $cap ][ $context ][ $ID ])) {
40
-            $this->caps[ $cap ][ $context ][ $ID ] = $this->capabilities->current_user_can($cap, $context, $ID);
39
+        if ( ! isset($this->caps[$cap][$context][$ID])) {
40
+            $this->caps[$cap][$context][$ID] = $this->capabilities->current_user_can($cap, $context, $ID);
41 41
         }
42
-        return $this->caps[ $cap ][ $context ][ $ID ];
42
+        return $this->caps[$cap][$context][$ID];
43 43
     }
44 44
 
45 45
 
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
      */
51 51
     protected function hasGlobalCap(string $cap, string $context): bool
52 52
     {
53
-        if (! isset($this->caps[ $cap ][ $context ])) {
54
-            $this->caps[ $cap ][ $context ] = $this->capabilities->current_user_can($cap, $context);
53
+        if ( ! isset($this->caps[$cap][$context])) {
54
+            $this->caps[$cap][$context] = $this->capabilities->current_user_can($cap, $context);
55 55
         }
56
-        return $this->caps[ $cap ][ $context ];
56
+        return $this->caps[$cap][$context];
57 57
     }
58 58
 }
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -6,45 +6,45 @@
 block discarded – undo
6 6
 
7 7
 abstract class UserCapabilities
8 8
 {
9
-    private EE_Capabilities $capabilities;
10
-
11
-    private array $caps = [];
12
-
13
-
14
-    /**
15
-     * @param EE_Capabilities $capabilities
16
-     */
17
-    public function __construct(EE_Capabilities $capabilities)
18
-    {
19
-        $this->capabilities = $capabilities;
20
-    }
21
-
22
-
23
-    /**
24
-     * @param string     $cap
25
-     * @param string     $context
26
-     * @param int|string $ID
27
-     * @return bool
28
-     */
29
-    protected function hasEntityCap(string $cap, string $context, $ID): bool
30
-    {
31
-        if (! isset($this->caps[ $cap ][ $context ][ $ID ])) {
32
-            $this->caps[ $cap ][ $context ][ $ID ] = $this->capabilities->current_user_can($cap, $context, $ID);
33
-        }
34
-        return $this->caps[ $cap ][ $context ][ $ID ];
35
-    }
36
-
37
-
38
-    /**
39
-     * @param string $cap
40
-     * @param string $context
41
-     * @return bool
42
-     */
43
-    protected function hasGlobalCap(string $cap, string $context): bool
44
-    {
45
-        if (! isset($this->caps[ $cap ][ $context ])) {
46
-            $this->caps[ $cap ][ $context ] = $this->capabilities->current_user_can($cap, $context);
47
-        }
48
-        return $this->caps[ $cap ][ $context ];
49
-    }
9
+	private EE_Capabilities $capabilities;
10
+
11
+	private array $caps = [];
12
+
13
+
14
+	/**
15
+	 * @param EE_Capabilities $capabilities
16
+	 */
17
+	public function __construct(EE_Capabilities $capabilities)
18
+	{
19
+		$this->capabilities = $capabilities;
20
+	}
21
+
22
+
23
+	/**
24
+	 * @param string     $cap
25
+	 * @param string     $context
26
+	 * @param int|string $ID
27
+	 * @return bool
28
+	 */
29
+	protected function hasEntityCap(string $cap, string $context, $ID): bool
30
+	{
31
+		if (! isset($this->caps[ $cap ][ $context ][ $ID ])) {
32
+			$this->caps[ $cap ][ $context ][ $ID ] = $this->capabilities->current_user_can($cap, $context, $ID);
33
+		}
34
+		return $this->caps[ $cap ][ $context ][ $ID ];
35
+	}
36
+
37
+
38
+	/**
39
+	 * @param string $cap
40
+	 * @param string $context
41
+	 * @return bool
42
+	 */
43
+	protected function hasGlobalCap(string $cap, string $context): bool
44
+	{
45
+		if (! isset($this->caps[ $cap ][ $context ])) {
46
+			$this->caps[ $cap ][ $context ] = $this->capabilities->current_user_can($cap, $context);
47
+		}
48
+		return $this->caps[ $cap ][ $context ];
49
+	}
50 50
 }
Please login to merge, or discard this patch.
Invoice/templates/invoice_settings_header_gateway.template.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@
 block discarded – undo
17 17
         <td>
18 18
             <h4 class="ee-status-outline ee-status-bg--info">
19 19
                 <?php esc_html_e(
20
-                    "The following settings affect the functioning of the Invoice gateway.",
21
-                    'event_espresso'
22
-                ); ?>
20
+					"The following settings affect the functioning of the Invoice gateway.",
21
+					'event_espresso'
22
+				); ?>
23 23
             </h4>
24 24
         </td>
25 25
     </tr>
Please login to merge, or discard this patch.
Invoice/templates/invoice_settings_header_display.template.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@
 block discarded – undo
17 17
         <td>
18 18
             <h4 class="ee-status-outline ee-status-bg--info">
19 19
                 <?php esc_html_e(
20
-                    "The following settings affect the content and/or appearance of the downloadable PDF invoice.",
21
-                    'event_espresso'
22
-                ); ?>
20
+					"The following settings affect the content and/or appearance of the downloadable PDF invoice.",
21
+					'event_espresso'
22
+				); ?>
23 23
             </h4>
24 24
         </td>
25 25
     </tr>
Please login to merge, or discard this patch.
Extend_Registration_Form_Questions_Admin_List_Table.class.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
      */
24 24
     public function column_display_text(EE_Question $question, bool $prep_content = true): string
25 25
     {
26
-        $actions         = [];
26
+        $actions = [];
27 27
 
28 28
         if ($this->caps_handler->userCanEditQuestion($question)) {
29 29
             $actions['edit'] = $this->getActionLink(
Please login to merge, or discard this patch.
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -13,74 +13,74 @@
 block discarded – undo
13 13
  */
14 14
 class Extend_Registration_Form_Questions_Admin_List_Table extends Registration_Form_Questions_Admin_List_Table
15 15
 {
16
-    /**
17
-     * @param EE_Question $question
18
-     * @param bool        $prep_content
19
-     * @return string
20
-     * @throws EE_Error
21
-     * @throws ReflectionException
22
-     */
23
-    public function column_display_text(EE_Question $question, bool $prep_content = true): string
24
-    {
25
-        $actions         = [];
16
+	/**
17
+	 * @param EE_Question $question
18
+	 * @param bool        $prep_content
19
+	 * @return string
20
+	 * @throws EE_Error
21
+	 * @throws ReflectionException
22
+	 */
23
+	public function column_display_text(EE_Question $question, bool $prep_content = true): string
24
+	{
25
+		$actions         = [];
26 26
 
27
-        if ($this->caps_handler->userCanEditQuestion($question)) {
28
-            $actions['edit'] = $this->getActionLink(
29
-                $this->getActionUrl($question, self::ACTION_EDIT),
30
-                esc_html__('Edit', 'event_espresso'),
31
-                esc_attr__('Edit Question', 'event_espresso')
32
-            );
33
-        }
27
+		if ($this->caps_handler->userCanEditQuestion($question)) {
28
+			$actions['edit'] = $this->getActionLink(
29
+				$this->getActionUrl($question, self::ACTION_EDIT),
30
+				esc_html__('Edit', 'event_espresso'),
31
+				esc_attr__('Edit Question', 'event_espresso')
32
+			);
33
+		}
34 34
 
35
-        if (
36
-            $this->_view != 'trash'
37
-            && ! $question->is_system_question()
38
-            && $this->caps_handler->userCanTrashQuestion($question)
39
-        ) {
40
-            $actions['delete'] = $this->getActionLink(
41
-                $this->getActionUrl($question, self::ACTION_TRASH),
42
-                esc_html__('Trash', 'event_espresso'),
43
-                esc_attr__('Trash Question', 'event_espresso')
44
-            );
45
-        }
35
+		if (
36
+			$this->_view != 'trash'
37
+			&& ! $question->is_system_question()
38
+			&& $this->caps_handler->userCanTrashQuestion($question)
39
+		) {
40
+			$actions['delete'] = $this->getActionLink(
41
+				$this->getActionUrl($question, self::ACTION_TRASH),
42
+				esc_html__('Trash', 'event_espresso'),
43
+				esc_attr__('Trash Question', 'event_espresso')
44
+			);
45
+		}
46 46
 
47
-        if ($this->_view == 'trash') {
48
-            if ($this->caps_handler->userCanRestoreQuestion($question)) {
49
-                $actions['restore'] = $this->getActionLink(
50
-                    $this->getActionUrl($question, self::ACTION_RESTORE),
51
-                    esc_html__('Restore', 'event_espresso'),
52
-                    esc_attr__('Restore Question', 'event_espresso')
53
-                );
54
-            }
55
-            if (
56
-                $question->count_related('Answer') === 0
57
-                && $this->caps_handler->userCanDeleteQuestion($question)
58
-            ) {
59
-                $actions['delete'] = $this->getActionLink(
60
-                    $this->getActionUrl($question, self::ACTION_DELETE),
61
-                    esc_html__('Delete Permanently', 'event_espresso'),
62
-                    esc_attr__('Delete Question Permanently', 'event_espresso')
63
-                );
64
-            }
65
-        }
66
-        if ($this->caps_handler->userCanEditQuestion($question)) {
67
-            $actions['duplicate'] = $this->getActionLink(
68
-                $this->getActionUrl($question, self::ACTION_COPY),
69
-                esc_html__('Duplicate', 'event_espresso'),
70
-                esc_attr__('Duplicate Question', 'event_espresso')
71
-            );
72
-        }
47
+		if ($this->_view == 'trash') {
48
+			if ($this->caps_handler->userCanRestoreQuestion($question)) {
49
+				$actions['restore'] = $this->getActionLink(
50
+					$this->getActionUrl($question, self::ACTION_RESTORE),
51
+					esc_html__('Restore', 'event_espresso'),
52
+					esc_attr__('Restore Question', 'event_espresso')
53
+				);
54
+			}
55
+			if (
56
+				$question->count_related('Answer') === 0
57
+				&& $this->caps_handler->userCanDeleteQuestion($question)
58
+			) {
59
+				$actions['delete'] = $this->getActionLink(
60
+					$this->getActionUrl($question, self::ACTION_DELETE),
61
+					esc_html__('Delete Permanently', 'event_espresso'),
62
+					esc_attr__('Delete Question Permanently', 'event_espresso')
63
+				);
64
+			}
65
+		}
66
+		if ($this->caps_handler->userCanEditQuestion($question)) {
67
+			$actions['duplicate'] = $this->getActionLink(
68
+				$this->getActionUrl($question, self::ACTION_COPY),
69
+				esc_html__('Duplicate', 'event_espresso'),
70
+				esc_attr__('Duplicate Question', 'event_espresso')
71
+			);
72
+		}
73 73
 
74
-        $content = $this->caps_handler->userCanEditQuestion($question)
75
-            ? $this->getActionLink(
76
-                $this->getActionUrl($question, self::ACTION_EDIT),
77
-                $prep_content ? $question->display_text() : $question->admin_label(),
78
-                esc_attr__('Edit Question', 'event_espresso'),
79
-                'row-title'
80
-            )
81
-            : $question->display_text();
82
-        $content .= $this->row_actions($actions);
74
+		$content = $this->caps_handler->userCanEditQuestion($question)
75
+			? $this->getActionLink(
76
+				$this->getActionUrl($question, self::ACTION_EDIT),
77
+				$prep_content ? $question->display_text() : $question->admin_label(),
78
+				esc_attr__('Edit Question', 'event_espresso'),
79
+				'row-title'
80
+			)
81
+			: $question->display_text();
82
+		$content .= $this->row_actions($actions);
83 83
 
84
-        return $prep_content ? $this->columnContent('display_text', $content) : $content;
85
-    }
84
+		return $prep_content ? $this->columnContent('display_text', $content) : $content;
85
+	}
86 86
 }
Please login to merge, or discard this patch.
Registration_Form_Question_Groups_Admin_List_Table.class.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
         $this->caps_handler = new RegFormListTableUserCapabilities(EE_Registry::instance()->CAP);
28 28
         parent::__construct($admin_page);
29 29
 
30
-        if (! defined('REG_ADMIN_URL')) {
30
+        if ( ! defined('REG_ADMIN_URL')) {
31 31
             define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
32 32
         }
33 33
     }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
             )
122 122
             : $notice;
123 123
         return $system_group || $has_questions_with_answers || ! $user_can_trash_it
124
-            ? '<span class="dashicons dashicons-lock ee-locked-entity ee-aria-tooltip" aria-label="' . $notice . '"></span>'
124
+            ? '<span class="dashicons dashicons-lock ee-locked-entity ee-aria-tooltip" aria-label="'.$notice.'"></span>'
125 125
               . sprintf(
126 126
                   '<input type="hidden" name="hdnchk[%1$d]" value="%1$d" />',
127 127
                   $item->ID()
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
     public function column_id(EE_Question_Group $item)
137 137
     {
138 138
         $content = '
139
-            <span class="ee-entity-id">' . $item->ID() . '</span>
139
+            <span class="ee-entity-id">' . $item->ID().'</span>
140 140
             <span class="show-on-mobile-view-only">
141
-                ' . $item->name() . '
141
+                ' . $item->name().'
142 142
             </span>';
143 143
         return $this->columnContent('id', $content, 'end');
144 144
     }
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
      */
217 217
     protected function getActionUrl(EE_Question_Group $question_group, $action): string
218 218
     {
219
-        if (! in_array($action, self::$actions)) {
219
+        if ( ! in_array($action, self::$actions)) {
220 220
             throw new DomainException(esc_html__('Invalid Action', 'event_espresso'));
221 221
         }
222 222
         return EE_Admin_Page::add_query_args_and_nonce(
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
 
245 245
     public function column_show_group_name(EE_Question_Group $question_group): string
246 246
     {
247
-        return $this->columnContent('show_group_name', $this->_yes_no[ $question_group->show_group_name() ]);
247
+        return $this->columnContent('show_group_name', $this->_yes_no[$question_group->show_group_name()]);
248 248
     }
249 249
 
250 250
 
251 251
     public function column_show_group_desc(EE_Question_Group $question_group): string
252 252
     {
253
-        return $this->columnContent('show_group_desc', $this->_yes_no[ $question_group->show_group_desc() ]);
253
+        return $this->columnContent('show_group_desc', $this->_yes_no[$question_group->show_group_desc()]);
254 254
     }
255 255
 }
Please login to merge, or discard this patch.
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -15,240 +15,240 @@
 block discarded – undo
15 15
  */
16 16
 class Registration_Form_Question_Groups_Admin_List_Table extends EE_Admin_List_Table
17 17
 {
18
-    /**
19
-     * @var RegFormListTableUserCapabilities
20
-     */
21
-    protected $caps_handler;
22
-
23
-
24
-    public function __construct($admin_page)
25
-    {
26
-        $this->caps_handler = new RegFormListTableUserCapabilities(EE_Registry::instance()->CAP);
27
-        parent::__construct($admin_page);
28
-
29
-        if (! defined('REG_ADMIN_URL')) {
30
-            define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
31
-        }
32
-    }
33
-
34
-
35
-    protected function _setup_data()
36
-    {
37
-        $this->_data = $this->_view != 'trash'
38
-            ? $this->_admin_page->get_question_groups($this->_per_page, $this->_current_page, false)
39
-            : $this->_admin_page->get_trashed_question_groups($this->_per_page, $this->_current_page, false);
40
-        $this->_all_data_count = $this->_view != 'trash'
41
-            ? $this->_admin_page->get_question_groups($this->_per_page, $this->_current_page, true)
42
-            : $this->_admin_page->get_trashed_question_groups($this->_per_page, $this->_current_page, true);
43
-    }
44
-
45
-
46
-    protected function _set_properties()
47
-    {
48
-        $this->_wp_list_args = array(
49
-            'singular' => esc_html__('question group', 'event_espresso'),
50
-            'plural'   => esc_html__('question groups', 'event_espresso'),
51
-            'ajax'     => true, // for now,
52
-            'screen'   => $this->_admin_page->get_current_screen()->id,
53
-        );
54
-
55
-        $this->_columns = array(
56
-            'cb'              => '<input type="checkbox" />',
57
-            'id'              => esc_html__('ID', 'event_espresso'),
58
-            'name'            => esc_html__('Group Name', 'event_espresso'),
59
-            'description'     => esc_html__('Description', 'event_espresso'),
60
-            'show_group_name' => esc_html__('Show Name', 'event_espresso'),
61
-            'show_group_desc' => esc_html__('Show Desc', 'event_espresso'),
62
-        );
63
-
64
-        $this->_sortable_columns = array(
65
-            'id'   => array('QSG_ID' => false),
66
-            'name' => array('QSG_name' => false),
67
-        );
68
-
69
-        $this->_hidden_columns = array(
70
-            'id',
71
-        );
72
-
73
-        $this->_ajax_sorting_callback = 'update_question_group_order';
74
-    }
75
-
76
-
77
-    // not needed
78
-    protected function _get_table_filters()
79
-    {
80
-        return [];
81
-    }
82
-
83
-
84
-    protected function _add_view_counts()
85
-    {
86
-        $this->_views['all']['count'] = $this->_admin_page->get_question_groups(
87
-            $this->_per_page,
88
-            $this->_current_page,
89
-            true
90
-        );
91
-        if ($this->caps_handler->userCanTrashQuestionGroups()) {
92
-            $this->_views['trash']['count'] = $this->_admin_page->get_trashed_question_groups(
93
-                $this->_per_page,
94
-                $this->_current_page,
95
-                true
96
-            );
97
-        }
98
-    }
99
-
100
-
101
-    /**
102
-     * @throws ReflectionException
103
-     * @throws EE_Error
104
-     */
105
-    public function column_cb($item)
106
-    {
107
-        $system_group = $item->get('QSG_system');
108
-        $user_can_trash_it = $this->caps_handler->userCanTrashQuestionGroup($item);
109
-        $has_questions_with_answers = ! $system_group && $this->_view == 'trash' && $item->has_questions_with_answers();
110
-        $notice = ! $user_can_trash_it
111
-            ? esc_html__('You do not have the required permissions to trash this question group', 'event_espresso')
112
-            : '';
113
-        $notice = $has_questions_with_answers
114
-            ? esc_html__('This question group is a system group and cannot be trashed', 'event_espresso')
115
-            : $notice;
116
-        $notice = $has_questions_with_answers
117
-            ? esc_html__(
118
-                'This question group has questions that have answers attached to it from registrations that have the question. It cannot be permanently deleted.',
119
-                'event_espresso'
120
-            )
121
-            : $notice;
122
-        return $system_group || $has_questions_with_answers || ! $user_can_trash_it
123
-            ? '<span class="dashicons dashicons-lock ee-locked-entity ee-aria-tooltip" aria-label="' . $notice . '"></span>'
124
-              . sprintf(
125
-                  '<input type="hidden" name="hdnchk[%1$d]" value="%1$d" />',
126
-                  $item->ID()
127
-              )
128
-            : sprintf(
129
-                '<input type="checkbox" id="QSG_ID[%1$d]" name="checkbox[%1$d]" value="%1$d" />',
130
-                $item->ID()
131
-            );
132
-    }
133
-
134
-
135
-    public function column_id(EE_Question_Group $item)
136
-    {
137
-        $content = '
18
+	/**
19
+	 * @var RegFormListTableUserCapabilities
20
+	 */
21
+	protected $caps_handler;
22
+
23
+
24
+	public function __construct($admin_page)
25
+	{
26
+		$this->caps_handler = new RegFormListTableUserCapabilities(EE_Registry::instance()->CAP);
27
+		parent::__construct($admin_page);
28
+
29
+		if (! defined('REG_ADMIN_URL')) {
30
+			define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
31
+		}
32
+	}
33
+
34
+
35
+	protected function _setup_data()
36
+	{
37
+		$this->_data = $this->_view != 'trash'
38
+			? $this->_admin_page->get_question_groups($this->_per_page, $this->_current_page, false)
39
+			: $this->_admin_page->get_trashed_question_groups($this->_per_page, $this->_current_page, false);
40
+		$this->_all_data_count = $this->_view != 'trash'
41
+			? $this->_admin_page->get_question_groups($this->_per_page, $this->_current_page, true)
42
+			: $this->_admin_page->get_trashed_question_groups($this->_per_page, $this->_current_page, true);
43
+	}
44
+
45
+
46
+	protected function _set_properties()
47
+	{
48
+		$this->_wp_list_args = array(
49
+			'singular' => esc_html__('question group', 'event_espresso'),
50
+			'plural'   => esc_html__('question groups', 'event_espresso'),
51
+			'ajax'     => true, // for now,
52
+			'screen'   => $this->_admin_page->get_current_screen()->id,
53
+		);
54
+
55
+		$this->_columns = array(
56
+			'cb'              => '<input type="checkbox" />',
57
+			'id'              => esc_html__('ID', 'event_espresso'),
58
+			'name'            => esc_html__('Group Name', 'event_espresso'),
59
+			'description'     => esc_html__('Description', 'event_espresso'),
60
+			'show_group_name' => esc_html__('Show Name', 'event_espresso'),
61
+			'show_group_desc' => esc_html__('Show Desc', 'event_espresso'),
62
+		);
63
+
64
+		$this->_sortable_columns = array(
65
+			'id'   => array('QSG_ID' => false),
66
+			'name' => array('QSG_name' => false),
67
+		);
68
+
69
+		$this->_hidden_columns = array(
70
+			'id',
71
+		);
72
+
73
+		$this->_ajax_sorting_callback = 'update_question_group_order';
74
+	}
75
+
76
+
77
+	// not needed
78
+	protected function _get_table_filters()
79
+	{
80
+		return [];
81
+	}
82
+
83
+
84
+	protected function _add_view_counts()
85
+	{
86
+		$this->_views['all']['count'] = $this->_admin_page->get_question_groups(
87
+			$this->_per_page,
88
+			$this->_current_page,
89
+			true
90
+		);
91
+		if ($this->caps_handler->userCanTrashQuestionGroups()) {
92
+			$this->_views['trash']['count'] = $this->_admin_page->get_trashed_question_groups(
93
+				$this->_per_page,
94
+				$this->_current_page,
95
+				true
96
+			);
97
+		}
98
+	}
99
+
100
+
101
+	/**
102
+	 * @throws ReflectionException
103
+	 * @throws EE_Error
104
+	 */
105
+	public function column_cb($item)
106
+	{
107
+		$system_group = $item->get('QSG_system');
108
+		$user_can_trash_it = $this->caps_handler->userCanTrashQuestionGroup($item);
109
+		$has_questions_with_answers = ! $system_group && $this->_view == 'trash' && $item->has_questions_with_answers();
110
+		$notice = ! $user_can_trash_it
111
+			? esc_html__('You do not have the required permissions to trash this question group', 'event_espresso')
112
+			: '';
113
+		$notice = $has_questions_with_answers
114
+			? esc_html__('This question group is a system group and cannot be trashed', 'event_espresso')
115
+			: $notice;
116
+		$notice = $has_questions_with_answers
117
+			? esc_html__(
118
+				'This question group has questions that have answers attached to it from registrations that have the question. It cannot be permanently deleted.',
119
+				'event_espresso'
120
+			)
121
+			: $notice;
122
+		return $system_group || $has_questions_with_answers || ! $user_can_trash_it
123
+			? '<span class="dashicons dashicons-lock ee-locked-entity ee-aria-tooltip" aria-label="' . $notice . '"></span>'
124
+			  . sprintf(
125
+				  '<input type="hidden" name="hdnchk[%1$d]" value="%1$d" />',
126
+				  $item->ID()
127
+			  )
128
+			: sprintf(
129
+				'<input type="checkbox" id="QSG_ID[%1$d]" name="checkbox[%1$d]" value="%1$d" />',
130
+				$item->ID()
131
+			);
132
+	}
133
+
134
+
135
+	public function column_id(EE_Question_Group $item)
136
+	{
137
+		$content = '
138 138
             <span class="ee-entity-id">' . $item->ID() . '</span>
139 139
             <span class="show-on-mobile-view-only">
140 140
                 ' . $item->name() . '
141 141
             </span>';
142
-        return $this->columnContent('id', $content, 'end');
143
-    }
144
-
145
-
146
-    /**
147
-     * @throws EE_Error
148
-     * @throws ReflectionException
149
-     */
150
-    public function column_name(EE_Question_Group $question_group, bool $prep_content = true): string
151
-    {
152
-        $actions = array();
153
-
154
-        if ($this->caps_handler->userCanEditQuestionGroup($question_group)) {
155
-            $actions['edit'] = $this->getActionLink(
156
-                $this->getActionUrl($question_group, self::ACTION_EDIT),
157
-                esc_html__('Edit', 'event_espresso'),
158
-                esc_attr__('Edit Question Group', 'event_espresso')
159
-            );
160
-        }
161
-        if (
162
-            $question_group->get('QSG_system') < 1
163
-            && $this->_view != 'trash'
164
-            && $this->caps_handler->userCanEditQuestionGroup($question_group)
165
-        ) {
166
-            $actions['delete'] = $this->getActionLink(
167
-                $this->getActionUrl($question_group, self::ACTION_TRASH),
168
-                esc_html__('Trash', 'event_espresso'),
169
-                esc_attr__('Trash Question Group', 'event_espresso')
170
-            );
171
-        }
172
-
173
-        if ($this->_view == 'trash') {
174
-            if ($this->caps_handler->userCanRestoreQuestionGroup($question_group)) {
175
-                $actions['restore'] = $this->getActionLink(
176
-                    $this->getActionUrl($question_group, self::ACTION_RESTORE),
177
-                    esc_html__('Restore', 'event_espresso'),
178
-                    esc_attr__('Restore Question Group', 'event_espresso')
179
-                );
180
-            }
181
-
182
-            if (
183
-                ! $question_group->has_questions_with_answers()
184
-                && $this->caps_handler->userCanDeleteQuestionGroup($question_group)
185
-            ) {
186
-                $actions['delete'] = $this->getActionLink(
187
-                    $this->getActionUrl($question_group, self::ACTION_DELETE),
188
-                    esc_html__('Delete Permanently', 'event_espresso'),
189
-                    esc_attr__('Delete Question Group Permanently', 'event_espresso')
190
-                );
191
-            }
192
-        }
193
-
194
-        $content = $this->caps_handler->userCanEditQuestionGroup($question_group)
195
-            ? $this->getActionLink(
196
-                $this->getActionUrl($question_group, self::ACTION_EDIT),
197
-                $question_group->name(),
198
-                esc_attr__('Edit Question Group', 'event_espresso'),
199
-                'row-title'
200
-            )
201
-            : $question_group->name();
202
-        $content .= $this->row_actions($actions);
203
-
204
-        return $prep_content ? $this->columnContent('name', $content) : $content;
205
-    }
206
-
207
-
208
-    /**
209
-     * @param EE_Question_Group $question_group
210
-     * @param                   $action
211
-     * @return string
212
-     * @throws EE_Error
213
-     * @throws ReflectionException
214
-     * @since 5.0.0.p
215
-     */
216
-    protected function getActionUrl(EE_Question_Group $question_group, $action): string
217
-    {
218
-        if (! in_array($action, self::$actions)) {
219
-            throw new DomainException(esc_html__('Invalid Action', 'event_espresso'));
220
-        }
221
-        return EE_Admin_Page::add_query_args_and_nonce(
222
-            [
223
-                'action'   => "{$action}_question_group",
224
-                'QSG_ID'   => $question_group->ID(),
225
-                'noheader' => $action !== self::ACTION_EDIT,
226
-            ],
227
-            EE_FORMS_ADMIN_URL
228
-        );
229
-    }
230
-
231
-
232
-    public function column_identifier(EE_Question_Group $question_group): string
233
-    {
234
-        return $this->columnContent('identifier', $question_group->identifier());
235
-    }
236
-
237
-
238
-    public function column_description(EE_Question_Group $question_group): string
239
-    {
240
-        return $this->columnContent('description', $question_group->desc());
241
-    }
242
-
243
-
244
-    public function column_show_group_name(EE_Question_Group $question_group): string
245
-    {
246
-        return $this->columnContent('show_group_name', $this->_yes_no[ $question_group->show_group_name() ]);
247
-    }
248
-
249
-
250
-    public function column_show_group_desc(EE_Question_Group $question_group): string
251
-    {
252
-        return $this->columnContent('show_group_desc', $this->_yes_no[ $question_group->show_group_desc() ]);
253
-    }
142
+		return $this->columnContent('id', $content, 'end');
143
+	}
144
+
145
+
146
+	/**
147
+	 * @throws EE_Error
148
+	 * @throws ReflectionException
149
+	 */
150
+	public function column_name(EE_Question_Group $question_group, bool $prep_content = true): string
151
+	{
152
+		$actions = array();
153
+
154
+		if ($this->caps_handler->userCanEditQuestionGroup($question_group)) {
155
+			$actions['edit'] = $this->getActionLink(
156
+				$this->getActionUrl($question_group, self::ACTION_EDIT),
157
+				esc_html__('Edit', 'event_espresso'),
158
+				esc_attr__('Edit Question Group', 'event_espresso')
159
+			);
160
+		}
161
+		if (
162
+			$question_group->get('QSG_system') < 1
163
+			&& $this->_view != 'trash'
164
+			&& $this->caps_handler->userCanEditQuestionGroup($question_group)
165
+		) {
166
+			$actions['delete'] = $this->getActionLink(
167
+				$this->getActionUrl($question_group, self::ACTION_TRASH),
168
+				esc_html__('Trash', 'event_espresso'),
169
+				esc_attr__('Trash Question Group', 'event_espresso')
170
+			);
171
+		}
172
+
173
+		if ($this->_view == 'trash') {
174
+			if ($this->caps_handler->userCanRestoreQuestionGroup($question_group)) {
175
+				$actions['restore'] = $this->getActionLink(
176
+					$this->getActionUrl($question_group, self::ACTION_RESTORE),
177
+					esc_html__('Restore', 'event_espresso'),
178
+					esc_attr__('Restore Question Group', 'event_espresso')
179
+				);
180
+			}
181
+
182
+			if (
183
+				! $question_group->has_questions_with_answers()
184
+				&& $this->caps_handler->userCanDeleteQuestionGroup($question_group)
185
+			) {
186
+				$actions['delete'] = $this->getActionLink(
187
+					$this->getActionUrl($question_group, self::ACTION_DELETE),
188
+					esc_html__('Delete Permanently', 'event_espresso'),
189
+					esc_attr__('Delete Question Group Permanently', 'event_espresso')
190
+				);
191
+			}
192
+		}
193
+
194
+		$content = $this->caps_handler->userCanEditQuestionGroup($question_group)
195
+			? $this->getActionLink(
196
+				$this->getActionUrl($question_group, self::ACTION_EDIT),
197
+				$question_group->name(),
198
+				esc_attr__('Edit Question Group', 'event_espresso'),
199
+				'row-title'
200
+			)
201
+			: $question_group->name();
202
+		$content .= $this->row_actions($actions);
203
+
204
+		return $prep_content ? $this->columnContent('name', $content) : $content;
205
+	}
206
+
207
+
208
+	/**
209
+	 * @param EE_Question_Group $question_group
210
+	 * @param                   $action
211
+	 * @return string
212
+	 * @throws EE_Error
213
+	 * @throws ReflectionException
214
+	 * @since 5.0.0.p
215
+	 */
216
+	protected function getActionUrl(EE_Question_Group $question_group, $action): string
217
+	{
218
+		if (! in_array($action, self::$actions)) {
219
+			throw new DomainException(esc_html__('Invalid Action', 'event_espresso'));
220
+		}
221
+		return EE_Admin_Page::add_query_args_and_nonce(
222
+			[
223
+				'action'   => "{$action}_question_group",
224
+				'QSG_ID'   => $question_group->ID(),
225
+				'noheader' => $action !== self::ACTION_EDIT,
226
+			],
227
+			EE_FORMS_ADMIN_URL
228
+		);
229
+	}
230
+
231
+
232
+	public function column_identifier(EE_Question_Group $question_group): string
233
+	{
234
+		return $this->columnContent('identifier', $question_group->identifier());
235
+	}
236
+
237
+
238
+	public function column_description(EE_Question_Group $question_group): string
239
+	{
240
+		return $this->columnContent('description', $question_group->desc());
241
+	}
242
+
243
+
244
+	public function column_show_group_name(EE_Question_Group $question_group): string
245
+	{
246
+		return $this->columnContent('show_group_name', $this->_yes_no[ $question_group->show_group_name() ]);
247
+	}
248
+
249
+
250
+	public function column_show_group_desc(EE_Question_Group $question_group): string
251
+	{
252
+		return $this->columnContent('show_group_desc', $this->_yes_no[ $question_group->show_group_desc() ]);
253
+	}
254 254
 }
Please login to merge, or discard this patch.
core/admin/templates/admin_details_metabox_column_wrapper.template.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@
 block discarded – undo
19 19
         </div> <!-- post-body-content -->
20 20
 
21 21
         <?php
22
-        // let's loop through the columns
23
-        for ($i = 1; $i <= $num_columns; $i++) {
24
-            $context = ($i === 1) ? 'normal' : 'side';
25
-            $context = ($i > 2) ? 'column' . $i : $context;
26
-            ?>
22
+		// let's loop through the columns
23
+		for ($i = 1; $i <= $num_columns; $i++) {
24
+			$context = ($i === 1) ? 'normal' : 'side';
25
+			$context = ($i > 2) ? 'column' . $i : $context;
26
+			?>
27 27
         <div id='postbox-container-<?php echo absint($i); ?>' class='postbox-container'>
28 28
             <?php do_meta_boxes($current_page, $context, null); ?>
29 29
         </div>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
         // let's loop through the columns
23 23
         for ($i = 1; $i <= $num_columns; $i++) {
24 24
             $context = ($i === 1) ? 'normal' : 'side';
25
-            $context = ($i > 2) ? 'column' . $i : $context;
25
+            $context = ($i > 2) ? 'column'.$i : $context;
26 26
             ?>
27 27
         <div id='postbox-container-<?php echo absint($i); ?>' class='postbox-container'>
28 28
             <?php do_meta_boxes($current_page, $context, null); ?>
Please login to merge, or discard this patch.
core/db_classes/EE_Checkin.class.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -9,131 +9,131 @@
 block discarded – undo
9 9
  */
10 10
 class EE_Checkin extends EE_Base_Class
11 11
 {
12
-    /**
13
-     * Registration can NOT be checked in or out
14
-     *
15
-     * @type int
16
-     */
17
-    const status_invalid = -1;
18
-
19
-    /**
20
-     * Registration has been checked out.
21
-     *
22
-     * @type int
23
-     */
24
-    const status_checked_out = 0;
25
-
26
-    /**
27
-     * Registration has been checked in.
28
-     *
29
-     * @type int
30
-     */
31
-    const status_checked_in = 1;
32
-
33
-    /**
34
-     * Registration has never been checked in.
35
-     *
36
-     * @type int
37
-     */
38
-    const status_checked_never = 2;
39
-
40
-
41
-    /**
42
-     *
43
-     * @param array|null  $props_n_values incoming values
44
-     * @param string|null $timezone       incoming timezone (if not set the timezone set for the website will be used.)
45
-     * @param array|null  $date_formats   incoming date_formats in an array
46
-     *                                    where the first value is the date_format
47
-     *                                    and the second value is the time format
48
-     * @return EE_Checkin
49
-     * @throws EE_Error
50
-     * @throws ReflectionException
51
-     */
52
-    public static function new_instance(
53
-        ?array $props_n_values = [],
54
-        ?string $timezone = '',
55
-        ?array $date_formats = []
56
-    ): EE_Checkin {
57
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
58
-        return $has_object ?: new self($props_n_values, false, $timezone, $date_formats);
59
-    }
60
-
61
-
62
-    /**
63
-     * @param array|null  $props_n_values incoming values from the database
64
-     * @param string|null $timezone       incoming timezone as set by the model.  If not set the timezone for
65
-     *                                    the website will be used.
66
-     * @return EE_Checkin
67
-     * @throws EE_Error
68
-     * @throws ReflectionException
69
-     */
70
-    public static function new_instance_from_db(?array $props_n_values = [], ?string $timezone = ''): EE_Checkin
71
-    {
72
-        return new self($props_n_values, true, $timezone);
73
-    }
74
-
75
-
76
-    public function ID()
77
-    {
78
-        return $this->get('CHK_ID');
79
-    }
80
-
81
-
82
-    /**
83
-     * @throws EE_Error
84
-     * @throws ReflectionException
85
-     */
86
-    public function registration_id(): int
87
-    {
88
-        return (int) $this->get('REG_ID');
89
-    }
90
-
91
-
92
-    /**
93
-     * @throws EE_Error
94
-     * @throws ReflectionException
95
-     */
96
-    public function datetime_id(): int
97
-    {
98
-        return (int) $this->get('DTT_ID');
99
-    }
100
-
101
-
102
-    /**
103
-     * @throws EE_Error
104
-     * @throws ReflectionException
105
-     */
106
-    public function status(): int
107
-    {
108
-        return (int) $this->get('CHK_in');
109
-    }
110
-
111
-
112
-    /**
113
-     * @throws ReflectionException
114
-     * @throws EE_Error
115
-     */
116
-    public function timestamp()
117
-    {
118
-        return $this->get('CHK_timestamp');
119
-    }
120
-
121
-
122
-    /**
123
-     * @throws EE_Error
124
-     * @throws ReflectionException
125
-     */
126
-    public function getCheckInText(): string
127
-    {
128
-        switch ($this->status()) {
129
-            case EE_Checkin::status_checked_in:
130
-                return esc_html__('Checked In', 'event_espresso');
131
-            case EE_Checkin::status_checked_out:
132
-                return esc_html__('Checked Out', 'event_espresso');
133
-            case EE_Checkin::status_checked_never:
134
-                return esc_html__('Never Checked In', 'event_espresso');
135
-            default:
136
-                return esc_html__('Can Not Check-in', 'event_espresso');
137
-        }
138
-    }
12
+	/**
13
+	 * Registration can NOT be checked in or out
14
+	 *
15
+	 * @type int
16
+	 */
17
+	const status_invalid = -1;
18
+
19
+	/**
20
+	 * Registration has been checked out.
21
+	 *
22
+	 * @type int
23
+	 */
24
+	const status_checked_out = 0;
25
+
26
+	/**
27
+	 * Registration has been checked in.
28
+	 *
29
+	 * @type int
30
+	 */
31
+	const status_checked_in = 1;
32
+
33
+	/**
34
+	 * Registration has never been checked in.
35
+	 *
36
+	 * @type int
37
+	 */
38
+	const status_checked_never = 2;
39
+
40
+
41
+	/**
42
+	 *
43
+	 * @param array|null  $props_n_values incoming values
44
+	 * @param string|null $timezone       incoming timezone (if not set the timezone set for the website will be used.)
45
+	 * @param array|null  $date_formats   incoming date_formats in an array
46
+	 *                                    where the first value is the date_format
47
+	 *                                    and the second value is the time format
48
+	 * @return EE_Checkin
49
+	 * @throws EE_Error
50
+	 * @throws ReflectionException
51
+	 */
52
+	public static function new_instance(
53
+		?array $props_n_values = [],
54
+		?string $timezone = '',
55
+		?array $date_formats = []
56
+	): EE_Checkin {
57
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
58
+		return $has_object ?: new self($props_n_values, false, $timezone, $date_formats);
59
+	}
60
+
61
+
62
+	/**
63
+	 * @param array|null  $props_n_values incoming values from the database
64
+	 * @param string|null $timezone       incoming timezone as set by the model.  If not set the timezone for
65
+	 *                                    the website will be used.
66
+	 * @return EE_Checkin
67
+	 * @throws EE_Error
68
+	 * @throws ReflectionException
69
+	 */
70
+	public static function new_instance_from_db(?array $props_n_values = [], ?string $timezone = ''): EE_Checkin
71
+	{
72
+		return new self($props_n_values, true, $timezone);
73
+	}
74
+
75
+
76
+	public function ID()
77
+	{
78
+		return $this->get('CHK_ID');
79
+	}
80
+
81
+
82
+	/**
83
+	 * @throws EE_Error
84
+	 * @throws ReflectionException
85
+	 */
86
+	public function registration_id(): int
87
+	{
88
+		return (int) $this->get('REG_ID');
89
+	}
90
+
91
+
92
+	/**
93
+	 * @throws EE_Error
94
+	 * @throws ReflectionException
95
+	 */
96
+	public function datetime_id(): int
97
+	{
98
+		return (int) $this->get('DTT_ID');
99
+	}
100
+
101
+
102
+	/**
103
+	 * @throws EE_Error
104
+	 * @throws ReflectionException
105
+	 */
106
+	public function status(): int
107
+	{
108
+		return (int) $this->get('CHK_in');
109
+	}
110
+
111
+
112
+	/**
113
+	 * @throws ReflectionException
114
+	 * @throws EE_Error
115
+	 */
116
+	public function timestamp()
117
+	{
118
+		return $this->get('CHK_timestamp');
119
+	}
120
+
121
+
122
+	/**
123
+	 * @throws EE_Error
124
+	 * @throws ReflectionException
125
+	 */
126
+	public function getCheckInText(): string
127
+	{
128
+		switch ($this->status()) {
129
+			case EE_Checkin::status_checked_in:
130
+				return esc_html__('Checked In', 'event_espresso');
131
+			case EE_Checkin::status_checked_out:
132
+				return esc_html__('Checked Out', 'event_espresso');
133
+			case EE_Checkin::status_checked_never:
134
+				return esc_html__('Never Checked In', 'event_espresso');
135
+			default:
136
+				return esc_html__('Can Not Check-in', 'event_espresso');
137
+		}
138
+	}
139 139
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Money.helper.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
         $format          = 'f';
172 172
         $currency_config = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
173 173
         // first get the decimal place and number of places
174
-        $format = "%'." . $currency_config->dec_plc . $format;
174
+        $format = "%'.".$currency_config->dec_plc.$format;
175 175
         // currency symbol on right side.
176
-        return $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign;
176
+        return $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign;
177 177
     }
178 178
 
179 179
 
@@ -194,10 +194,10 @@  discard block
 block discarded – undo
194 194
         $currency_config            = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
195 195
         $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0');
196 196
         // first get the decimal place and number of places
197
-        $format = '#,##0.' . $decimal_places_placeholder;
197
+        $format = '#,##0.'.$decimal_places_placeholder;
198 198
         // currency symbol on right side.
199
-        $format          = $currency_config->sign_b4
200
-            ? $currency_config->sign . $format
199
+        $format = $currency_config->sign_b4
200
+            ? $currency_config->sign.$format
201 201
             : $format
202 202
               . $currency_config->sign;
203 203
         $formatterObject = [
Please login to merge, or discard this patch.
Indentation   +220 added lines, -220 removed lines patch added patch discarded remove patch
@@ -10,236 +10,236 @@
 block discarded – undo
10 10
  */
11 11
 class EEH_Money extends EEH_Base
12 12
 {
13
-    /**
14
-     * This removes all localized money formatting from the incoming value
15
-     * Note: uses this site's currency settings for deciding what is considered a
16
-     * "thousands separator" (usually the character "," )
17
-     * and what is a "decimal mark" (usually the character ".")
18
-     *
19
-     * @param int|float|string $money_value
20
-     * @param string|null      $CNT_ISO
21
-     * @return float
22
-     * @throws EE_Error
23
-     * @throws ReflectionException
24
-     */
25
-    public static function strip_localized_money_formatting($money_value, ?string $CNT_ISO = ''): float
26
-    {
27
-        $currency_config = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
28
-        $money_value     = str_replace(
29
-            [
30
-                $currency_config->thsnds,
31
-                $currency_config->dec_mrk,
32
-            ],
33
-            [
34
-                '', // remove thousands separator
35
-                '.', // convert decimal mark to what PHP expects
36
-            ],
37
-            $money_value
38
-        );
39
-        return (float) filter_var(
40
-            $money_value,
41
-            FILTER_SANITIZE_NUMBER_FLOAT,
42
-            FILTER_FLAG_ALLOW_FRACTION
43
-        );
44
-    }
13
+	/**
14
+	 * This removes all localized money formatting from the incoming value
15
+	 * Note: uses this site's currency settings for deciding what is considered a
16
+	 * "thousands separator" (usually the character "," )
17
+	 * and what is a "decimal mark" (usually the character ".")
18
+	 *
19
+	 * @param int|float|string $money_value
20
+	 * @param string|null      $CNT_ISO
21
+	 * @return float
22
+	 * @throws EE_Error
23
+	 * @throws ReflectionException
24
+	 */
25
+	public static function strip_localized_money_formatting($money_value, ?string $CNT_ISO = ''): float
26
+	{
27
+		$currency_config = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
28
+		$money_value     = str_replace(
29
+			[
30
+				$currency_config->thsnds,
31
+				$currency_config->dec_mrk,
32
+			],
33
+			[
34
+				'', // remove thousands separator
35
+				'.', // convert decimal mark to what PHP expects
36
+			],
37
+			$money_value
38
+		);
39
+		return (float) filter_var(
40
+			$money_value,
41
+			FILTER_SANITIZE_NUMBER_FLOAT,
42
+			FILTER_FLAG_ALLOW_FRACTION
43
+		);
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * This converts an incoming localized money value into a standard float item (to three decimal places)
49
-     * Only use this if you know the $money_value follows your currency configuration's
50
-     * settings. Note: this uses this site's currency settings for deciding what is considered a
51
-     * "thousands separator" (usually the character "," )
52
-     * and what is a "decimal mark" (usually the character ".")
53
-     *
54
-     * @param int|float|string $money_value
55
-     * @return float
56
-     * @throws EE_Error
57
-     * @throws ReflectionException
58
-     */
59
-    public static function convert_to_float_from_localized_money($money_value): float
60
-    {
61
-        // float it! and round to three decimal places
62
-        return round(EEH_Money::strip_localized_money_formatting($money_value), 3);
63
-    }
47
+	/**
48
+	 * This converts an incoming localized money value into a standard float item (to three decimal places)
49
+	 * Only use this if you know the $money_value follows your currency configuration's
50
+	 * settings. Note: this uses this site's currency settings for deciding what is considered a
51
+	 * "thousands separator" (usually the character "," )
52
+	 * and what is a "decimal mark" (usually the character ".")
53
+	 *
54
+	 * @param int|float|string $money_value
55
+	 * @return float
56
+	 * @throws EE_Error
57
+	 * @throws ReflectionException
58
+	 */
59
+	public static function convert_to_float_from_localized_money($money_value): float
60
+	{
61
+		// float it! and round to three decimal places
62
+		return round(EEH_Money::strip_localized_money_formatting($money_value), 3);
63
+	}
64 64
 
65 65
 
66
-    /**
67
-     * For comparing floats. Default operator is '=', but see the $operator below for all options.
68
-     * This should be used to compare floats instead of normal '==' because floats
69
-     * are inherently imprecise, and so you can sometimes have two floats that appear to be identical
70
-     * but actually differ by 0.00000001.
71
-     *
72
-     * @see http://biostall.com/php-function-to-compare-floating-point-numbers
73
-     * @param int|float|string $float1
74
-     * @param int|float|string $float2
75
-     * @param string|null      $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne
76
-     * @return bool whether the equation is true or false
77
-     * @throws EE_Error
78
-     */
79
-    public static function compare_floats($float1, $float2, ?string $operator = '='): bool
80
-    {
81
-        // Check numbers to 5 digits of precision
82
-        $epsilon = 0.00001;
83
-        $float1  = (float) $float1;
84
-        $float2  = (float) $float2;
85
-        switch ($operator) {
86
-            // equal
87
-            case '=':
88
-            case '==':
89
-            case '===':
90
-            case 'eq':
91
-                if (abs($float1 - $float2) < $epsilon) {
92
-                    return true;
93
-                }
94
-                break;
95
-            // less than
96
-            case '<':
97
-            case 'lt':
98
-                if (abs($float1 - $float2) < $epsilon) {
99
-                    return false;
100
-                }
101
-                if ($float1 < $float2) {
102
-                    return true;
103
-                }
104
-                break;
105
-            // less than or equal
106
-            case '<=':
107
-            case 'lte':
108
-                if (
109
-                    self::compare_floats($float1, $float2, '<')
110
-                    || self::compare_floats($float1, $float2)
111
-                ) {
112
-                    return true;
113
-                }
114
-                break;
115
-            // greater than
116
-            case '>':
117
-            case 'gt':
118
-                if (abs($float1 - $float2) < $epsilon) {
119
-                    return false;
120
-                }
121
-                if ($float1 > $float2) {
122
-                    return true;
123
-                }
124
-                break;
125
-            // greater than or equal
126
-            case '>=':
127
-            case 'gte':
128
-                if (
129
-                    self::compare_floats($float1, $float2, '>')
130
-                    || self::compare_floats($float1, $float2)
131
-                ) {
132
-                    return true;
133
-                }
134
-                break;
135
-            case '<>':
136
-            case '!=':
137
-            case '!==':
138
-            case 'ne':
139
-                if (abs($float1 - $float2) > $epsilon) {
140
-                    return true;
141
-                }
142
-                break;
143
-            default:
144
-                throw new EE_Error(
145
-                    sprintf(
146
-                        esc_html__(
147
-                            "Unknown operator %s in EEH_Money::compare_floats()",
148
-                            'event_espresso'
149
-                        ),
150
-                        $operator
151
-                    )
152
-                );
153
-        }
154
-        return false;
155
-    }
66
+	/**
67
+	 * For comparing floats. Default operator is '=', but see the $operator below for all options.
68
+	 * This should be used to compare floats instead of normal '==' because floats
69
+	 * are inherently imprecise, and so you can sometimes have two floats that appear to be identical
70
+	 * but actually differ by 0.00000001.
71
+	 *
72
+	 * @see http://biostall.com/php-function-to-compare-floating-point-numbers
73
+	 * @param int|float|string $float1
74
+	 * @param int|float|string $float2
75
+	 * @param string|null      $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne
76
+	 * @return bool whether the equation is true or false
77
+	 * @throws EE_Error
78
+	 */
79
+	public static function compare_floats($float1, $float2, ?string $operator = '='): bool
80
+	{
81
+		// Check numbers to 5 digits of precision
82
+		$epsilon = 0.00001;
83
+		$float1  = (float) $float1;
84
+		$float2  = (float) $float2;
85
+		switch ($operator) {
86
+			// equal
87
+			case '=':
88
+			case '==':
89
+			case '===':
90
+			case 'eq':
91
+				if (abs($float1 - $float2) < $epsilon) {
92
+					return true;
93
+				}
94
+				break;
95
+			// less than
96
+			case '<':
97
+			case 'lt':
98
+				if (abs($float1 - $float2) < $epsilon) {
99
+					return false;
100
+				}
101
+				if ($float1 < $float2) {
102
+					return true;
103
+				}
104
+				break;
105
+			// less than or equal
106
+			case '<=':
107
+			case 'lte':
108
+				if (
109
+					self::compare_floats($float1, $float2, '<')
110
+					|| self::compare_floats($float1, $float2)
111
+				) {
112
+					return true;
113
+				}
114
+				break;
115
+			// greater than
116
+			case '>':
117
+			case 'gt':
118
+				if (abs($float1 - $float2) < $epsilon) {
119
+					return false;
120
+				}
121
+				if ($float1 > $float2) {
122
+					return true;
123
+				}
124
+				break;
125
+			// greater than or equal
126
+			case '>=':
127
+			case 'gte':
128
+				if (
129
+					self::compare_floats($float1, $float2, '>')
130
+					|| self::compare_floats($float1, $float2)
131
+				) {
132
+					return true;
133
+				}
134
+				break;
135
+			case '<>':
136
+			case '!=':
137
+			case '!==':
138
+			case 'ne':
139
+				if (abs($float1 - $float2) > $epsilon) {
140
+					return true;
141
+				}
142
+				break;
143
+			default:
144
+				throw new EE_Error(
145
+					sprintf(
146
+						esc_html__(
147
+							"Unknown operator %s in EEH_Money::compare_floats()",
148
+							'event_espresso'
149
+						),
150
+						$operator
151
+					)
152
+				);
153
+		}
154
+		return false;
155
+	}
156 156
 
157 157
 
158
-    /**
159
-     * This returns a localized format string suitable for jQplot.
160
-     *
161
-     * @param string|null $CNT_ISO If this is provided, then will attempt to get the currency settings for the country.
162
-     *                             Otherwise will use currency settings for current active country on site.
163
-     * @return string
164
-     * @throws EE_Error
165
-     * @throws ReflectionException
166
-     */
167
-    public static function get_format_for_jqplot(?string $CNT_ISO = ''): string
168
-    {
169
-        // default format
170
-        $format          = 'f';
171
-        $currency_config = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
172
-        // first get the decimal place and number of places
173
-        $format = "%'." . $currency_config->dec_plc . $format;
174
-        // currency symbol on right side.
175
-        return $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign;
176
-    }
158
+	/**
159
+	 * This returns a localized format string suitable for jQplot.
160
+	 *
161
+	 * @param string|null $CNT_ISO If this is provided, then will attempt to get the currency settings for the country.
162
+	 *                             Otherwise will use currency settings for current active country on site.
163
+	 * @return string
164
+	 * @throws EE_Error
165
+	 * @throws ReflectionException
166
+	 */
167
+	public static function get_format_for_jqplot(?string $CNT_ISO = ''): string
168
+	{
169
+		// default format
170
+		$format          = 'f';
171
+		$currency_config = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
172
+		// first get the decimal place and number of places
173
+		$format = "%'." . $currency_config->dec_plc . $format;
174
+		// currency symbol on right side.
175
+		return $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign;
176
+	}
177 177
 
178 178
 
179
-    /**
180
-     * This returns a localized format string suitable for usage with the Google Charts API format param.
181
-     *
182
-     * @param string|null $CNT_ISO If this is provided, then will attempt to get the currency settings for the country.
183
-     *                             Otherwise will use currency settings for current active country on site.
184
-     *                             Note: GoogleCharts uses ICU pattern set
185
-     *                             (@return array
186
-     * @return array
187
-     * @throws EE_Error
188
-     * @throws ReflectionException
189
-     * @see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details)
190
-     */
191
-    public static function get_format_for_google_charts(?string $CNT_ISO = ''): array
192
-    {
193
-        $currency_config            = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
194
-        $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0');
195
-        // first get the decimal place and number of places
196
-        $format = '#,##0.' . $decimal_places_placeholder;
197
-        // currency symbol on right side.
198
-        $format          = $currency_config->sign_b4
199
-            ? $currency_config->sign . $format
200
-            : $format
201
-              . $currency_config->sign;
202
-        $formatterObject = [
203
-            'decimalSymbol'  => $currency_config->dec_mrk,
204
-            'groupingSymbol' => $currency_config->thsnds,
205
-            'fractionDigits' => $currency_config->dec_plc,
206
-        ];
207
-        if ($currency_config->sign_b4) {
208
-            $formatterObject['prefix'] = $currency_config->sign;
209
-        } else {
210
-            $formatterObject['suffix'] = $currency_config->sign;
211
-        }
212
-        return [
213
-            'format'          => $format,
214
-            'formatterObject' => $formatterObject,
215
-        ];
216
-    }
179
+	/**
180
+	 * This returns a localized format string suitable for usage with the Google Charts API format param.
181
+	 *
182
+	 * @param string|null $CNT_ISO If this is provided, then will attempt to get the currency settings for the country.
183
+	 *                             Otherwise will use currency settings for current active country on site.
184
+	 *                             Note: GoogleCharts uses ICU pattern set
185
+	 *                             (@return array
186
+	 * @return array
187
+	 * @throws EE_Error
188
+	 * @throws ReflectionException
189
+	 * @see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details)
190
+	 */
191
+	public static function get_format_for_google_charts(?string $CNT_ISO = ''): array
192
+	{
193
+		$currency_config            = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
194
+		$decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0');
195
+		// first get the decimal place and number of places
196
+		$format = '#,##0.' . $decimal_places_placeholder;
197
+		// currency symbol on right side.
198
+		$format          = $currency_config->sign_b4
199
+			? $currency_config->sign . $format
200
+			: $format
201
+			  . $currency_config->sign;
202
+		$formatterObject = [
203
+			'decimalSymbol'  => $currency_config->dec_mrk,
204
+			'groupingSymbol' => $currency_config->thsnds,
205
+			'fractionDigits' => $currency_config->dec_plc,
206
+		];
207
+		if ($currency_config->sign_b4) {
208
+			$formatterObject['prefix'] = $currency_config->sign;
209
+		} else {
210
+			$formatterObject['suffix'] = $currency_config->sign;
211
+		}
212
+		return [
213
+			'format'          => $format,
214
+			'formatterObject' => $formatterObject,
215
+		];
216
+	}
217 217
 
218 218
 
219
-    /**
220
-     * @param string|null $CNT_ISO
221
-     * @return EE_Currency_Config
222
-     * @throws EE_Error
223
-     * @throws ReflectionException
224
-     */
225
-    public static function get_currency_config(?string $CNT_ISO = ''): EE_Currency_Config
226
-    {
227
-        return EE_Currency_Config::getCurrencyConfig($CNT_ISO);
228
-    }
219
+	/**
220
+	 * @param string|null $CNT_ISO
221
+	 * @return EE_Currency_Config
222
+	 * @throws EE_Error
223
+	 * @throws ReflectionException
224
+	 */
225
+	public static function get_currency_config(?string $CNT_ISO = ''): EE_Currency_Config
226
+	{
227
+		return EE_Currency_Config::getCurrencyConfig($CNT_ISO);
228
+	}
229 229
 
230 230
 
231
-    /**
232
-     * @param string|null $CNT_ISO
233
-     * @param bool        $as_decimal if false [default] will return the number of decimal places ex: 1, 2, 3
234
-     *                                if true, will return the subunits as a decimal fraction ex: .1, .01, .001
235
-     * @return float
236
-     * @throws EE_Error
237
-     * @throws ReflectionException
238
-     * @since 5.0.0.p
239
-     */
240
-    public static function getCurrencySubUnits(?string $CNT_ISO = '', bool $as_decimal = false): float
241
-    {
242
-        $currency_config = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
243
-        return $as_decimal ? pow(10, ($currency_config->dec_plc * -1)) : $currency_config->dec_plc;
244
-    }
231
+	/**
232
+	 * @param string|null $CNT_ISO
233
+	 * @param bool        $as_decimal if false [default] will return the number of decimal places ex: 1, 2, 3
234
+	 *                                if true, will return the subunits as a decimal fraction ex: .1, .01, .001
235
+	 * @return float
236
+	 * @throws EE_Error
237
+	 * @throws ReflectionException
238
+	 * @since 5.0.0.p
239
+	 */
240
+	public static function getCurrencySubUnits(?string $CNT_ISO = '', bool $as_decimal = false): float
241
+	{
242
+		$currency_config = EE_Currency_Config::getCurrencyConfig($CNT_ISO);
243
+		return $as_decimal ? pow(10, ($currency_config->dec_plc * -1)) : $currency_config->dec_plc;
244
+	}
245 245
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Price.model.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -115,23 +115,23 @@  discard block
 block discarded – undo
115 115
             'WP_User'    => new EE_Belongs_To_Relation(),
116 116
         ];
117 117
         // this model is generally available for reading
118
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] =
118
+        $this->_cap_restriction_generators[EEM_Base::caps_read] =
119 119
             new EE_Restriction_Generator_Default_Public(
120 120
                 'PRC_is_default',
121 121
                 'Ticket.Datetime.Event'
122 122
             );
123 123
         // account for default tickets in the caps
124
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
124
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] =
125 125
             new EE_Restriction_Generator_Default_Protected(
126 126
                 'PRC_is_default',
127 127
                 'Ticket.Datetime.Event'
128 128
             );
129
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
129
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] =
130 130
             new EE_Restriction_Generator_Default_Protected(
131 131
                 'PRC_is_default',
132 132
                 'Ticket.Datetime.Event'
133 133
             );
134
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
134
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] =
135 135
             new EE_Restriction_Generator_Default_Protected(
136 136
                 'PRC_is_default',
137 137
                 'Ticket.Datetime.Event'
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
             'PRC_deleted'    => 0,
200 200
             'PRC_is_default' => 1,
201 201
         ];
202
-        if (! $include_taxes) {
202
+        if ( ! $include_taxes) {
203 203
             $_where['Price_Type.PBT_ID'] = ['!=', 4];
204 204
         }
205 205
         $_query_params = [
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         );
257 257
         foreach ($all_taxes as $tax) {
258 258
             if ($tax instanceof EE_Price) {
259
-                $taxes[ $tax->order() ][ $tax->ID() ] = $tax;
259
+                $taxes[$tax->order()][$tax->ID()] = $tax;
260 260
             }
261 261
         }
262 262
         return $taxes;
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
             if ($default_prices) {
282 282
                 foreach ($default_prices as $price) {
283 283
                     if ($price instanceof EE_Price) {
284
-                        $array_of_price_objects[ $price->type() ][] = $price;
284
+                        $array_of_price_objects[$price->type()][] = $price;
285 285
                     }
286 286
                 }
287 287
                 return $array_of_price_objects;
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
             ]
299 299
         );
300 300
 
301
-        if (! empty($ticket_prices)) {
301
+        if ( ! empty($ticket_prices)) {
302 302
             foreach ($ticket_prices as $price) {
303 303
                 if ($price instanceof EE_Price) {
304
-                    $array_of_price_objects[ $price->type() ][] = $price;
304
+                    $array_of_price_objects[$price->type()][] = $price;
305 305
                 }
306 306
             }
307 307
             return $array_of_price_objects;
Please login to merge, or discard this patch.
Indentation   +349 added lines, -349 removed lines patch added patch discarded remove patch
@@ -12,380 +12,380 @@
 block discarded – undo
12 12
  */
13 13
 class EEM_Price extends EEM_Soft_Delete_Base
14 14
 {
15
-    protected static ?EEM_Price $_instance = null;
15
+	protected static ?EEM_Price $_instance = null;
16 16
 
17 17
 
18
-    /**
19
-     * private constructor to prevent direct creation
20
-     *
21
-     * @Constructor
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
-     *                              Default is NULL
26
-     *                              (and will be assumed using the set timezone in the 'timezone_string' wp option)
27
-     * @throws EE_Error
28
-     * @throws ReflectionException
29
-     */
30
-    protected function __construct(?string $timezone = '')
31
-    {
32
-        $this->singular_item = esc_html__('Price', 'event_espresso');
33
-        $this->plural_item   = esc_html__('Prices', 'event_espresso');
18
+	/**
19
+	 * private constructor to prevent direct creation
20
+	 *
21
+	 * @Constructor
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
+	 *                              Default is NULL
26
+	 *                              (and will be assumed using the set timezone in the 'timezone_string' wp option)
27
+	 * @throws EE_Error
28
+	 * @throws ReflectionException
29
+	 */
30
+	protected function __construct(?string $timezone = '')
31
+	{
32
+		$this->singular_item = esc_html__('Price', 'event_espresso');
33
+		$this->plural_item   = esc_html__('Prices', 'event_espresso');
34 34
 
35
-        $this->_tables          = [
36
-            'Price' => new EE_Primary_Table('esp_price', 'PRC_ID'),
37
-        ];
38
-        $this->_fields          = [
39
-            'Price' => [
40
-                'PRC_ID'         => new EE_Primary_Key_Int_Field(
41
-                    'PRC_ID',
42
-                    'Price ID'
43
-                ),
44
-                'PRT_ID'         => new EE_Foreign_Key_Int_Field(
45
-                    'PRT_ID',
46
-                    esc_html__('Price type Id', 'event_espresso'),
47
-                    false,
48
-                    null,
49
-                    'Price_Type'
50
-                ),
51
-                'PRC_amount'     => new EE_Money_Field(
52
-                    'PRC_amount',
53
-                    esc_html__('Price Amount', 'event_espresso'),
54
-                    false,
55
-                    0
56
-                ),
57
-                'PRC_name'       => new EE_Plain_Text_Field(
58
-                    'PRC_name',
59
-                    esc_html__('Name of Price', 'event_espresso'),
60
-                    false,
61
-                    ''
62
-                ),
63
-                'PRC_desc'       => new EE_Post_Content_Field(
64
-                    'PRC_desc',
65
-                    esc_html__('Price Description', 'event_espresso'),
66
-                    false,
67
-                    ''
68
-                ),
69
-                'PRC_is_default' => new EE_Boolean_Field(
70
-                    'PRC_is_default',
71
-                    esc_html__('Flag indicating whether price is a default price', 'event_espresso'),
72
-                    false,
73
-                    false
74
-                ),
75
-                'PRC_overrides'  => new EE_Integer_Field(
76
-                    'PRC_overrides',
77
-                    esc_html__(
78
-                        'Price ID for a global Price that will be overridden by this Price  ( for replacing default prices )',
79
-                        'event_espresso'
80
-                    ),
81
-                    true,
82
-                    0
83
-                ),
84
-                'PRC_order'      => new EE_Integer_Field(
85
-                    'PRC_order',
86
-                    esc_html__(
87
-                        'Order of Application of Price (lower numbers apply first?)',
88
-                        'event_espresso'
89
-                    ),
90
-                    false,
91
-                    1
92
-                ),
93
-                'PRC_deleted'    => new EE_Trashed_Flag_Field(
94
-                    'PRC_deleted',
95
-                    esc_html__('Flag Indicating if this has been deleted or not', 'event_espresso'),
96
-                    false,
97
-                    false
98
-                ),
99
-                'PRC_parent'     => new EE_Integer_Field(
100
-                    'PRC_parent',
101
-                    esc_html__('Indicates what PRC_ID is the parent of this PRC_ID', 'event_espresso'),
102
-                    true,
103
-                    0
104
-                ),
105
-                'PRC_wp_user'    => new EE_WP_User_Field(
106
-                    'PRC_wp_user',
107
-                    esc_html__('Price Creator ID', 'event_espresso'),
108
-                    false
109
-                ),
110
-            ],
111
-        ];
112
-        $this->_model_relations = [
113
-            'Ticket'     => new EE_HABTM_Relation('Ticket_Price'),
114
-            'Price_Type' => new EE_Belongs_To_Relation(),
115
-            'WP_User'    => new EE_Belongs_To_Relation(),
116
-        ];
117
-        // this model is generally available for reading
118
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] =
119
-            new EE_Restriction_Generator_Default_Public(
120
-                'PRC_is_default',
121
-                'Ticket.Datetime.Event'
122
-            );
123
-        // account for default tickets in the caps
124
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
125
-            new EE_Restriction_Generator_Default_Protected(
126
-                'PRC_is_default',
127
-                'Ticket.Datetime.Event'
128
-            );
129
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
130
-            new EE_Restriction_Generator_Default_Protected(
131
-                'PRC_is_default',
132
-                'Ticket.Datetime.Event'
133
-            );
134
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
135
-            new EE_Restriction_Generator_Default_Protected(
136
-                'PRC_is_default',
137
-                'Ticket.Datetime.Event'
138
-            );
139
-        parent::__construct($timezone);
140
-    }
35
+		$this->_tables          = [
36
+			'Price' => new EE_Primary_Table('esp_price', 'PRC_ID'),
37
+		];
38
+		$this->_fields          = [
39
+			'Price' => [
40
+				'PRC_ID'         => new EE_Primary_Key_Int_Field(
41
+					'PRC_ID',
42
+					'Price ID'
43
+				),
44
+				'PRT_ID'         => new EE_Foreign_Key_Int_Field(
45
+					'PRT_ID',
46
+					esc_html__('Price type Id', 'event_espresso'),
47
+					false,
48
+					null,
49
+					'Price_Type'
50
+				),
51
+				'PRC_amount'     => new EE_Money_Field(
52
+					'PRC_amount',
53
+					esc_html__('Price Amount', 'event_espresso'),
54
+					false,
55
+					0
56
+				),
57
+				'PRC_name'       => new EE_Plain_Text_Field(
58
+					'PRC_name',
59
+					esc_html__('Name of Price', 'event_espresso'),
60
+					false,
61
+					''
62
+				),
63
+				'PRC_desc'       => new EE_Post_Content_Field(
64
+					'PRC_desc',
65
+					esc_html__('Price Description', 'event_espresso'),
66
+					false,
67
+					''
68
+				),
69
+				'PRC_is_default' => new EE_Boolean_Field(
70
+					'PRC_is_default',
71
+					esc_html__('Flag indicating whether price is a default price', 'event_espresso'),
72
+					false,
73
+					false
74
+				),
75
+				'PRC_overrides'  => new EE_Integer_Field(
76
+					'PRC_overrides',
77
+					esc_html__(
78
+						'Price ID for a global Price that will be overridden by this Price  ( for replacing default prices )',
79
+						'event_espresso'
80
+					),
81
+					true,
82
+					0
83
+				),
84
+				'PRC_order'      => new EE_Integer_Field(
85
+					'PRC_order',
86
+					esc_html__(
87
+						'Order of Application of Price (lower numbers apply first?)',
88
+						'event_espresso'
89
+					),
90
+					false,
91
+					1
92
+				),
93
+				'PRC_deleted'    => new EE_Trashed_Flag_Field(
94
+					'PRC_deleted',
95
+					esc_html__('Flag Indicating if this has been deleted or not', 'event_espresso'),
96
+					false,
97
+					false
98
+				),
99
+				'PRC_parent'     => new EE_Integer_Field(
100
+					'PRC_parent',
101
+					esc_html__('Indicates what PRC_ID is the parent of this PRC_ID', 'event_espresso'),
102
+					true,
103
+					0
104
+				),
105
+				'PRC_wp_user'    => new EE_WP_User_Field(
106
+					'PRC_wp_user',
107
+					esc_html__('Price Creator ID', 'event_espresso'),
108
+					false
109
+				),
110
+			],
111
+		];
112
+		$this->_model_relations = [
113
+			'Ticket'     => new EE_HABTM_Relation('Ticket_Price'),
114
+			'Price_Type' => new EE_Belongs_To_Relation(),
115
+			'WP_User'    => new EE_Belongs_To_Relation(),
116
+		];
117
+		// this model is generally available for reading
118
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] =
119
+			new EE_Restriction_Generator_Default_Public(
120
+				'PRC_is_default',
121
+				'Ticket.Datetime.Event'
122
+			);
123
+		// account for default tickets in the caps
124
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] =
125
+			new EE_Restriction_Generator_Default_Protected(
126
+				'PRC_is_default',
127
+				'Ticket.Datetime.Event'
128
+			);
129
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ]       =
130
+			new EE_Restriction_Generator_Default_Protected(
131
+				'PRC_is_default',
132
+				'Ticket.Datetime.Event'
133
+			);
134
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ]     =
135
+			new EE_Restriction_Generator_Default_Protected(
136
+				'PRC_is_default',
137
+				'Ticket.Datetime.Event'
138
+			);
139
+		parent::__construct($timezone);
140
+	}
141 141
 
142 142
 
143
-    /**
144
-     * instantiate a new price object with blank/empty properties
145
-     *
146
-     * @return EE_Price
147
-     * @throws EE_Error
148
-     * @throws ReflectionException
149
-     */
150
-    public function get_new_price(): EE_Price
151
-    {
152
-        return $this->create_default_object();
153
-    }
143
+	/**
144
+	 * instantiate a new price object with blank/empty properties
145
+	 *
146
+	 * @return EE_Price
147
+	 * @throws EE_Error
148
+	 * @throws ReflectionException
149
+	 */
150
+	public function get_new_price(): EE_Price
151
+	{
152
+		return $this->create_default_object();
153
+	}
154 154
 
155 155
 
156
-    /**
157
-     * retrieve  ALL prices from db
158
-     *
159
-     * @return EE_Price[]
160
-     * @throws EE_Error
161
-     * @throws ReflectionException
162
-     */
163
-    public function get_all_prices(): array
164
-    {
165
-        // retrieve all prices
166
-        return $this->get_all(['order_by' => ['PRC_amount' => 'ASC']]);
167
-    }
156
+	/**
157
+	 * retrieve  ALL prices from db
158
+	 *
159
+	 * @return EE_Price[]
160
+	 * @throws EE_Error
161
+	 * @throws ReflectionException
162
+	 */
163
+	public function get_all_prices(): array
164
+	{
165
+		// retrieve all prices
166
+		return $this->get_all(['order_by' => ['PRC_amount' => 'ASC']]);
167
+	}
168 168
 
169 169
 
170
-    /**
171
-     * retrieve all active prices for a particular event
172
-     *
173
-     * @param int $EVT_ID
174
-     * @return array on success
175
-     * @throws EE_Error
176
-     * @throws ReflectionException
177
-     */
178
-    public function get_all_event_prices(int $EVT_ID = 0): array
179
-    {
180
-        return $this->get_all(
181
-            [
182
-                [
183
-                    'EVT_ID'            => $EVT_ID,
184
-                    'Price_Type.PBT_ID' => ['!=', EEM_Price_Type::base_type_tax],
185
-                ],
186
-                'order_by' => $this->_order_by_array_for_get_all_method(),
187
-            ]
188
-        );
189
-    }
170
+	/**
171
+	 * retrieve all active prices for a particular event
172
+	 *
173
+	 * @param int $EVT_ID
174
+	 * @return array on success
175
+	 * @throws EE_Error
176
+	 * @throws ReflectionException
177
+	 */
178
+	public function get_all_event_prices(int $EVT_ID = 0): array
179
+	{
180
+		return $this->get_all(
181
+			[
182
+				[
183
+					'EVT_ID'            => $EVT_ID,
184
+					'Price_Type.PBT_ID' => ['!=', EEM_Price_Type::base_type_tax],
185
+				],
186
+				'order_by' => $this->_order_by_array_for_get_all_method(),
187
+			]
188
+		);
189
+	}
190 190
 
191 191
 
192
-    /**
193
-     * retrieve all active global prices (that are not taxes (PBT_ID=4)) for a particular event
194
-     *
195
-     * @param bool $count return count
196
-     * @param bool $include_taxes
197
-     * @return int|EE_Price[]
198
-     * @throws EE_Error
199
-     * @throws ReflectionException
200
-     * @throws ReflectionException
201
-     */
202
-    public function get_all_default_prices(bool $count = false, bool $include_taxes = false)
203
-    {
204
-        $_where = [
205
-            'PRC_deleted'    => 0,
206
-            'PRC_is_default' => 1,
207
-        ];
208
-        if (! $include_taxes) {
209
-            $_where['Price_Type.PBT_ID'] = ['!=', 4];
210
-        }
211
-        $_query_params = [
212
-            $_where,
213
-            'order_by' => $this->_order_by_array_for_get_all_method(),
214
-        ];
215
-        return $count ? $this->count([$_where]) : $this->get_all($_query_params);
216
-    }
192
+	/**
193
+	 * retrieve all active global prices (that are not taxes (PBT_ID=4)) for a particular event
194
+	 *
195
+	 * @param bool $count return count
196
+	 * @param bool $include_taxes
197
+	 * @return int|EE_Price[]
198
+	 * @throws EE_Error
199
+	 * @throws ReflectionException
200
+	 * @throws ReflectionException
201
+	 */
202
+	public function get_all_default_prices(bool $count = false, bool $include_taxes = false)
203
+	{
204
+		$_where = [
205
+			'PRC_deleted'    => 0,
206
+			'PRC_is_default' => 1,
207
+		];
208
+		if (! $include_taxes) {
209
+			$_where['Price_Type.PBT_ID'] = ['!=', 4];
210
+		}
211
+		$_query_params = [
212
+			$_where,
213
+			'order_by' => $this->_order_by_array_for_get_all_method(),
214
+		];
215
+		return $count ? $this->count([$_where]) : $this->get_all($_query_params);
216
+	}
217 217
 
218 218
 
219
-    /**
220
-     * retrieve all active global prices that are taxes
221
-     *
222
-     * @return EE_Price[]
223
-     * @throws EE_Error
224
-     * @throws ReflectionException
225
-     * @since   5.0.0.p
226
-     */
227
-    public function getAllDefaultTaxes(): array
228
-    {
229
-        return $this->get_all(
230
-            [
231
-                [
232
-                    'PRC_deleted'       => 0,
233
-                    'PRC_is_default'    => 1,
234
-                    'Price_Type.PBT_ID' => EEM_Price_Type::base_type_tax,
235
-                ],
236
-                'order_by' => [
237
-                    'Price_Type.PRT_order' => 'ASC',
238
-                    'PRC_order'            => 'ASC',
239
-                ],
240
-            ]
241
-        );
242
-    }
219
+	/**
220
+	 * retrieve all active global prices that are taxes
221
+	 *
222
+	 * @return EE_Price[]
223
+	 * @throws EE_Error
224
+	 * @throws ReflectionException
225
+	 * @since   5.0.0.p
226
+	 */
227
+	public function getAllDefaultTaxes(): array
228
+	{
229
+		return $this->get_all(
230
+			[
231
+				[
232
+					'PRC_deleted'       => 0,
233
+					'PRC_is_default'    => 1,
234
+					'Price_Type.PBT_ID' => EEM_Price_Type::base_type_tax,
235
+				],
236
+				'order_by' => [
237
+					'Price_Type.PRT_order' => 'ASC',
238
+					'PRC_order'            => 'ASC',
239
+				],
240
+			]
241
+		);
242
+	}
243 243
 
244 244
 
245
-    /**
246
-     * retrieve all prices that are taxes
247
-     *
248
-     * @return EE_Price[]
249
-     * @throws EE_Error
250
-     * @throws InvalidArgumentException
251
-     * @throws ReflectionException
252
-     * @throws InvalidDataTypeException
253
-     * @throws InvalidInterfaceException
254
-     */
255
-    public function get_all_prices_that_are_taxes(): array
256
-    {
257
-        $taxes     = [];
258
-        $all_taxes = $this->get_all(
259
-            [
260
-                ['Price_Type.PBT_ID' => EEM_Price_Type::base_type_tax, 'PRC_is_default' => 1],
261
-                'order_by' => ['Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC'],
262
-            ]
263
-        );
264
-        foreach ($all_taxes as $tax) {
265
-            if ($tax instanceof EE_Price) {
266
-                $taxes[ $tax->order() ][ $tax->ID() ] = $tax;
267
-            }
268
-        }
269
-        return $taxes;
270
-    }
245
+	/**
246
+	 * retrieve all prices that are taxes
247
+	 *
248
+	 * @return EE_Price[]
249
+	 * @throws EE_Error
250
+	 * @throws InvalidArgumentException
251
+	 * @throws ReflectionException
252
+	 * @throws InvalidDataTypeException
253
+	 * @throws InvalidInterfaceException
254
+	 */
255
+	public function get_all_prices_that_are_taxes(): array
256
+	{
257
+		$taxes     = [];
258
+		$all_taxes = $this->get_all(
259
+			[
260
+				['Price_Type.PBT_ID' => EEM_Price_Type::base_type_tax, 'PRC_is_default' => 1],
261
+				'order_by' => ['Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC'],
262
+			]
263
+		);
264
+		foreach ($all_taxes as $tax) {
265
+			if ($tax instanceof EE_Price) {
266
+				$taxes[ $tax->order() ][ $tax->ID() ] = $tax;
267
+			}
268
+		}
269
+		return $taxes;
270
+	}
271 271
 
272 272
 
273
-    /**
274
-     * retrieve all prices for an ticket plus default global prices, but not taxes
275
-     *
276
-     * @param int $TKT_ID the id of the event.  If not included then we assume that this is a new ticket.
277
-     * @return EE_Price[]
278
-     * @throws EE_Error
279
-     * @throws ReflectionException
280
-     * @throws ReflectionException
281
-     * @throws ReflectionException
282
-     */
283
-    public function get_all_ticket_prices_for_admin(int $TKT_ID = 0): array
284
-    {
285
-        $array_of_price_objects = [];
286
-        if (empty($TKT_ID)) {
287
-            // if there is no tkt, get prices with no tkt ID, are global, are not a tax, and are active
288
-            // return that list
289
-            $default_prices = $this->get_all_default_prices();
273
+	/**
274
+	 * retrieve all prices for an ticket plus default global prices, but not taxes
275
+	 *
276
+	 * @param int $TKT_ID the id of the event.  If not included then we assume that this is a new ticket.
277
+	 * @return EE_Price[]
278
+	 * @throws EE_Error
279
+	 * @throws ReflectionException
280
+	 * @throws ReflectionException
281
+	 * @throws ReflectionException
282
+	 */
283
+	public function get_all_ticket_prices_for_admin(int $TKT_ID = 0): array
284
+	{
285
+		$array_of_price_objects = [];
286
+		if (empty($TKT_ID)) {
287
+			// if there is no tkt, get prices with no tkt ID, are global, are not a tax, and are active
288
+			// return that list
289
+			$default_prices = $this->get_all_default_prices();
290 290
 
291
-            if ($default_prices) {
292
-                foreach ($default_prices as $price) {
293
-                    if ($price instanceof EE_Price) {
294
-                        $array_of_price_objects[ $price->type() ][] = $price;
295
-                    }
296
-                }
297
-                return $array_of_price_objects;
298
-            }
299
-            return [];
300
-        }
301
-        $ticket_prices = $this->get_all(
302
-            [
303
-                [
304
-                    'TKT_ID'      => $TKT_ID,
305
-                    'PRC_deleted' => 0,
306
-                ],
307
-                'order_by' => ['PRC_order' => 'ASC'],
308
-            ]
309
-        );
291
+			if ($default_prices) {
292
+				foreach ($default_prices as $price) {
293
+					if ($price instanceof EE_Price) {
294
+						$array_of_price_objects[ $price->type() ][] = $price;
295
+					}
296
+				}
297
+				return $array_of_price_objects;
298
+			}
299
+			return [];
300
+		}
301
+		$ticket_prices = $this->get_all(
302
+			[
303
+				[
304
+					'TKT_ID'      => $TKT_ID,
305
+					'PRC_deleted' => 0,
306
+				],
307
+				'order_by' => ['PRC_order' => 'ASC'],
308
+			]
309
+		);
310 310
 
311
-        if (! empty($ticket_prices)) {
312
-            foreach ($ticket_prices as $price) {
313
-                if ($price instanceof EE_Price) {
314
-                    $array_of_price_objects[ $price->type() ][] = $price;
315
-                }
316
-            }
317
-            return $array_of_price_objects;
318
-        }
319
-        return [];
320
-    }
311
+		if (! empty($ticket_prices)) {
312
+			foreach ($ticket_prices as $price) {
313
+				if ($price instanceof EE_Price) {
314
+					$array_of_price_objects[ $price->type() ][] = $price;
315
+				}
316
+			}
317
+			return $array_of_price_objects;
318
+		}
319
+		return [];
320
+	}
321 321
 
322 322
 
323
-    /**
324
-     * @param EE_Price $price_a
325
-     * @param EE_Price $price_b
326
-     * @return int
327
-     * @throws EE_Error
328
-     * @throws ReflectionException
329
-     */
330
-    public function _sort_event_prices_by_type(EE_Price $price_a, EE_Price $price_b): int
331
-    {
332
-        if ($price_a->type_obj()->order() === $price_b->type_obj()->order()) {
333
-            return $this->_sort_event_prices_by_order($price_a, $price_b);
334
-        }
335
-        return $price_a->type_obj()->order() < $price_b->type_obj()->order() ? -1 : 1;
336
-    }
323
+	/**
324
+	 * @param EE_Price $price_a
325
+	 * @param EE_Price $price_b
326
+	 * @return int
327
+	 * @throws EE_Error
328
+	 * @throws ReflectionException
329
+	 */
330
+	public function _sort_event_prices_by_type(EE_Price $price_a, EE_Price $price_b): int
331
+	{
332
+		if ($price_a->type_obj()->order() === $price_b->type_obj()->order()) {
333
+			return $this->_sort_event_prices_by_order($price_a, $price_b);
334
+		}
335
+		return $price_a->type_obj()->order() < $price_b->type_obj()->order() ? -1 : 1;
336
+	}
337 337
 
338 338
 
339
-    /**
340
-     * @param EE_Price $price_a
341
-     * @param EE_Price $price_b
342
-     * @return int
343
-     * @throws EE_Error
344
-     * @throws ReflectionException
345
-     */
346
-    public function _sort_event_prices_by_order(EE_Price $price_a, EE_Price $price_b): int
347
-    {
348
-        if ($price_a->order() === $price_b->order()) {
349
-            return 0;
350
-        }
351
-        return $price_a->order() < $price_b->order() ? -1 : 1;
352
-    }
339
+	/**
340
+	 * @param EE_Price $price_a
341
+	 * @param EE_Price $price_b
342
+	 * @return int
343
+	 * @throws EE_Error
344
+	 * @throws ReflectionException
345
+	 */
346
+	public function _sort_event_prices_by_order(EE_Price $price_a, EE_Price $price_b): int
347
+	{
348
+		if ($price_a->order() === $price_b->order()) {
349
+			return 0;
350
+		}
351
+		return $price_a->order() < $price_b->order() ? -1 : 1;
352
+	}
353 353
 
354 354
 
355
-    /**
356
-     * get all prices of a specific type
357
-     *
358
-     * @param int $type - PRT_ID
359
-     * @return EE_Price[]
360
-     * @throws EE_Error
361
-     * @throws ReflectionException
362
-     */
363
-    public function get_all_prices_that_are_type(int $type = 0): array
364
-    {
365
-        return $this->get_all(
366
-            [
367
-                [
368
-                    'PRT_ID' => $type,
369
-                ],
370
-                'order_by' => $this->_order_by_array_for_get_all_method(),
371
-            ]
372
-        );
373
-    }
355
+	/**
356
+	 * get all prices of a specific type
357
+	 *
358
+	 * @param int $type - PRT_ID
359
+	 * @return EE_Price[]
360
+	 * @throws EE_Error
361
+	 * @throws ReflectionException
362
+	 */
363
+	public function get_all_prices_that_are_type(int $type = 0): array
364
+	{
365
+		return $this->get_all(
366
+			[
367
+				[
368
+					'PRT_ID' => $type,
369
+				],
370
+				'order_by' => $this->_order_by_array_for_get_all_method(),
371
+			]
372
+		);
373
+	}
374 374
 
375 375
 
376
-    /**
377
-     * Returns an array of the normal 'order_by' query parameter provided to the get_all query.
378
-     * Of course you don't have to use it, but this is the order we usually want to sort prices by
379
-     *
380
-     * @return array which can be used like so: $this->get_all(array(array(...where
381
-     *               stuff...),'order_by'=>$this->_order_by_array_for_get_all_method()));
382
-     */
383
-    public function _order_by_array_for_get_all_method(): array
384
-    {
385
-        return [
386
-            'PRC_order'            => 'ASC',
387
-            'Price_Type.PRT_order' => 'ASC',
388
-            'PRC_ID'               => 'ASC',
389
-        ];
390
-    }
376
+	/**
377
+	 * Returns an array of the normal 'order_by' query parameter provided to the get_all query.
378
+	 * Of course you don't have to use it, but this is the order we usually want to sort prices by
379
+	 *
380
+	 * @return array which can be used like so: $this->get_all(array(array(...where
381
+	 *               stuff...),'order_by'=>$this->_order_by_array_for_get_all_method()));
382
+	 */
383
+	public function _order_by_array_for_get_all_method(): array
384
+	{
385
+		return [
386
+			'PRC_order'            => 'ASC',
387
+			'Price_Type.PRT_order' => 'ASC',
388
+			'PRC_ID'               => 'ASC',
389
+		];
390
+	}
391 391
 }
Please login to merge, or discard this patch.