@@ -11,61 +11,61 @@ |
||
11 | 11 | class EE_Radio_Button_Display_Strategy extends EE_Compound_Input_Display_Strategy |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * |
|
16 | - * @throws EE_Error |
|
17 | - * @return string of html to display the field |
|
18 | - */ |
|
19 | - public function display() |
|
20 | - { |
|
21 | - $input = $this->get_input(); |
|
22 | - $input->set_label_sizes(); |
|
23 | - $label_size_class = $input->get_label_size_class(); |
|
24 | - $html = ''; |
|
25 | - foreach ($input->options() as $value => $display_text) { |
|
26 | - $value = $input->get_normalization_strategy()->unnormalize($value); |
|
14 | + /** |
|
15 | + * |
|
16 | + * @throws EE_Error |
|
17 | + * @return string of html to display the field |
|
18 | + */ |
|
19 | + public function display() |
|
20 | + { |
|
21 | + $input = $this->get_input(); |
|
22 | + $input->set_label_sizes(); |
|
23 | + $label_size_class = $input->get_label_size_class(); |
|
24 | + $html = ''; |
|
25 | + foreach ($input->options() as $value => $display_text) { |
|
26 | + $value = $input->get_normalization_strategy()->unnormalize($value); |
|
27 | 27 | |
28 | - $html_id = $this->get_sub_input_id($value); |
|
29 | - $html .= EEH_HTML::nl(0, 'radio'); |
|
28 | + $html_id = $this->get_sub_input_id($value); |
|
29 | + $html .= EEH_HTML::nl(0, 'radio'); |
|
30 | 30 | |
31 | - $html .= $this->_opening_tag('label'); |
|
32 | - $html .= $this->_attributes_string( |
|
33 | - array( |
|
34 | - 'for' => $html_id, |
|
35 | - 'id' => $html_id . '-lbl', |
|
36 | - 'class' => apply_filters( |
|
37 | - 'FHEE__EE_Radio_Button_Display_Strategy__display__option_label_class', |
|
38 | - 'ee-radio-label-after' . $label_size_class, |
|
39 | - $this, |
|
40 | - $input, |
|
41 | - $value |
|
42 | - ) |
|
43 | - ) |
|
44 | - ); |
|
45 | - $html .= '>'; |
|
46 | - $html .= EEH_HTML::nl(1, 'radio'); |
|
47 | - $html .= $this->_opening_tag('input'); |
|
48 | - $attributes = array( |
|
49 | - 'id' => $html_id, |
|
50 | - 'name' => $input->html_name(), |
|
51 | - 'class' => $input->html_class(), |
|
52 | - 'style' => $input->html_style(), |
|
53 | - 'type' => 'radio', |
|
54 | - 'value' => $value, |
|
55 | - 0 => $input->other_html_attributes(), |
|
56 | - 'data-question_label' => $input->html_label_id() |
|
57 | - ); |
|
58 | - if ($input->raw_value() === $value) { |
|
59 | - $attributes['checked'] = 'checked'; |
|
60 | - } |
|
61 | - $html .= $this->_attributes_string($attributes); |
|
31 | + $html .= $this->_opening_tag('label'); |
|
32 | + $html .= $this->_attributes_string( |
|
33 | + array( |
|
34 | + 'for' => $html_id, |
|
35 | + 'id' => $html_id . '-lbl', |
|
36 | + 'class' => apply_filters( |
|
37 | + 'FHEE__EE_Radio_Button_Display_Strategy__display__option_label_class', |
|
38 | + 'ee-radio-label-after' . $label_size_class, |
|
39 | + $this, |
|
40 | + $input, |
|
41 | + $value |
|
42 | + ) |
|
43 | + ) |
|
44 | + ); |
|
45 | + $html .= '>'; |
|
46 | + $html .= EEH_HTML::nl(1, 'radio'); |
|
47 | + $html .= $this->_opening_tag('input'); |
|
48 | + $attributes = array( |
|
49 | + 'id' => $html_id, |
|
50 | + 'name' => $input->html_name(), |
|
51 | + 'class' => $input->html_class(), |
|
52 | + 'style' => $input->html_style(), |
|
53 | + 'type' => 'radio', |
|
54 | + 'value' => $value, |
|
55 | + 0 => $input->other_html_attributes(), |
|
56 | + 'data-question_label' => $input->html_label_id() |
|
57 | + ); |
|
58 | + if ($input->raw_value() === $value) { |
|
59 | + $attributes['checked'] = 'checked'; |
|
60 | + } |
|
61 | + $html .= $this->_attributes_string($attributes); |
|
62 | 62 | |
63 | - $html .= '> '; |
|
64 | - $html .= $display_text; |
|
65 | - $html .= EEH_HTML::nl(-1, 'radio') . '</label>'; |
|
66 | - } |
|
67 | - $html .= EEH_HTML::div('', '', 'clear-float'); |
|
68 | - $html .= EEH_HTML::divx(); |
|
69 | - return apply_filters('FHEE__EE_Radio_Button_Display_Strategy__display', $html, $this, $this->_input); |
|
70 | - } |
|
63 | + $html .= '> '; |
|
64 | + $html .= $display_text; |
|
65 | + $html .= EEH_HTML::nl(-1, 'radio') . '</label>'; |
|
66 | + } |
|
67 | + $html .= EEH_HTML::div('', '', 'clear-float'); |
|
68 | + $html .= EEH_HTML::divx(); |
|
69 | + return apply_filters('FHEE__EE_Radio_Button_Display_Strategy__display', $html, $this, $this->_input); |
|
70 | + } |
|
71 | 71 | } |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | $html .= $this->_attributes_string( |
33 | 33 | array( |
34 | 34 | 'for' => $html_id, |
35 | - 'id' => $html_id . '-lbl', |
|
35 | + 'id' => $html_id.'-lbl', |
|
36 | 36 | 'class' => apply_filters( |
37 | 37 | 'FHEE__EE_Radio_Button_Display_Strategy__display__option_label_class', |
38 | - 'ee-radio-label-after' . $label_size_class, |
|
38 | + 'ee-radio-label-after'.$label_size_class, |
|
39 | 39 | $this, |
40 | 40 | $input, |
41 | 41 | $value |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | $html .= '> '; |
64 | 64 | $html .= $display_text; |
65 | - $html .= EEH_HTML::nl(-1, 'radio') . '</label>'; |
|
65 | + $html .= EEH_HTML::nl(-1, 'radio').'</label>'; |
|
66 | 66 | } |
67 | 67 | $html .= EEH_HTML::div('', '', 'clear-float'); |
68 | 68 | $html .= EEH_HTML::divx(); |
@@ -16,74 +16,74 @@ |
||
16 | 16 | class EraseAttendeeData implements PersonalDataEraserInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var EEM_Attendee |
|
21 | - */ |
|
22 | - protected $attendee_model; |
|
19 | + /** |
|
20 | + * @var EEM_Attendee |
|
21 | + */ |
|
22 | + protected $attendee_model; |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * EraseAttendeeData constructor. |
|
27 | - * |
|
28 | - * @param EEM_Attendee $attendee_model |
|
29 | - */ |
|
30 | - public function __construct(EEM_Attendee $attendee_model) |
|
31 | - { |
|
32 | - $this->attendee_model = $attendee_model; |
|
33 | - } |
|
25 | + /** |
|
26 | + * EraseAttendeeData constructor. |
|
27 | + * |
|
28 | + * @param EEM_Attendee $attendee_model |
|
29 | + */ |
|
30 | + public function __construct(EEM_Attendee $attendee_model) |
|
31 | + { |
|
32 | + $this->attendee_model = $attendee_model; |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * Gets a translated string name for the data eraser |
|
38 | - * |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public function name() |
|
42 | - { |
|
43 | - return esc_html__('Event Espresso Attendee Data', 'event_espresso'); |
|
44 | - } |
|
36 | + /** |
|
37 | + * Gets a translated string name for the data eraser |
|
38 | + * |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public function name() |
|
42 | + { |
|
43 | + return esc_html__('Event Espresso Attendee Data', 'event_espresso'); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * Erases a "page" of personal user data |
|
49 | - * |
|
50 | - * @return array { |
|
51 | - * @type boolean $items_removed whether items were removed successfully or not |
|
52 | - * @type boolean $items_retained whether any items were skipped or not |
|
53 | - * @type array $messages values are messages to show |
|
54 | - * @type boolean $done whether this eraser is done or has more pages |
|
55 | - * } |
|
56 | - * @throws \EE_Error |
|
57 | - */ |
|
58 | - public function erase($email_address, $page = 1) |
|
59 | - { |
|
60 | - $rows_updated = $this->attendee_model->update( |
|
61 | - array( |
|
62 | - 'ATT_fname' => esc_html__('Anonymous', 'event_espresso'), |
|
63 | - 'ATT_lname' => '', |
|
64 | - 'ATT_email' => '', |
|
65 | - 'ATT_address' => '', |
|
66 | - 'ATT_address2' => '', |
|
67 | - 'ATT_city' => '', |
|
68 | - 'STA_ID' => 0, |
|
69 | - 'CNT_ISO' => '', |
|
70 | - 'ATT_zip' => '', |
|
71 | - 'ATT_phone' => '', |
|
72 | - ), |
|
73 | - array( |
|
74 | - array( |
|
75 | - 'ATT_email' => $email_address, |
|
76 | - ), |
|
77 | - ) |
|
78 | - ); |
|
47 | + /** |
|
48 | + * Erases a "page" of personal user data |
|
49 | + * |
|
50 | + * @return array { |
|
51 | + * @type boolean $items_removed whether items were removed successfully or not |
|
52 | + * @type boolean $items_retained whether any items were skipped or not |
|
53 | + * @type array $messages values are messages to show |
|
54 | + * @type boolean $done whether this eraser is done or has more pages |
|
55 | + * } |
|
56 | + * @throws \EE_Error |
|
57 | + */ |
|
58 | + public function erase($email_address, $page = 1) |
|
59 | + { |
|
60 | + $rows_updated = $this->attendee_model->update( |
|
61 | + array( |
|
62 | + 'ATT_fname' => esc_html__('Anonymous', 'event_espresso'), |
|
63 | + 'ATT_lname' => '', |
|
64 | + 'ATT_email' => '', |
|
65 | + 'ATT_address' => '', |
|
66 | + 'ATT_address2' => '', |
|
67 | + 'ATT_city' => '', |
|
68 | + 'STA_ID' => 0, |
|
69 | + 'CNT_ISO' => '', |
|
70 | + 'ATT_zip' => '', |
|
71 | + 'ATT_phone' => '', |
|
72 | + ), |
|
73 | + array( |
|
74 | + array( |
|
75 | + 'ATT_email' => $email_address, |
|
76 | + ), |
|
77 | + ) |
|
78 | + ); |
|
79 | 79 | |
80 | - return array( |
|
81 | - 'items_removed' => (bool) $rows_updated, |
|
82 | - 'items_retained' => false, // always false in this example |
|
83 | - 'messages' => array(), |
|
84 | - 'done' => true, |
|
85 | - ); |
|
86 | - } |
|
80 | + return array( |
|
81 | + 'items_removed' => (bool) $rows_updated, |
|
82 | + 'items_retained' => false, // always false in this example |
|
83 | + 'messages' => array(), |
|
84 | + 'done' => true, |
|
85 | + ); |
|
86 | + } |
|
87 | 87 | } |
88 | 88 | // End of file EraseAttendeeData.php |
89 | 89 | // Location: EventEspresso\core\domain\services\privacy\erasure/EraseAttendeeData.php |
@@ -17,89 +17,89 @@ |
||
17 | 17 | class EE_Restriction_Generator_Event_Related_Protected extends EE_Restriction_Generator_Base |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * Path to the event model from the model this restriction generator will be applied to; |
|
22 | - * including the event model itself. Eg "Ticket.Datetime.Event" |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - protected $_path_to_event_model = null; |
|
20 | + /** |
|
21 | + * Path to the event model from the model this restriction generator will be applied to; |
|
22 | + * including the event model itself. Eg "Ticket.Datetime.Event" |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + protected $_path_to_event_model = null; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Capability context on event model when creating restrictions. |
|
29 | - * Eg, although we may want capability restrictions relating to deleting datetimes, |
|
30 | - * they don't need to be able to DELETE EVENTS, they just need to be able to |
|
31 | - * EDIT EVENTS in order to DELETE DATETIMES. |
|
32 | - * @var string one of EEM_Base::valid_cap_contexts() |
|
33 | - */ |
|
34 | - protected $_cap_context_on_event_model = null; |
|
35 | - /** |
|
36 | - * |
|
37 | - * @param string $path_to_event_model |
|
38 | - * @param string $cap_context_on_event_model capability context on event model when creating restrictions. |
|
39 | - * Eg, although we may want capability restrictions relating to deleting datetimes, |
|
40 | - * they don't need to be able to DELETE EVENTS, they just need to be able to |
|
41 | - * EDIT EVENTS in order to DELETE DATETIMES. If none if provided, assumed to be the same |
|
42 | - * as on the primary model. |
|
43 | - */ |
|
44 | - public function __construct($path_to_event_model, $cap_context_on_event_model = null) |
|
45 | - { |
|
46 | - if (substr($path_to_event_model, -1, 1) != '.') { |
|
47 | - $path_to_event_model .= '.'; |
|
48 | - } |
|
49 | - $this->_path_to_event_model = $path_to_event_model; |
|
50 | - $this->_cap_context_on_event_model = $cap_context_on_event_model; |
|
51 | - } |
|
27 | + /** |
|
28 | + * Capability context on event model when creating restrictions. |
|
29 | + * Eg, although we may want capability restrictions relating to deleting datetimes, |
|
30 | + * they don't need to be able to DELETE EVENTS, they just need to be able to |
|
31 | + * EDIT EVENTS in order to DELETE DATETIMES. |
|
32 | + * @var string one of EEM_Base::valid_cap_contexts() |
|
33 | + */ |
|
34 | + protected $_cap_context_on_event_model = null; |
|
35 | + /** |
|
36 | + * |
|
37 | + * @param string $path_to_event_model |
|
38 | + * @param string $cap_context_on_event_model capability context on event model when creating restrictions. |
|
39 | + * Eg, although we may want capability restrictions relating to deleting datetimes, |
|
40 | + * they don't need to be able to DELETE EVENTS, they just need to be able to |
|
41 | + * EDIT EVENTS in order to DELETE DATETIMES. If none if provided, assumed to be the same |
|
42 | + * as on the primary model. |
|
43 | + */ |
|
44 | + public function __construct($path_to_event_model, $cap_context_on_event_model = null) |
|
45 | + { |
|
46 | + if (substr($path_to_event_model, -1, 1) != '.') { |
|
47 | + $path_to_event_model .= '.'; |
|
48 | + } |
|
49 | + $this->_path_to_event_model = $path_to_event_model; |
|
50 | + $this->_cap_context_on_event_model = $cap_context_on_event_model; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Returns `$this->_cap_context_on_event_model`, the relevant action ("read", |
|
55 | - * "read_admin", "edit" or "delete") for the EVENT related to this model. |
|
56 | - * @see EE_Restriction_Generator_Event_Related_Protected::__construct() |
|
57 | - * @return string one of EEM_Base::valid_cap_contexts() |
|
58 | - */ |
|
59 | - protected function action_for_event() |
|
60 | - { |
|
61 | - if ($this->_cap_context_on_event_model) { |
|
62 | - return $this->_cap_context_on_event_model; |
|
63 | - } else { |
|
64 | - return $this->action(); |
|
65 | - } |
|
66 | - } |
|
53 | + /** |
|
54 | + * Returns `$this->_cap_context_on_event_model`, the relevant action ("read", |
|
55 | + * "read_admin", "edit" or "delete") for the EVENT related to this model. |
|
56 | + * @see EE_Restriction_Generator_Event_Related_Protected::__construct() |
|
57 | + * @return string one of EEM_Base::valid_cap_contexts() |
|
58 | + */ |
|
59 | + protected function action_for_event() |
|
60 | + { |
|
61 | + if ($this->_cap_context_on_event_model) { |
|
62 | + return $this->_cap_context_on_event_model; |
|
63 | + } else { |
|
64 | + return $this->action(); |
|
65 | + } |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * |
|
70 | - * @return \EE_Default_Where_Conditions |
|
71 | - */ |
|
72 | - protected function _generate_restrictions() |
|
73 | - { |
|
74 | - // if there are no standard caps for this model, then for now all we know |
|
75 | - // if they need the default cap to access this |
|
76 | - if (! $this->model()->cap_slug()) { |
|
77 | - return array( |
|
78 | - self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
|
79 | - ); |
|
80 | - } |
|
68 | + /** |
|
69 | + * |
|
70 | + * @return \EE_Default_Where_Conditions |
|
71 | + */ |
|
72 | + protected function _generate_restrictions() |
|
73 | + { |
|
74 | + // if there are no standard caps for this model, then for now all we know |
|
75 | + // if they need the default cap to access this |
|
76 | + if (! $this->model()->cap_slug()) { |
|
77 | + return array( |
|
78 | + self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
|
79 | + ); |
|
80 | + } |
|
81 | 81 | |
82 | - $event_model = EEM_Event::instance(); |
|
83 | - return array( |
|
84 | - // first: basically access to non-defaults is essentially controlled by which events are accessible |
|
85 | - // if they don't have the basic event cap, they can't access ANY non-default items |
|
86 | - EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action_for_event()) => new EE_Return_None_Where_Conditions(), |
|
87 | - // if they don't have the others event cap, they can't access others' non-default items |
|
88 | - EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action_for_event() . '_others') => new EE_Default_Where_Conditions( |
|
89 | - array( $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder ) |
|
90 | - ), |
|
91 | - // if they have basic and others, but not private, they can't access others' private non-default items |
|
92 | - EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action_for_event() . '_private') => new EE_Default_Where_Conditions( |
|
93 | - array( |
|
94 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action_for_event() . '_private') => $this->addPublishedPostConditions( |
|
95 | - array( |
|
96 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
97 | - ), |
|
98 | - false, |
|
99 | - $this->_path_to_event_model |
|
100 | - ) |
|
101 | - ) |
|
102 | - ), |
|
103 | - ); |
|
104 | - } |
|
82 | + $event_model = EEM_Event::instance(); |
|
83 | + return array( |
|
84 | + // first: basically access to non-defaults is essentially controlled by which events are accessible |
|
85 | + // if they don't have the basic event cap, they can't access ANY non-default items |
|
86 | + EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action_for_event()) => new EE_Return_None_Where_Conditions(), |
|
87 | + // if they don't have the others event cap, they can't access others' non-default items |
|
88 | + EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action_for_event() . '_others') => new EE_Default_Where_Conditions( |
|
89 | + array( $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder ) |
|
90 | + ), |
|
91 | + // if they have basic and others, but not private, they can't access others' private non-default items |
|
92 | + EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action_for_event() . '_private') => new EE_Default_Where_Conditions( |
|
93 | + array( |
|
94 | + 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action_for_event() . '_private') => $this->addPublishedPostConditions( |
|
95 | + array( |
|
96 | + $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
97 | + ), |
|
98 | + false, |
|
99 | + $this->_path_to_event_model |
|
100 | + ) |
|
101 | + ) |
|
102 | + ), |
|
103 | + ); |
|
104 | + } |
|
105 | 105 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | { |
74 | 74 | // if there are no standard caps for this model, then for now all we know |
75 | 75 | // if they need the default cap to access this |
76 | - if (! $this->model()->cap_slug()) { |
|
76 | + if ( ! $this->model()->cap_slug()) { |
|
77 | 77 | return array( |
78 | 78 | self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
79 | 79 | ); |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | // if they don't have the basic event cap, they can't access ANY non-default items |
86 | 86 | EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action_for_event()) => new EE_Return_None_Where_Conditions(), |
87 | 87 | // if they don't have the others event cap, they can't access others' non-default items |
88 | - EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action_for_event() . '_others') => new EE_Default_Where_Conditions( |
|
89 | - array( $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder ) |
|
88 | + EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action_for_event().'_others') => new EE_Default_Where_Conditions( |
|
89 | + array($this->_path_to_event_model.'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder) |
|
90 | 90 | ), |
91 | 91 | // if they have basic and others, but not private, they can't access others' private non-default items |
92 | - EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action_for_event() . '_private') => new EE_Default_Where_Conditions( |
|
92 | + EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action_for_event().'_private') => new EE_Default_Where_Conditions( |
|
93 | 93 | array( |
94 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action_for_event() . '_private') => $this->addPublishedPostConditions( |
|
94 | + 'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action_for_event().'_private') => $this->addPublishedPostConditions( |
|
95 | 95 | array( |
96 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
96 | + $this->_path_to_event_model.'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
97 | 97 | ), |
98 | 98 | false, |
99 | 99 | $this->_path_to_event_model |
@@ -17,72 +17,72 @@ |
||
17 | 17 | class EE_Restriction_Generator_Event_Related_Public extends EE_Restriction_Generator_Base |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * Path to the event model from the model this restriction generator will be applied to; |
|
22 | - * including the event model itself. Eg "Ticket.Datetime.Event" |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - protected $_path_to_event_model; |
|
26 | - /** |
|
27 | - * |
|
28 | - * @param string $path_to_event_model |
|
29 | - */ |
|
30 | - public function __construct($path_to_event_model) |
|
31 | - { |
|
32 | - if (substr($path_to_event_model, -1, 1) != '.') { |
|
33 | - $path_to_event_model .= '.'; |
|
34 | - } |
|
35 | - $this->_path_to_event_model = $path_to_event_model; |
|
36 | - } |
|
37 | - /** |
|
38 | - * |
|
39 | - * @return \EE_Default_Where_Conditions |
|
40 | - */ |
|
41 | - protected function _generate_restrictions() |
|
42 | - { |
|
43 | - // if there are no standard caps for this model, then for now all we know |
|
44 | - // if they need the default cap to access this |
|
45 | - if (! $this->model()->cap_slug()) { |
|
46 | - return array( |
|
47 | - self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
|
48 | - ); |
|
49 | - } |
|
20 | + /** |
|
21 | + * Path to the event model from the model this restriction generator will be applied to; |
|
22 | + * including the event model itself. Eg "Ticket.Datetime.Event" |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + protected $_path_to_event_model; |
|
26 | + /** |
|
27 | + * |
|
28 | + * @param string $path_to_event_model |
|
29 | + */ |
|
30 | + public function __construct($path_to_event_model) |
|
31 | + { |
|
32 | + if (substr($path_to_event_model, -1, 1) != '.') { |
|
33 | + $path_to_event_model .= '.'; |
|
34 | + } |
|
35 | + $this->_path_to_event_model = $path_to_event_model; |
|
36 | + } |
|
37 | + /** |
|
38 | + * |
|
39 | + * @return \EE_Default_Where_Conditions |
|
40 | + */ |
|
41 | + protected function _generate_restrictions() |
|
42 | + { |
|
43 | + // if there are no standard caps for this model, then for now all we know |
|
44 | + // if they need the default cap to access this |
|
45 | + if (! $this->model()->cap_slug()) { |
|
46 | + return array( |
|
47 | + self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
|
48 | + ); |
|
49 | + } |
|
50 | 50 | |
51 | - $event_model = EEM_Event::instance(); |
|
52 | - return array( |
|
53 | - // first: basically access to non-defaults is essentially controlled by which events are accessible |
|
54 | - // if they don't have the basic event cap, they can only read things for published events |
|
55 | - EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions( |
|
56 | - $this->addPublishedPostConditions( |
|
57 | - array(), |
|
58 | - true, |
|
59 | - $this->_path_to_event_model |
|
60 | - ) |
|
61 | - ), |
|
62 | - // if they don't have the others event cap, they can't access others' non-default items |
|
63 | - EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => new EE_Default_Where_Conditions( |
|
64 | - array( |
|
65 | - 'OR*' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => $this->addPublishedPostConditions( |
|
66 | - array( |
|
67 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
68 | - ), |
|
69 | - true, |
|
70 | - $this->_path_to_event_model |
|
71 | - ) |
|
72 | - ) |
|
73 | - ), |
|
74 | - // if they have basic and others, but not private, they can't access others' private non-default items |
|
75 | - EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions( |
|
76 | - array( |
|
77 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => $this->addPublishedPostConditions( |
|
78 | - array( |
|
79 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
80 | - ), |
|
81 | - false, |
|
82 | - $this->_path_to_event_model |
|
83 | - ) |
|
84 | - ) |
|
85 | - ), |
|
86 | - ); |
|
87 | - } |
|
51 | + $event_model = EEM_Event::instance(); |
|
52 | + return array( |
|
53 | + // first: basically access to non-defaults is essentially controlled by which events are accessible |
|
54 | + // if they don't have the basic event cap, they can only read things for published events |
|
55 | + EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions( |
|
56 | + $this->addPublishedPostConditions( |
|
57 | + array(), |
|
58 | + true, |
|
59 | + $this->_path_to_event_model |
|
60 | + ) |
|
61 | + ), |
|
62 | + // if they don't have the others event cap, they can't access others' non-default items |
|
63 | + EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => new EE_Default_Where_Conditions( |
|
64 | + array( |
|
65 | + 'OR*' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => $this->addPublishedPostConditions( |
|
66 | + array( |
|
67 | + $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
68 | + ), |
|
69 | + true, |
|
70 | + $this->_path_to_event_model |
|
71 | + ) |
|
72 | + ) |
|
73 | + ), |
|
74 | + // if they have basic and others, but not private, they can't access others' private non-default items |
|
75 | + EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions( |
|
76 | + array( |
|
77 | + 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => $this->addPublishedPostConditions( |
|
78 | + array( |
|
79 | + $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
80 | + ), |
|
81 | + false, |
|
82 | + $this->_path_to_event_model |
|
83 | + ) |
|
84 | + ) |
|
85 | + ), |
|
86 | + ); |
|
87 | + } |
|
88 | 88 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | { |
43 | 43 | // if there are no standard caps for this model, then for now all we know |
44 | 44 | // if they need the default cap to access this |
45 | - if (! $this->model()->cap_slug()) { |
|
45 | + if ( ! $this->model()->cap_slug()) { |
|
46 | 46 | return array( |
47 | 47 | self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
48 | 48 | ); |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | ) |
61 | 61 | ), |
62 | 62 | // if they don't have the others event cap, they can't access others' non-default items |
63 | - EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => new EE_Default_Where_Conditions( |
|
63 | + EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action().'_others') => new EE_Default_Where_Conditions( |
|
64 | 64 | array( |
65 | - 'OR*' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => $this->addPublishedPostConditions( |
|
65 | + 'OR*'.EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action().'_others') => $this->addPublishedPostConditions( |
|
66 | 66 | array( |
67 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
67 | + $this->_path_to_event_model.'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
68 | 68 | ), |
69 | 69 | true, |
70 | 70 | $this->_path_to_event_model |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | ) |
73 | 73 | ), |
74 | 74 | // if they have basic and others, but not private, they can't access others' private non-default items |
75 | - EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions( |
|
75 | + EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action().'_private') => new EE_Default_Where_Conditions( |
|
76 | 76 | array( |
77 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => $this->addPublishedPostConditions( |
|
77 | + 'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action().'_private') => $this->addPublishedPostConditions( |
|
78 | 78 | array( |
79 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
79 | + $this->_path_to_event_model.'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
80 | 80 | ), |
81 | 81 | false, |
82 | 82 | $this->_path_to_event_model |
@@ -12,74 +12,74 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_Restriction_Generator_Public extends EE_Restriction_Generator_Base |
14 | 14 | { |
15 | - protected function _generate_restrictions() |
|
16 | - { |
|
17 | - // if there are no standard caps for this model, then for allow full access |
|
18 | - if (! $this->model()->cap_slug()) { |
|
19 | - return array( |
|
20 | - ); |
|
21 | - } |
|
15 | + protected function _generate_restrictions() |
|
16 | + { |
|
17 | + // if there are no standard caps for this model, then for allow full access |
|
18 | + if (! $this->model()->cap_slug()) { |
|
19 | + return array( |
|
20 | + ); |
|
21 | + } |
|
22 | 22 | |
23 | - $restrictions = array(); |
|
24 | - // does the basic cap exist? (eg 'ee_read_registrations') |
|
25 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action())) { |
|
26 | - if ($this->model() instanceof EEM_CPT_Base) { |
|
27 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) ] = new EE_Default_Where_Conditions( |
|
28 | - $this->addPublishedPostConditions() |
|
29 | - ); |
|
30 | - } elseif ($this->model() instanceof EEM_Soft_Delete_Base) { |
|
31 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) ] = new EE_Default_Where_Conditions( |
|
32 | - array( $this->model()->deleted_field_name() => false ) |
|
33 | - ); |
|
34 | - } else { |
|
35 | - // don't impose any restrictions if they don't have the basic reading cap |
|
36 | - } |
|
37 | - // does the others cap exist? (eg 'ee_read_others_registrations') |
|
38 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others')) {// both caps exist |
|
39 | - if ($this->model() instanceof EEM_CPT_Base) { |
|
40 | - // then if they don't have the others cap, AT MOST show them their own and other published ones |
|
41 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') ] = new EE_Default_Where_Conditions( |
|
42 | - array( |
|
43 | - 'OR*' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => $this->addPublishedPostConditions( |
|
44 | - array( |
|
45 | - EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
|
46 | - ) |
|
47 | - ) |
|
48 | - ) |
|
49 | - ); |
|
50 | - } elseif ($this->model() instanceof EEM_Soft_Delete_Base) { |
|
51 | - // then if they don't have the other cap, AT MOST show them their own or non deleted ones |
|
52 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') ] = new EE_Default_Where_Conditions( |
|
53 | - array( |
|
54 | - 'OR*' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => array( |
|
55 | - EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
|
56 | - $this->model()->deleted_field_name() => false |
|
57 | - ) |
|
58 | - ) |
|
59 | - ); |
|
60 | - } else { |
|
61 | - // again, if they don't have the others cap, continue showing all because there are no inherently hidden ones |
|
62 | - } |
|
63 | - // does the private cap exist (eg 'ee_read_others_private_events') |
|
64 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_private') && $this->model() instanceof EEM_CPT_Base) { |
|
65 | - // if they have basic and others, but not private, restrict them to see theirs and others' that aren't private |
|
66 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') ] = new EE_Default_Where_Conditions( |
|
67 | - array( |
|
68 | - 'OR*' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') => $this->addPublishedPostConditions( |
|
69 | - array( |
|
70 | - EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
|
71 | - ), |
|
72 | - false, |
|
73 | - '' |
|
74 | - ) |
|
75 | - ) |
|
76 | - ); |
|
77 | - } |
|
78 | - } |
|
79 | - } else { |
|
80 | - // there is no basic cap. So allow full access |
|
81 | - $restrictions = array(); |
|
82 | - } |
|
83 | - return $restrictions; |
|
84 | - } |
|
23 | + $restrictions = array(); |
|
24 | + // does the basic cap exist? (eg 'ee_read_registrations') |
|
25 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action())) { |
|
26 | + if ($this->model() instanceof EEM_CPT_Base) { |
|
27 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) ] = new EE_Default_Where_Conditions( |
|
28 | + $this->addPublishedPostConditions() |
|
29 | + ); |
|
30 | + } elseif ($this->model() instanceof EEM_Soft_Delete_Base) { |
|
31 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) ] = new EE_Default_Where_Conditions( |
|
32 | + array( $this->model()->deleted_field_name() => false ) |
|
33 | + ); |
|
34 | + } else { |
|
35 | + // don't impose any restrictions if they don't have the basic reading cap |
|
36 | + } |
|
37 | + // does the others cap exist? (eg 'ee_read_others_registrations') |
|
38 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others')) {// both caps exist |
|
39 | + if ($this->model() instanceof EEM_CPT_Base) { |
|
40 | + // then if they don't have the others cap, AT MOST show them their own and other published ones |
|
41 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') ] = new EE_Default_Where_Conditions( |
|
42 | + array( |
|
43 | + 'OR*' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => $this->addPublishedPostConditions( |
|
44 | + array( |
|
45 | + EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
|
46 | + ) |
|
47 | + ) |
|
48 | + ) |
|
49 | + ); |
|
50 | + } elseif ($this->model() instanceof EEM_Soft_Delete_Base) { |
|
51 | + // then if they don't have the other cap, AT MOST show them their own or non deleted ones |
|
52 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') ] = new EE_Default_Where_Conditions( |
|
53 | + array( |
|
54 | + 'OR*' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => array( |
|
55 | + EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
|
56 | + $this->model()->deleted_field_name() => false |
|
57 | + ) |
|
58 | + ) |
|
59 | + ); |
|
60 | + } else { |
|
61 | + // again, if they don't have the others cap, continue showing all because there are no inherently hidden ones |
|
62 | + } |
|
63 | + // does the private cap exist (eg 'ee_read_others_private_events') |
|
64 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_private') && $this->model() instanceof EEM_CPT_Base) { |
|
65 | + // if they have basic and others, but not private, restrict them to see theirs and others' that aren't private |
|
66 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') ] = new EE_Default_Where_Conditions( |
|
67 | + array( |
|
68 | + 'OR*' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') => $this->addPublishedPostConditions( |
|
69 | + array( |
|
70 | + EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
|
71 | + ), |
|
72 | + false, |
|
73 | + '' |
|
74 | + ) |
|
75 | + ) |
|
76 | + ); |
|
77 | + } |
|
78 | + } |
|
79 | + } else { |
|
80 | + // there is no basic cap. So allow full access |
|
81 | + $restrictions = array(); |
|
82 | + } |
|
83 | + return $restrictions; |
|
84 | + } |
|
85 | 85 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | protected function _generate_restrictions() |
16 | 16 | { |
17 | 17 | // if there are no standard caps for this model, then for allow full access |
18 | - if (! $this->model()->cap_slug()) { |
|
18 | + if ( ! $this->model()->cap_slug()) { |
|
19 | 19 | return array( |
20 | 20 | ); |
21 | 21 | } |
@@ -24,23 +24,23 @@ discard block |
||
24 | 24 | // does the basic cap exist? (eg 'ee_read_registrations') |
25 | 25 | if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action())) { |
26 | 26 | if ($this->model() instanceof EEM_CPT_Base) { |
27 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) ] = new EE_Default_Where_Conditions( |
|
27 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action())] = new EE_Default_Where_Conditions( |
|
28 | 28 | $this->addPublishedPostConditions() |
29 | 29 | ); |
30 | 30 | } elseif ($this->model() instanceof EEM_Soft_Delete_Base) { |
31 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) ] = new EE_Default_Where_Conditions( |
|
32 | - array( $this->model()->deleted_field_name() => false ) |
|
31 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action())] = new EE_Default_Where_Conditions( |
|
32 | + array($this->model()->deleted_field_name() => false) |
|
33 | 33 | ); |
34 | 34 | } else { |
35 | 35 | // don't impose any restrictions if they don't have the basic reading cap |
36 | 36 | } |
37 | 37 | // does the others cap exist? (eg 'ee_read_others_registrations') |
38 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others')) {// both caps exist |
|
38 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action().'_others')) {// both caps exist |
|
39 | 39 | if ($this->model() instanceof EEM_CPT_Base) { |
40 | 40 | // then if they don't have the others cap, AT MOST show them their own and other published ones |
41 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') ] = new EE_Default_Where_Conditions( |
|
41 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_others')] = new EE_Default_Where_Conditions( |
|
42 | 42 | array( |
43 | - 'OR*' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => $this->addPublishedPostConditions( |
|
43 | + 'OR*'.EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_others') => $this->addPublishedPostConditions( |
|
44 | 44 | array( |
45 | 45 | EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
46 | 46 | ) |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | ); |
50 | 50 | } elseif ($this->model() instanceof EEM_Soft_Delete_Base) { |
51 | 51 | // then if they don't have the other cap, AT MOST show them their own or non deleted ones |
52 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') ] = new EE_Default_Where_Conditions( |
|
52 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_others')] = new EE_Default_Where_Conditions( |
|
53 | 53 | array( |
54 | - 'OR*' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => array( |
|
54 | + 'OR*'.EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_others') => array( |
|
55 | 55 | EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
56 | 56 | $this->model()->deleted_field_name() => false |
57 | 57 | ) |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | // again, if they don't have the others cap, continue showing all because there are no inherently hidden ones |
62 | 62 | } |
63 | 63 | // does the private cap exist (eg 'ee_read_others_private_events') |
64 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_private') && $this->model() instanceof EEM_CPT_Base) { |
|
64 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action().'_private') && $this->model() instanceof EEM_CPT_Base) { |
|
65 | 65 | // if they have basic and others, but not private, restrict them to see theirs and others' that aren't private |
66 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') ] = new EE_Default_Where_Conditions( |
|
66 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_private')] = new EE_Default_Where_Conditions( |
|
67 | 67 | array( |
68 | - 'OR*' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') => $this->addPublishedPostConditions( |
|
68 | + 'OR*'.EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_private') => $this->addPublishedPostConditions( |
|
69 | 69 | array( |
70 | 70 | EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
71 | 71 | ), |
@@ -18,110 +18,110 @@ |
||
18 | 18 | class EE_Restriction_Generator_Default_Public extends EE_Restriction_Generator_Base |
19 | 19 | { |
20 | 20 | /** |
21 | - * Name of the field on this model (or a related model, including the model chain to it) |
|
22 | - * that is a boolean indicating whether or not a model object is considered "Default" or not |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - protected $_default_field_name; |
|
21 | + * Name of the field on this model (or a related model, including the model chain to it) |
|
22 | + * that is a boolean indicating whether or not a model object is considered "Default" or not |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + protected $_default_field_name; |
|
26 | 26 | |
27 | - /** |
|
28 | - * The model chain to follow to get to the event model, including the event model itself. |
|
29 | - * Eg 'Ticket.Datetime.Event' |
|
30 | - * @var string |
|
31 | - */ |
|
32 | - protected $_path_to_event_model; |
|
33 | - /** |
|
34 | - * |
|
35 | - * @param string $default_field_name the name of the field Name of the field on this model (or a related model, including the model chain to it) |
|
36 | - * that is a boolean indicating whether or not a model object is considered "Default" or not |
|
37 | - * @param string $path_to_event_model The model chain to follow to get to the event model, including the event model itself. |
|
38 | - * Eg 'Ticket.Datetime.Event' |
|
39 | - */ |
|
40 | - public function __construct($default_field_name, $path_to_event_model) |
|
41 | - { |
|
42 | - $this->_default_field_name = $default_field_name; |
|
43 | - if (substr($path_to_event_model, -1, 1) != '.') { |
|
44 | - $path_to_event_model .= '.'; |
|
45 | - } |
|
46 | - $this->_path_to_event_model = $path_to_event_model; |
|
47 | - } |
|
27 | + /** |
|
28 | + * The model chain to follow to get to the event model, including the event model itself. |
|
29 | + * Eg 'Ticket.Datetime.Event' |
|
30 | + * @var string |
|
31 | + */ |
|
32 | + protected $_path_to_event_model; |
|
33 | + /** |
|
34 | + * |
|
35 | + * @param string $default_field_name the name of the field Name of the field on this model (or a related model, including the model chain to it) |
|
36 | + * that is a boolean indicating whether or not a model object is considered "Default" or not |
|
37 | + * @param string $path_to_event_model The model chain to follow to get to the event model, including the event model itself. |
|
38 | + * Eg 'Ticket.Datetime.Event' |
|
39 | + */ |
|
40 | + public function __construct($default_field_name, $path_to_event_model) |
|
41 | + { |
|
42 | + $this->_default_field_name = $default_field_name; |
|
43 | + if (substr($path_to_event_model, -1, 1) != '.') { |
|
44 | + $path_to_event_model .= '.'; |
|
45 | + } |
|
46 | + $this->_path_to_event_model = $path_to_event_model; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return EE_Default_Where_Conditions |
|
51 | - * @throws EE_Error |
|
52 | - */ |
|
53 | - protected function _generate_restrictions() |
|
54 | - { |
|
55 | - // if there are no standard caps for this model, then for now all we know |
|
56 | - // if they need the default cap to access this |
|
57 | - if (!$this->model()->cap_slug()) { |
|
58 | - return array( |
|
59 | - self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
|
60 | - ); |
|
61 | - } |
|
49 | + /** |
|
50 | + * @return EE_Default_Where_Conditions |
|
51 | + * @throws EE_Error |
|
52 | + */ |
|
53 | + protected function _generate_restrictions() |
|
54 | + { |
|
55 | + // if there are no standard caps for this model, then for now all we know |
|
56 | + // if they need the default cap to access this |
|
57 | + if (!$this->model()->cap_slug()) { |
|
58 | + return array( |
|
59 | + self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | |
63 | - $event_model = EEM_Event::instance(); |
|
63 | + $event_model = EEM_Event::instance(); |
|
64 | 64 | |
65 | - $restrictions = array( |
|
66 | - // first: basically access to non-defaults is essentially controlled by which events are accessible |
|
67 | - // if they don't have the basic event cap, they can't access ANY non-default items |
|
68 | - EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions(array( |
|
69 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => $this->addPublishedPostConditions( |
|
70 | - array( |
|
71 | - $this->_default_field_name => true, |
|
72 | - ), |
|
73 | - true, |
|
74 | - $this->_path_to_event_model |
|
75 | - ) |
|
76 | - )), |
|
77 | - // if they don't have the others event cap, they can only access their own, others' that are for published events, or defaults |
|
78 | - EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => new EE_Default_Where_Conditions( |
|
79 | - array( |
|
80 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => $this->addPublishedPostConditions( |
|
81 | - array( |
|
82 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
83 | - $this->_default_field_name => true, |
|
84 | - ), |
|
85 | - true, |
|
86 | - $this->_path_to_event_model |
|
87 | - ) |
|
88 | - ) |
|
89 | - ), |
|
90 | - // if they have basic and others, but not private, they can access default, their own, and others' that aren't private |
|
91 | - EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions( |
|
92 | - array( |
|
93 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => $this->addPublishedPostConditions( |
|
94 | - array( |
|
95 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
96 | - $this->_default_field_name => true |
|
97 | - ), |
|
98 | - false, |
|
99 | - $this->_path_to_event_model |
|
100 | - ) |
|
101 | - ) |
|
102 | - ), |
|
103 | - // second: access to defaults is controlled by the default capabilities |
|
104 | - // if they don't have the basic default capability, restrict access to only non-default items |
|
105 | - EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_default') => new EE_Default_Where_Conditions( |
|
106 | - array( $this->_default_field_name => false ) |
|
107 | - ), |
|
108 | - ); |
|
109 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others_default')) { |
|
110 | - // if they don't have the "others" default capability, restrict access to only their default ones, and non-default ones |
|
111 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') ] = new EE_Default_Where_Conditions( |
|
112 | - array( |
|
113 | - // if they don't have the others default cap, they can't access others default items (but they can access |
|
114 | - // their own default items, and non-default items) |
|
115 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') => array( |
|
116 | - 'AND' => array( |
|
117 | - EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
|
118 | - $this->_default_field_name => true |
|
119 | - ), |
|
120 | - $this->_default_field_name => false |
|
121 | - ) |
|
122 | - ) |
|
123 | - ); |
|
124 | - } |
|
125 | - return $restrictions; |
|
126 | - } |
|
65 | + $restrictions = array( |
|
66 | + // first: basically access to non-defaults is essentially controlled by which events are accessible |
|
67 | + // if they don't have the basic event cap, they can't access ANY non-default items |
|
68 | + EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions(array( |
|
69 | + 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => $this->addPublishedPostConditions( |
|
70 | + array( |
|
71 | + $this->_default_field_name => true, |
|
72 | + ), |
|
73 | + true, |
|
74 | + $this->_path_to_event_model |
|
75 | + ) |
|
76 | + )), |
|
77 | + // if they don't have the others event cap, they can only access their own, others' that are for published events, or defaults |
|
78 | + EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => new EE_Default_Where_Conditions( |
|
79 | + array( |
|
80 | + 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => $this->addPublishedPostConditions( |
|
81 | + array( |
|
82 | + $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
83 | + $this->_default_field_name => true, |
|
84 | + ), |
|
85 | + true, |
|
86 | + $this->_path_to_event_model |
|
87 | + ) |
|
88 | + ) |
|
89 | + ), |
|
90 | + // if they have basic and others, but not private, they can access default, their own, and others' that aren't private |
|
91 | + EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions( |
|
92 | + array( |
|
93 | + 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => $this->addPublishedPostConditions( |
|
94 | + array( |
|
95 | + $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
96 | + $this->_default_field_name => true |
|
97 | + ), |
|
98 | + false, |
|
99 | + $this->_path_to_event_model |
|
100 | + ) |
|
101 | + ) |
|
102 | + ), |
|
103 | + // second: access to defaults is controlled by the default capabilities |
|
104 | + // if they don't have the basic default capability, restrict access to only non-default items |
|
105 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_default') => new EE_Default_Where_Conditions( |
|
106 | + array( $this->_default_field_name => false ) |
|
107 | + ), |
|
108 | + ); |
|
109 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others_default')) { |
|
110 | + // if they don't have the "others" default capability, restrict access to only their default ones, and non-default ones |
|
111 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') ] = new EE_Default_Where_Conditions( |
|
112 | + array( |
|
113 | + // if they don't have the others default cap, they can't access others default items (but they can access |
|
114 | + // their own default items, and non-default items) |
|
115 | + 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') => array( |
|
116 | + 'AND' => array( |
|
117 | + EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
|
118 | + $this->_default_field_name => true |
|
119 | + ), |
|
120 | + $this->_default_field_name => false |
|
121 | + ) |
|
122 | + ) |
|
123 | + ); |
|
124 | + } |
|
125 | + return $restrictions; |
|
126 | + } |
|
127 | 127 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | { |
55 | 55 | // if there are no standard caps for this model, then for now all we know |
56 | 56 | // if they need the default cap to access this |
57 | - if (!$this->model()->cap_slug()) { |
|
57 | + if ( ! $this->model()->cap_slug()) { |
|
58 | 58 | return array( |
59 | 59 | self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
60 | 60 | ); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | // first: basically access to non-defaults is essentially controlled by which events are accessible |
67 | 67 | // if they don't have the basic event cap, they can't access ANY non-default items |
68 | 68 | EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions(array( |
69 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => $this->addPublishedPostConditions( |
|
69 | + 'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => $this->addPublishedPostConditions( |
|
70 | 70 | array( |
71 | 71 | $this->_default_field_name => true, |
72 | 72 | ), |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | ) |
76 | 76 | )), |
77 | 77 | // if they don't have the others event cap, they can only access their own, others' that are for published events, or defaults |
78 | - EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => new EE_Default_Where_Conditions( |
|
78 | + EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action().'_others') => new EE_Default_Where_Conditions( |
|
79 | 79 | array( |
80 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => $this->addPublishedPostConditions( |
|
80 | + 'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action().'_others') => $this->addPublishedPostConditions( |
|
81 | 81 | array( |
82 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
82 | + $this->_path_to_event_model.'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
83 | 83 | $this->_default_field_name => true, |
84 | 84 | ), |
85 | 85 | true, |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | ) |
89 | 89 | ), |
90 | 90 | // if they have basic and others, but not private, they can access default, their own, and others' that aren't private |
91 | - EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions( |
|
91 | + EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action().'_private') => new EE_Default_Where_Conditions( |
|
92 | 92 | array( |
93 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => $this->addPublishedPostConditions( |
|
93 | + 'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action().'_private') => $this->addPublishedPostConditions( |
|
94 | 94 | array( |
95 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
95 | + $this->_path_to_event_model.'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder, |
|
96 | 96 | $this->_default_field_name => true |
97 | 97 | ), |
98 | 98 | false, |
@@ -102,17 +102,17 @@ discard block |
||
102 | 102 | ), |
103 | 103 | // second: access to defaults is controlled by the default capabilities |
104 | 104 | // if they don't have the basic default capability, restrict access to only non-default items |
105 | - EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_default') => new EE_Default_Where_Conditions( |
|
106 | - array( $this->_default_field_name => false ) |
|
105 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_default') => new EE_Default_Where_Conditions( |
|
106 | + array($this->_default_field_name => false) |
|
107 | 107 | ), |
108 | 108 | ); |
109 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others_default')) { |
|
109 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action().'_others_default')) { |
|
110 | 110 | // if they don't have the "others" default capability, restrict access to only their default ones, and non-default ones |
111 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') ] = new EE_Default_Where_Conditions( |
|
111 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_others_default')] = new EE_Default_Where_Conditions( |
|
112 | 112 | array( |
113 | 113 | // if they don't have the others default cap, they can't access others default items (but they can access |
114 | 114 | // their own default items, and non-default items) |
115 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') => array( |
|
115 | + 'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_others_default') => array( |
|
116 | 116 | 'AND' => array( |
117 | 117 | EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
118 | 118 | $this->_default_field_name => true |
@@ -22,70 +22,70 @@ |
||
22 | 22 | interface BlockInterface |
23 | 23 | { |
24 | 24 | |
25 | - const NAME_SPACE = 'eventespresso'; |
|
26 | - |
|
27 | - /** |
|
28 | - * Perform any early setup required by the block |
|
29 | - * including setting the block type and supported post types |
|
30 | - * |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public function initialize(); |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public function blockType(); |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * AssetRegister that this editor block uses for asset registration |
|
44 | - * |
|
45 | - * @return BlockAssetManagerInterface |
|
46 | - */ |
|
47 | - public function assetManager(); |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * Registers the Editor Block with WP core; |
|
52 | - * Returns the registered block type on success, or false on failure. |
|
53 | - * |
|
54 | - * @return WP_Block_Type|false |
|
55 | - */ |
|
56 | - public function registerBlock(); |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * Un-registers the Editor Block with WP core; |
|
61 | - * Returns the registered block type on success, or false on failure. |
|
62 | - * |
|
63 | - * @return WP_Block_Type|false |
|
64 | - */ |
|
65 | - public function unRegisterBlock(); |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * returns an array of fully qualified class names |
|
70 | - * for RouteMatchSpecificationInterface objects |
|
71 | - * that specify routes that the block should be loaded for. |
|
72 | - * |
|
73 | - * @return array |
|
74 | - */ |
|
75 | - public function supportedRoutes(); |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @return array |
|
80 | - */ |
|
81 | - public function getEditorContainer(); |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * returns the rendered HTML for the block |
|
86 | - * |
|
87 | - * @param array $attributes |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function renderBlock(array $attributes = array()); |
|
25 | + const NAME_SPACE = 'eventespresso'; |
|
26 | + |
|
27 | + /** |
|
28 | + * Perform any early setup required by the block |
|
29 | + * including setting the block type and supported post types |
|
30 | + * |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public function initialize(); |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public function blockType(); |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * AssetRegister that this editor block uses for asset registration |
|
44 | + * |
|
45 | + * @return BlockAssetManagerInterface |
|
46 | + */ |
|
47 | + public function assetManager(); |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * Registers the Editor Block with WP core; |
|
52 | + * Returns the registered block type on success, or false on failure. |
|
53 | + * |
|
54 | + * @return WP_Block_Type|false |
|
55 | + */ |
|
56 | + public function registerBlock(); |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * Un-registers the Editor Block with WP core; |
|
61 | + * Returns the registered block type on success, or false on failure. |
|
62 | + * |
|
63 | + * @return WP_Block_Type|false |
|
64 | + */ |
|
65 | + public function unRegisterBlock(); |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * returns an array of fully qualified class names |
|
70 | + * for RouteMatchSpecificationInterface objects |
|
71 | + * that specify routes that the block should be loaded for. |
|
72 | + * |
|
73 | + * @return array |
|
74 | + */ |
|
75 | + public function supportedRoutes(); |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @return array |
|
80 | + */ |
|
81 | + public function getEditorContainer(); |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * returns the rendered HTML for the block |
|
86 | + * |
|
87 | + * @param array $attributes |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function renderBlock(array $attributes = array()); |
|
91 | 91 | } |
@@ -24,17 +24,17 @@ |
||
24 | 24 | abstract class RouteMatchSpecification implements RouteMatchSpecificationInterface |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @var RequestInterface $request |
|
29 | - */ |
|
30 | - protected $request; |
|
27 | + /** |
|
28 | + * @var RequestInterface $request |
|
29 | + */ |
|
30 | + protected $request; |
|
31 | 31 | |
32 | - /** |
|
33 | - * RouteMatch constructor. |
|
34 | - * @param RequestInterface $request |
|
35 | - */ |
|
36 | - public function __construct(RequestInterface $request) |
|
37 | - { |
|
38 | - $this->request = $request; |
|
39 | - } |
|
32 | + /** |
|
33 | + * RouteMatch constructor. |
|
34 | + * @param RequestInterface $request |
|
35 | + */ |
|
36 | + public function __construct(RequestInterface $request) |
|
37 | + { |
|
38 | + $this->request = $request; |
|
39 | + } |
|
40 | 40 | } |
@@ -13,18 +13,18 @@ |
||
13 | 13 | abstract class RouteMatchSpecificationDecorator implements RouteMatchSpecificationInterface |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @var RouteMatchSpecificationInterface $specification |
|
18 | - */ |
|
19 | - protected $specification; |
|
16 | + /** |
|
17 | + * @var RouteMatchSpecificationInterface $specification |
|
18 | + */ |
|
19 | + protected $specification; |
|
20 | 20 | |
21 | - /** |
|
22 | - * RouteMatchSpecificationDecorator constructor. |
|
23 | - * |
|
24 | - * @param RouteMatchSpecificationInterface $specification |
|
25 | - */ |
|
26 | - public function __construct(RouteMatchSpecificationInterface $specification) |
|
27 | - { |
|
28 | - $this->specification = $specification; |
|
29 | - } |
|
21 | + /** |
|
22 | + * RouteMatchSpecificationDecorator constructor. |
|
23 | + * |
|
24 | + * @param RouteMatchSpecificationInterface $specification |
|
25 | + */ |
|
26 | + public function __construct(RouteMatchSpecificationInterface $specification) |
|
27 | + { |
|
28 | + $this->specification = $specification; |
|
29 | + } |
|
30 | 30 | } |