@@ -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 |
@@ -27,182 +27,182 @@ |
||
27 | 27 | abstract class EE_Restriction_Generator_Base |
28 | 28 | { |
29 | 29 | |
30 | - /** |
|
31 | - * The restrictions generated by this object. FALSE before any are made. |
|
32 | - * @var EE_Default_Where_Conditions[] |
|
33 | - */ |
|
34 | - protected $_cap_restrictions_generated = false; |
|
30 | + /** |
|
31 | + * The restrictions generated by this object. FALSE before any are made. |
|
32 | + * @var EE_Default_Where_Conditions[] |
|
33 | + */ |
|
34 | + protected $_cap_restrictions_generated = false; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Model for which restrictions are generated |
|
38 | - * @var EEM_Base |
|
39 | - */ |
|
40 | - protected $_model; |
|
36 | + /** |
|
37 | + * Model for which restrictions are generated |
|
38 | + * @var EEM_Base |
|
39 | + */ |
|
40 | + protected $_model; |
|
41 | 41 | |
42 | - /** |
|
43 | - * One of EEM_Base::valid_cap_contexts() |
|
44 | - * @var string |
|
45 | - */ |
|
46 | - protected $_action; |
|
47 | - /** |
|
48 | - * Puts the last necessary info onto the restriction generator class. This is usually |
|
49 | - * called by EEM_Base during its constructor, so child classes don't have to |
|
50 | - * always provide this info. |
|
51 | - * @param EEM_Base $model |
|
52 | - * @param string $action |
|
53 | - */ |
|
54 | - public function _construct_finalize(EEM_Base $model, $action) |
|
55 | - { |
|
56 | - $this->_model = $model; |
|
57 | - $this->_action = $action; |
|
58 | - } |
|
42 | + /** |
|
43 | + * One of EEM_Base::valid_cap_contexts() |
|
44 | + * @var string |
|
45 | + */ |
|
46 | + protected $_action; |
|
47 | + /** |
|
48 | + * Puts the last necessary info onto the restriction generator class. This is usually |
|
49 | + * called by EEM_Base during its constructor, so child classes don't have to |
|
50 | + * always provide this info. |
|
51 | + * @param EEM_Base $model |
|
52 | + * @param string $action |
|
53 | + */ |
|
54 | + public function _construct_finalize(EEM_Base $model, $action) |
|
55 | + { |
|
56 | + $this->_model = $model; |
|
57 | + $this->_action = $action; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Returns the model set for this restriction generator |
|
62 | - * |
|
63 | - * @throws EE_Error |
|
64 | - * @return EEM_Base | EEM_Soft_Delete_Base |
|
65 | - */ |
|
66 | - public function model() |
|
67 | - { |
|
68 | - if (! $this->_model instanceof EEM_Base) { |
|
69 | - throw new EE_Error(sprintf(__('Cannot generate capability restrictions because model has not yet been set on the %s. Please ensure _construct_finalize() was called', 'event_espresso'), get_class($this))); |
|
70 | - } |
|
71 | - return $this->_model; |
|
72 | - } |
|
60 | + /** |
|
61 | + * Returns the model set for this restriction generator |
|
62 | + * |
|
63 | + * @throws EE_Error |
|
64 | + * @return EEM_Base | EEM_Soft_Delete_Base |
|
65 | + */ |
|
66 | + public function model() |
|
67 | + { |
|
68 | + if (! $this->_model instanceof EEM_Base) { |
|
69 | + throw new EE_Error(sprintf(__('Cannot generate capability restrictions because model has not yet been set on the %s. Please ensure _construct_finalize() was called', 'event_espresso'), get_class($this))); |
|
70 | + } |
|
71 | + return $this->_model; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Returns the action this restriction generator will generate restrictions for. |
|
76 | - * It should be one of EEM_Base::valid_cap_contexts() |
|
77 | - * |
|
78 | - * @throws EE_Error |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function action() |
|
82 | - { |
|
83 | - if (! $this->_action) { |
|
84 | - throw new EE_Error(sprintf(__('Cannot generate capability restrictions because model has not yet been set on the %s. Please ensure _construct_finalize() was called', 'event_espresso'), get_class($this))); |
|
85 | - } |
|
86 | - return $this->_action; |
|
87 | - } |
|
74 | + /** |
|
75 | + * Returns the action this restriction generator will generate restrictions for. |
|
76 | + * It should be one of EEM_Base::valid_cap_contexts() |
|
77 | + * |
|
78 | + * @throws EE_Error |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function action() |
|
82 | + { |
|
83 | + if (! $this->_action) { |
|
84 | + throw new EE_Error(sprintf(__('Cannot generate capability restrictions because model has not yet been set on the %s. Please ensure _construct_finalize() was called', 'event_espresso'), get_class($this))); |
|
85 | + } |
|
86 | + return $this->_action; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Returns whether or not _construct_finalize() has been called on this restriction generator object |
|
91 | - * @return boolean |
|
92 | - */ |
|
93 | - public function construction_finalized() |
|
94 | - { |
|
95 | - if ($this->_model instanceof EEM_Base && $this->_action) { |
|
96 | - return true; |
|
97 | - } else { |
|
98 | - return false; |
|
99 | - } |
|
100 | - } |
|
89 | + /** |
|
90 | + * Returns whether or not _construct_finalize() has been called on this restriction generator object |
|
91 | + * @return boolean |
|
92 | + */ |
|
93 | + public function construction_finalized() |
|
94 | + { |
|
95 | + if ($this->_model instanceof EEM_Base && $this->_action) { |
|
96 | + return true; |
|
97 | + } else { |
|
98 | + return false; |
|
99 | + } |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * Gets the capability restrictions generated by this object. Caches them in |
|
104 | - * case they are required for subsequent requests |
|
105 | - * @return array @see EEM_Base::_cap_restrictions |
|
106 | - */ |
|
107 | - public function generate_restrictions() |
|
108 | - { |
|
109 | - if ($this->_cap_restrictions_generated === false) { |
|
110 | - $this->_cap_restrictions_generated = apply_filters('FHEE__EE_Restriction_Generator_Base__generate_restrictions__first_time', $this->_generate_restrictions(), $this); |
|
111 | - } |
|
112 | - return apply_filters('FHEE__EE_Restriction_Generator_Base__generate_restrictions__every_time', $this->_cap_restrictions_generated, $this); |
|
113 | - } |
|
102 | + /** |
|
103 | + * Gets the capability restrictions generated by this object. Caches them in |
|
104 | + * case they are required for subsequent requests |
|
105 | + * @return array @see EEM_Base::_cap_restrictions |
|
106 | + */ |
|
107 | + public function generate_restrictions() |
|
108 | + { |
|
109 | + if ($this->_cap_restrictions_generated === false) { |
|
110 | + $this->_cap_restrictions_generated = apply_filters('FHEE__EE_Restriction_Generator_Base__generate_restrictions__first_time', $this->_generate_restrictions(), $this); |
|
111 | + } |
|
112 | + return apply_filters('FHEE__EE_Restriction_Generator_Base__generate_restrictions__every_time', $this->_cap_restrictions_generated, $this); |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * Provided with the model, and using global knowledge about what capabilities exist, |
|
117 | - * generates an array for use in one of the sub-arrays in EEM_Base::_cap_restrictions, |
|
118 | - * where keys are capability names, and values are children of EE_Default_Where_Conditions |
|
119 | - * @return array @see EEM_Base::_cap_restrictions |
|
120 | - */ |
|
121 | - abstract protected function _generate_restrictions(); |
|
115 | + /** |
|
116 | + * Provided with the model, and using global knowledge about what capabilities exist, |
|
117 | + * generates an array for use in one of the sub-arrays in EEM_Base::_cap_restrictions, |
|
118 | + * where keys are capability names, and values are children of EE_Default_Where_Conditions |
|
119 | + * @return array @see EEM_Base::_cap_restrictions |
|
120 | + */ |
|
121 | + abstract protected function _generate_restrictions(); |
|
122 | 122 | |
123 | - /** |
|
124 | - * Whether or not this restriction generator has already done its job of |
|
125 | - * making restrictions and caching them on itself in case its asked later |
|
126 | - * @return boolean |
|
127 | - */ |
|
128 | - public function has_generated_cap_restrictions() |
|
129 | - { |
|
130 | - if ($this->_cap_restrictions_generated === false) { |
|
131 | - return false; |
|
132 | - } else { |
|
133 | - return true; |
|
134 | - } |
|
135 | - } |
|
123 | + /** |
|
124 | + * Whether or not this restriction generator has already done its job of |
|
125 | + * making restrictions and caching them on itself in case its asked later |
|
126 | + * @return boolean |
|
127 | + */ |
|
128 | + public function has_generated_cap_restrictions() |
|
129 | + { |
|
130 | + if ($this->_cap_restrictions_generated === false) { |
|
131 | + return false; |
|
132 | + } else { |
|
133 | + return true; |
|
134 | + } |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * Given an action like 'edit' generates the cap name based off |
|
139 | - * the EEM_Base::_cap_slug, which for events would be 'events', to generate the |
|
140 | - * cap name like 'ee_edit_events'. |
|
141 | - * If a $qualifier is passed, |
|
142 | - * @param EEM_Base $model |
|
143 | - * @param string $action |
|
144 | - * @return string |
|
145 | - */ |
|
146 | - public static function get_cap_name($model, $action) |
|
147 | - { |
|
148 | - return apply_filters('FHEE__EE_Restriction_Generator__get_cap_name', ( $model->is_wp_core_model() ? '' : 'ee_' ) . $action . '_' . $model->cap_slug(), $model, $action); |
|
149 | - } |
|
137 | + /** |
|
138 | + * Given an action like 'edit' generates the cap name based off |
|
139 | + * the EEM_Base::_cap_slug, which for events would be 'events', to generate the |
|
140 | + * cap name like 'ee_edit_events'. |
|
141 | + * If a $qualifier is passed, |
|
142 | + * @param EEM_Base $model |
|
143 | + * @param string $action |
|
144 | + * @return string |
|
145 | + */ |
|
146 | + public static function get_cap_name($model, $action) |
|
147 | + { |
|
148 | + return apply_filters('FHEE__EE_Restriction_Generator__get_cap_name', ( $model->is_wp_core_model() ? '' : 'ee_' ) . $action . '_' . $model->cap_slug(), $model, $action); |
|
149 | + } |
|
150 | 150 | |
151 | - /** |
|
152 | - * Checks if there is a cap for this model and this action |
|
153 | - * @param EEM_Base $model |
|
154 | - * @param string $action |
|
155 | - * @return boolean |
|
156 | - */ |
|
157 | - public static function is_cap($model, $action) |
|
158 | - { |
|
159 | - $caps_for_admin = EE_Registry::instance()->CAP->get_ee_capabilities('administrator'); |
|
160 | - if (in_array(self::get_cap_name($model, $action), $caps_for_admin)) { |
|
161 | - return true; |
|
162 | - } else { |
|
163 | - return false; |
|
164 | - } |
|
165 | - } |
|
151 | + /** |
|
152 | + * Checks if there is a cap for this model and this action |
|
153 | + * @param EEM_Base $model |
|
154 | + * @param string $action |
|
155 | + * @return boolean |
|
156 | + */ |
|
157 | + public static function is_cap($model, $action) |
|
158 | + { |
|
159 | + $caps_for_admin = EE_Registry::instance()->CAP->get_ee_capabilities('administrator'); |
|
160 | + if (in_array(self::get_cap_name($model, $action), $caps_for_admin)) { |
|
161 | + return true; |
|
162 | + } else { |
|
163 | + return false; |
|
164 | + } |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * Returns the default capability used to determine if the current user can |
|
169 | - * access something. |
|
170 | - * @return string |
|
171 | - */ |
|
172 | - public static function get_default_restrictions_cap() |
|
173 | - { |
|
174 | - return apply_filters('FHEE__EE_Restriction_Generator_Base__default_restrictions_cap', 'manage_options'); |
|
175 | - } |
|
167 | + /** |
|
168 | + * Returns the default capability used to determine if the current user can |
|
169 | + * access something. |
|
170 | + * @return string |
|
171 | + */ |
|
172 | + public static function get_default_restrictions_cap() |
|
173 | + { |
|
174 | + return apply_filters('FHEE__EE_Restriction_Generator_Base__default_restrictions_cap', 'manage_options'); |
|
175 | + } |
|
176 | 176 | |
177 | 177 | |
178 | - /** |
|
179 | - * Gets WHERE conditions for the query that show the posty-y model is published, |
|
180 | - * or that it's sold out and it was previously published |
|
181 | - * @param array $where_conditions |
|
182 | - * @param boolean $check_if_published if true, will add conditions like status=publish. If false, will add conditions |
|
183 | - * like status!=private |
|
184 | - * @param string $path_to_event_model including the period at the end |
|
185 | - * @return array |
|
186 | - */ |
|
187 | - protected function addPublishedPostConditions($where_conditions = array(), $check_if_published = true, $path_to_event_model = '') |
|
188 | - { |
|
189 | - if ($check_if_published) { |
|
190 | - $published_value = 'publish'; |
|
191 | - } else { |
|
192 | - $published_value = array('!=','private'); |
|
193 | - } |
|
194 | - // only add a check for the previous event status if the model is the event or it's related to the event model |
|
195 | - if ($this->model() instanceof EEM_Event || strpos($path_to_event_model, 'Event') !== false) { |
|
196 | - $where_conditions['OR*status'] = array( |
|
197 | - $path_to_event_model . 'status' => $published_value, |
|
198 | - 'AND' => array( |
|
199 | - $path_to_event_model . 'Post_Meta.meta_key' => '_previous_event_status', |
|
200 | - $path_to_event_model . 'Post_Meta.meta_value' => $published_value |
|
201 | - ) |
|
202 | - ); |
|
203 | - } else { |
|
204 | - $where_conditions[ $path_to_event_model . 'status' ] = $published_value; |
|
205 | - } |
|
206 | - return $where_conditions; |
|
207 | - } |
|
178 | + /** |
|
179 | + * Gets WHERE conditions for the query that show the posty-y model is published, |
|
180 | + * or that it's sold out and it was previously published |
|
181 | + * @param array $where_conditions |
|
182 | + * @param boolean $check_if_published if true, will add conditions like status=publish. If false, will add conditions |
|
183 | + * like status!=private |
|
184 | + * @param string $path_to_event_model including the period at the end |
|
185 | + * @return array |
|
186 | + */ |
|
187 | + protected function addPublishedPostConditions($where_conditions = array(), $check_if_published = true, $path_to_event_model = '') |
|
188 | + { |
|
189 | + if ($check_if_published) { |
|
190 | + $published_value = 'publish'; |
|
191 | + } else { |
|
192 | + $published_value = array('!=','private'); |
|
193 | + } |
|
194 | + // only add a check for the previous event status if the model is the event or it's related to the event model |
|
195 | + if ($this->model() instanceof EEM_Event || strpos($path_to_event_model, 'Event') !== false) { |
|
196 | + $where_conditions['OR*status'] = array( |
|
197 | + $path_to_event_model . 'status' => $published_value, |
|
198 | + 'AND' => array( |
|
199 | + $path_to_event_model . 'Post_Meta.meta_key' => '_previous_event_status', |
|
200 | + $path_to_event_model . 'Post_Meta.meta_value' => $published_value |
|
201 | + ) |
|
202 | + ); |
|
203 | + } else { |
|
204 | + $where_conditions[ $path_to_event_model . 'status' ] = $published_value; |
|
205 | + } |
|
206 | + return $where_conditions; |
|
207 | + } |
|
208 | 208 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function model() |
67 | 67 | { |
68 | - if (! $this->_model instanceof EEM_Base) { |
|
68 | + if ( ! $this->_model instanceof EEM_Base) { |
|
69 | 69 | throw new EE_Error(sprintf(__('Cannot generate capability restrictions because model has not yet been set on the %s. Please ensure _construct_finalize() was called', 'event_espresso'), get_class($this))); |
70 | 70 | } |
71 | 71 | return $this->_model; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function action() |
82 | 82 | { |
83 | - if (! $this->_action) { |
|
83 | + if ( ! $this->_action) { |
|
84 | 84 | throw new EE_Error(sprintf(__('Cannot generate capability restrictions because model has not yet been set on the %s. Please ensure _construct_finalize() was called', 'event_espresso'), get_class($this))); |
85 | 85 | } |
86 | 86 | return $this->_action; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function construction_finalized() |
94 | 94 | { |
95 | - if ($this->_model instanceof EEM_Base && $this->_action) { |
|
95 | + if ($this->_model instanceof EEM_Base && $this->_action) { |
|
96 | 96 | return true; |
97 | 97 | } else { |
98 | 98 | return false; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public static function get_cap_name($model, $action) |
147 | 147 | { |
148 | - return apply_filters('FHEE__EE_Restriction_Generator__get_cap_name', ( $model->is_wp_core_model() ? '' : 'ee_' ) . $action . '_' . $model->cap_slug(), $model, $action); |
|
148 | + return apply_filters('FHEE__EE_Restriction_Generator__get_cap_name', ($model->is_wp_core_model() ? '' : 'ee_').$action.'_'.$model->cap_slug(), $model, $action); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -189,19 +189,19 @@ discard block |
||
189 | 189 | if ($check_if_published) { |
190 | 190 | $published_value = 'publish'; |
191 | 191 | } else { |
192 | - $published_value = array('!=','private'); |
|
192 | + $published_value = array('!=', 'private'); |
|
193 | 193 | } |
194 | 194 | // only add a check for the previous event status if the model is the event or it's related to the event model |
195 | 195 | if ($this->model() instanceof EEM_Event || strpos($path_to_event_model, 'Event') !== false) { |
196 | 196 | $where_conditions['OR*status'] = array( |
197 | - $path_to_event_model . 'status' => $published_value, |
|
197 | + $path_to_event_model.'status' => $published_value, |
|
198 | 198 | 'AND' => array( |
199 | - $path_to_event_model . 'Post_Meta.meta_key' => '_previous_event_status', |
|
200 | - $path_to_event_model . 'Post_Meta.meta_value' => $published_value |
|
199 | + $path_to_event_model.'Post_Meta.meta_key' => '_previous_event_status', |
|
200 | + $path_to_event_model.'Post_Meta.meta_value' => $published_value |
|
201 | 201 | ) |
202 | 202 | ); |
203 | 203 | } else { |
204 | - $where_conditions[ $path_to_event_model . 'status' ] = $published_value; |
|
204 | + $where_conditions[$path_to_event_model.'status'] = $published_value; |
|
205 | 205 | } |
206 | 206 | return $where_conditions; |
207 | 207 | } |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.66.rc.009'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.66.rc.009'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |