@@ -2,36 +2,36 @@ |
||
2 | 2 | |
3 | 3 | class EE_Maybe_Serialized_Text_Field extends EE_Serialized_Text_Field |
4 | 4 | { |
5 | - /** |
|
6 | - * Value could be an array or a string. If its an array, serialize it. Otherwise, leave it as a string |
|
7 | - * |
|
8 | - * @param array|string $value_of_field_on_model_object |
|
9 | - * @return string (possibly serialized) |
|
10 | - */ |
|
11 | - public function prepare_for_use_in_db($value_of_field_on_model_object) |
|
12 | - { |
|
13 | - if (is_array($value_of_field_on_model_object)) { |
|
14 | - return parent::prepare_for_use_in_db($value_of_field_on_model_object); |
|
15 | - } else { |
|
16 | - return $value_of_field_on_model_object; |
|
17 | - } |
|
18 | - } |
|
5 | + /** |
|
6 | + * Value could be an array or a string. If its an array, serialize it. Otherwise, leave it as a string |
|
7 | + * |
|
8 | + * @param array|string $value_of_field_on_model_object |
|
9 | + * @return string (possibly serialized) |
|
10 | + */ |
|
11 | + public function prepare_for_use_in_db($value_of_field_on_model_object) |
|
12 | + { |
|
13 | + if (is_array($value_of_field_on_model_object)) { |
|
14 | + return parent::prepare_for_use_in_db($value_of_field_on_model_object); |
|
15 | + } else { |
|
16 | + return $value_of_field_on_model_object; |
|
17 | + } |
|
18 | + } |
|
19 | 19 | |
20 | - /** |
|
21 | - * Formats the array (or string) according to $schema. Right now, just implode with commas |
|
22 | - * |
|
23 | - * @param type $value_on_field_to_be_outputted |
|
24 | - * @param type $schema |
|
25 | - * @return strubg |
|
26 | - */ |
|
27 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
28 | - { |
|
29 | - $pretty_value = null; |
|
30 | - if (is_array($value_on_field_to_be_outputted)) { |
|
31 | - $pretty_value = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
|
32 | - } else { |
|
33 | - $pretty_value = $value_on_field_to_be_outputted; |
|
34 | - } |
|
35 | - return $pretty_value; |
|
36 | - } |
|
20 | + /** |
|
21 | + * Formats the array (or string) according to $schema. Right now, just implode with commas |
|
22 | + * |
|
23 | + * @param type $value_on_field_to_be_outputted |
|
24 | + * @param type $schema |
|
25 | + * @return strubg |
|
26 | + */ |
|
27 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
28 | + { |
|
29 | + $pretty_value = null; |
|
30 | + if (is_array($value_on_field_to_be_outputted)) { |
|
31 | + $pretty_value = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
|
32 | + } else { |
|
33 | + $pretty_value = $value_on_field_to_be_outputted; |
|
34 | + } |
|
35 | + return $pretty_value; |
|
36 | + } |
|
37 | 37 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function prepare_for_set($value) |
30 | 30 | { |
31 | - if (! current_user_can('unfiltered_html')) { |
|
31 | + if ( ! current_user_can('unfiltered_html')) { |
|
32 | 32 | $value = wp_kses("$value", wp_kses_allowed_html('post')); |
33 | 33 | } |
34 | 34 | return parent::prepare_for_set($value); |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected static function _setup_the_content_wp_core_only_filters() |
98 | 98 | { |
99 | - add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'run_shortcode'), 8); |
|
100 | - add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'autoembed'), 8); |
|
99 | + add_filter('the_content_wp_core_only', array($GLOBALS['wp_embed'], 'run_shortcode'), 8); |
|
100 | + add_filter('the_content_wp_core_only', array($GLOBALS['wp_embed'], 'autoembed'), 8); |
|
101 | 101 | add_filter('the_content_wp_core_only', 'wptexturize', 10); |
102 | 102 | add_filter('the_content_wp_core_only', 'wpautop', 10); |
103 | 103 | add_filter('the_content_wp_core_only', 'shortcode_unautop', 10); |
@@ -7,129 +7,129 @@ |
||
7 | 7 | class EE_Post_Content_Field extends EE_Text_Field_Base |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * @param string $table_column |
|
12 | - * @param string $nicename |
|
13 | - * @param bool $nullable |
|
14 | - * @param null $default_value |
|
15 | - */ |
|
16 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
17 | - { |
|
18 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
19 | - $this->setSchemaType('object'); |
|
20 | - } |
|
10 | + /** |
|
11 | + * @param string $table_column |
|
12 | + * @param string $nicename |
|
13 | + * @param bool $nullable |
|
14 | + * @param null $default_value |
|
15 | + */ |
|
16 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
17 | + { |
|
18 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
19 | + $this->setSchemaType('object'); |
|
20 | + } |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * removes all tags which a WP Post wouldn't allow in its content normally |
|
25 | - * |
|
26 | - * @param string $value |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function prepare_for_set($value) |
|
30 | - { |
|
31 | - if (! current_user_can('unfiltered_html')) { |
|
32 | - $value = wp_kses("$value", wp_kses_allowed_html('post')); |
|
33 | - } |
|
34 | - return parent::prepare_for_set($value); |
|
35 | - } |
|
23 | + /** |
|
24 | + * removes all tags which a WP Post wouldn't allow in its content normally |
|
25 | + * |
|
26 | + * @param string $value |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function prepare_for_set($value) |
|
30 | + { |
|
31 | + if (! current_user_can('unfiltered_html')) { |
|
32 | + $value = wp_kses("$value", wp_kses_allowed_html('post')); |
|
33 | + } |
|
34 | + return parent::prepare_for_set($value); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Runs the content through `the_content`, or if prepares the content for placing in a form input |
|
41 | - * @param string $value_on_field_to_be_outputted |
|
42 | - * @param string $schema possible values: 'form_input' or null (if null, will run through 'the_content') |
|
43 | - * @return string |
|
44 | - * @throws EE_Error when WP_DEBUG is on and recursive calling is detected |
|
45 | - */ |
|
46 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
47 | - { |
|
48 | - switch ($schema) { |
|
49 | - case 'form_input': |
|
50 | - return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
|
51 | - case 'the_content': |
|
52 | - if (doing_filter('the_content')) { |
|
53 | - if (defined('WP_DEBUG') && WP_DEBUG) { |
|
54 | - throw new EE_Error( |
|
55 | - sprintf( |
|
56 | - esc_html__('You have recursively called "%1$s" with %2$s set to %3$s which uses "%2$s" filter. You should use it with %2$s "%3$s" instead here.', 'event_espresso'), |
|
57 | - 'EE_Post_Content_Field::prepare_for_pretty_echoing', |
|
58 | - '$schema', |
|
59 | - 'the_content', |
|
60 | - 'the_content_wp_core_only' |
|
61 | - ) |
|
62 | - ); |
|
63 | - } else { |
|
64 | - return $this->prepare_for_pretty_echoing($value_on_field_to_be_outputted, 'the_content_wp_core_only'); |
|
65 | - } |
|
66 | - } |
|
67 | - return apply_filters( |
|
68 | - 'the_content', |
|
69 | - parent::prepare_for_pretty_echoing( |
|
70 | - $value_on_field_to_be_outputted, |
|
71 | - $schema |
|
72 | - ) |
|
73 | - ); |
|
74 | - case 'the_content_wp_core_only': |
|
75 | - default: |
|
76 | - self::_setup_the_content_wp_core_only_filters(); |
|
77 | - $return_value = apply_filters( |
|
78 | - 'the_content_wp_core_only', |
|
79 | - parent::prepare_for_pretty_echoing( |
|
80 | - $value_on_field_to_be_outputted, |
|
81 | - $schema |
|
82 | - ) |
|
83 | - ); |
|
84 | - // ya know what? adding these filters is super fast. Let's just |
|
85 | - // avoid needing to maintain global state and set this up as-needed |
|
86 | - remove_all_filters('the_content_wp_core_only'); |
|
87 | - do_action('AHEE__EE_Post_Content_Field__prepare_for_pretty_echoing__the_content_wp_core_only__done'); |
|
88 | - return $return_value; |
|
89 | - } |
|
90 | - } |
|
39 | + /** |
|
40 | + * Runs the content through `the_content`, or if prepares the content for placing in a form input |
|
41 | + * @param string $value_on_field_to_be_outputted |
|
42 | + * @param string $schema possible values: 'form_input' or null (if null, will run through 'the_content') |
|
43 | + * @return string |
|
44 | + * @throws EE_Error when WP_DEBUG is on and recursive calling is detected |
|
45 | + */ |
|
46 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
47 | + { |
|
48 | + switch ($schema) { |
|
49 | + case 'form_input': |
|
50 | + return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
|
51 | + case 'the_content': |
|
52 | + if (doing_filter('the_content')) { |
|
53 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
54 | + throw new EE_Error( |
|
55 | + sprintf( |
|
56 | + esc_html__('You have recursively called "%1$s" with %2$s set to %3$s which uses "%2$s" filter. You should use it with %2$s "%3$s" instead here.', 'event_espresso'), |
|
57 | + 'EE_Post_Content_Field::prepare_for_pretty_echoing', |
|
58 | + '$schema', |
|
59 | + 'the_content', |
|
60 | + 'the_content_wp_core_only' |
|
61 | + ) |
|
62 | + ); |
|
63 | + } else { |
|
64 | + return $this->prepare_for_pretty_echoing($value_on_field_to_be_outputted, 'the_content_wp_core_only'); |
|
65 | + } |
|
66 | + } |
|
67 | + return apply_filters( |
|
68 | + 'the_content', |
|
69 | + parent::prepare_for_pretty_echoing( |
|
70 | + $value_on_field_to_be_outputted, |
|
71 | + $schema |
|
72 | + ) |
|
73 | + ); |
|
74 | + case 'the_content_wp_core_only': |
|
75 | + default: |
|
76 | + self::_setup_the_content_wp_core_only_filters(); |
|
77 | + $return_value = apply_filters( |
|
78 | + 'the_content_wp_core_only', |
|
79 | + parent::prepare_for_pretty_echoing( |
|
80 | + $value_on_field_to_be_outputted, |
|
81 | + $schema |
|
82 | + ) |
|
83 | + ); |
|
84 | + // ya know what? adding these filters is super fast. Let's just |
|
85 | + // avoid needing to maintain global state and set this up as-needed |
|
86 | + remove_all_filters('the_content_wp_core_only'); |
|
87 | + do_action('AHEE__EE_Post_Content_Field__prepare_for_pretty_echoing__the_content_wp_core_only__done'); |
|
88 | + return $return_value; |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * Verifies we've setup the standard WP core filters on 'the_content_wp_core_only' filter |
|
96 | - */ |
|
97 | - protected static function _setup_the_content_wp_core_only_filters() |
|
98 | - { |
|
99 | - add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'run_shortcode'), 8); |
|
100 | - add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'autoembed'), 8); |
|
101 | - add_filter('the_content_wp_core_only', 'wptexturize', 10); |
|
102 | - add_filter('the_content_wp_core_only', 'wpautop', 10); |
|
103 | - add_filter('the_content_wp_core_only', 'shortcode_unautop', 10); |
|
104 | - add_filter('the_content_wp_core_only', 'prepend_attachment', 10); |
|
105 | - if (function_exists('wp_filter_content_tags')) { |
|
106 | - add_filter('the_content_wp_core_only', 'wp_filter_content_tags', 10); |
|
107 | - } elseif (function_exists('wp_make_content_images_responsive')) { |
|
108 | - add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10); |
|
109 | - } |
|
110 | - add_filter('the_content_wp_core_only', 'do_shortcode', 11); |
|
111 | - add_filter('the_content_wp_core_only', 'convert_smilies', 20); |
|
112 | - } |
|
94 | + /** |
|
95 | + * Verifies we've setup the standard WP core filters on 'the_content_wp_core_only' filter |
|
96 | + */ |
|
97 | + protected static function _setup_the_content_wp_core_only_filters() |
|
98 | + { |
|
99 | + add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'run_shortcode'), 8); |
|
100 | + add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'autoembed'), 8); |
|
101 | + add_filter('the_content_wp_core_only', 'wptexturize', 10); |
|
102 | + add_filter('the_content_wp_core_only', 'wpautop', 10); |
|
103 | + add_filter('the_content_wp_core_only', 'shortcode_unautop', 10); |
|
104 | + add_filter('the_content_wp_core_only', 'prepend_attachment', 10); |
|
105 | + if (function_exists('wp_filter_content_tags')) { |
|
106 | + add_filter('the_content_wp_core_only', 'wp_filter_content_tags', 10); |
|
107 | + } elseif (function_exists('wp_make_content_images_responsive')) { |
|
108 | + add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10); |
|
109 | + } |
|
110 | + add_filter('the_content_wp_core_only', 'do_shortcode', 11); |
|
111 | + add_filter('the_content_wp_core_only', 'convert_smilies', 20); |
|
112 | + } |
|
113 | 113 | |
114 | 114 | |
115 | 115 | |
116 | - public function getSchemaProperties() |
|
117 | - { |
|
118 | - return array( |
|
119 | - 'raw' => array( |
|
120 | - 'description' => sprintf( |
|
121 | - esc_html__('%s - the content as it exists in the database.', 'event_espresso'), |
|
122 | - $this->get_nicename() |
|
123 | - ), |
|
124 | - 'type' => 'string' |
|
125 | - ), |
|
126 | - 'rendered' => array( |
|
127 | - 'description' => sprintf( |
|
128 | - esc_html__('%s - the content rendered for display.', 'event_espresso'), |
|
129 | - $this->get_nicename() |
|
130 | - ), |
|
131 | - 'type' => 'string' |
|
132 | - ) |
|
133 | - ); |
|
134 | - } |
|
116 | + public function getSchemaProperties() |
|
117 | + { |
|
118 | + return array( |
|
119 | + 'raw' => array( |
|
120 | + 'description' => sprintf( |
|
121 | + esc_html__('%s - the content as it exists in the database.', 'event_espresso'), |
|
122 | + $this->get_nicename() |
|
123 | + ), |
|
124 | + 'type' => 'string' |
|
125 | + ), |
|
126 | + 'rendered' => array( |
|
127 | + 'description' => sprintf( |
|
128 | + esc_html__('%s - the content rendered for display.', 'event_espresso'), |
|
129 | + $this->get_nicename() |
|
130 | + ), |
|
131 | + 'type' => 'string' |
|
132 | + ) |
|
133 | + ); |
|
134 | + } |
|
135 | 135 | } |
@@ -11,59 +11,59 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field |
13 | 13 | { |
14 | - /** |
|
15 | - * removes all non-basic tags when setting |
|
16 | - * |
|
17 | - * @param string $value_inputted_for_field_on_model_object |
|
18 | - * @return string |
|
19 | - */ |
|
20 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
21 | - { |
|
22 | - return parent::prepare_for_set($this->_remove_tags($value_inputted_for_field_on_model_object)); |
|
23 | - } |
|
14 | + /** |
|
15 | + * removes all non-basic tags when setting |
|
16 | + * |
|
17 | + * @param string $value_inputted_for_field_on_model_object |
|
18 | + * @return string |
|
19 | + */ |
|
20 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
21 | + { |
|
22 | + return parent::prepare_for_set($this->_remove_tags($value_inputted_for_field_on_model_object)); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Remove any non-"simple" html tags. @see EE_Simple_HTML_Field |
|
27 | - * |
|
28 | - * @param array|string $value |
|
29 | - * @return array|string |
|
30 | - */ |
|
31 | - protected function _remove_tags($value) |
|
32 | - { |
|
33 | - if (is_array($value)) { |
|
34 | - foreach ($value as $key => $v) { |
|
35 | - $value[ $key ] = $this->_remove_tags($v); |
|
36 | - } |
|
37 | - } elseif (is_string($value)) { |
|
38 | - $value = wp_kses("$value", $this->_get_allowed_tags()); |
|
39 | - } |
|
40 | - return $value; |
|
41 | - } |
|
25 | + /** |
|
26 | + * Remove any non-"simple" html tags. @see EE_Simple_HTML_Field |
|
27 | + * |
|
28 | + * @param array|string $value |
|
29 | + * @return array|string |
|
30 | + */ |
|
31 | + protected function _remove_tags($value) |
|
32 | + { |
|
33 | + if (is_array($value)) { |
|
34 | + foreach ($value as $key => $v) { |
|
35 | + $value[ $key ] = $this->_remove_tags($v); |
|
36 | + } |
|
37 | + } elseif (is_string($value)) { |
|
38 | + $value = wp_kses("$value", $this->_get_allowed_tags()); |
|
39 | + } |
|
40 | + return $value; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * In case unsafe data somehow got inserted into the database, we want to remove tags again |
|
45 | - * |
|
46 | - * @param array|string $value_found_in_db_for_model_object |
|
47 | - * @return array|string |
|
48 | - */ |
|
49 | - public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
50 | - { |
|
51 | - return $this->_remove_tags(parent::prepare_for_set_from_db($value_found_in_db_for_model_object)); |
|
52 | - } |
|
43 | + /** |
|
44 | + * In case unsafe data somehow got inserted into the database, we want to remove tags again |
|
45 | + * |
|
46 | + * @param array|string $value_found_in_db_for_model_object |
|
47 | + * @return array|string |
|
48 | + */ |
|
49 | + public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
50 | + { |
|
51 | + return $this->_remove_tags(parent::prepare_for_set_from_db($value_found_in_db_for_model_object)); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Determines what tags to allow in this model field |
|
57 | - * |
|
58 | - * @global array $allowedtags |
|
59 | - * @return array |
|
60 | - */ |
|
61 | - public function _get_allowed_tags() |
|
62 | - { |
|
63 | - return apply_filters( |
|
64 | - 'FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', |
|
65 | - EEH_HTML::get_simple_tags(), |
|
66 | - $this |
|
67 | - ); |
|
68 | - } |
|
55 | + /** |
|
56 | + * Determines what tags to allow in this model field |
|
57 | + * |
|
58 | + * @global array $allowedtags |
|
59 | + * @return array |
|
60 | + */ |
|
61 | + public function _get_allowed_tags() |
|
62 | + { |
|
63 | + return apply_filters( |
|
64 | + 'FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', |
|
65 | + EEH_HTML::get_simple_tags(), |
|
66 | + $this |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | { |
33 | 33 | if (is_array($value)) { |
34 | 34 | foreach ($value as $key => $v) { |
35 | - $value[ $key ] = $this->_remove_tags($v); |
|
35 | + $value[$key] = $this->_remove_tags($v); |
|
36 | 36 | } |
37 | 37 | } elseif (is_string($value)) { |
38 | 38 | $value = wp_kses("$value", $this->_get_allowed_tags()); |
@@ -10,28 +10,28 @@ |
||
10 | 10 | abstract class EE_DB_Only_Field_Base extends EE_Model_Field_Base |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @param string $table_column |
|
15 | - * @param string $nicename |
|
16 | - * @param bool $nullable |
|
17 | - * @param null $default_value |
|
18 | - */ |
|
19 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
20 | - { |
|
21 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
22 | - $this->setSchemaReadOnly(true); |
|
23 | - } |
|
13 | + /** |
|
14 | + * @param string $table_column |
|
15 | + * @param string $nicename |
|
16 | + * @param bool $nullable |
|
17 | + * @param null $default_value |
|
18 | + */ |
|
19 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
20 | + { |
|
21 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
22 | + $this->setSchemaReadOnly(true); |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * All these children classes are for the db-only (meaning, we should select them |
|
28 | - * on get_all queries, update, delete, and will still want to set their default value |
|
29 | - * on inserts, but the model object won't have reference to these fields) |
|
30 | - * |
|
31 | - * @return boolean |
|
32 | - */ |
|
33 | - public function is_db_only_field() |
|
34 | - { |
|
35 | - return true; |
|
36 | - } |
|
26 | + /** |
|
27 | + * All these children classes are for the db-only (meaning, we should select them |
|
28 | + * on get_all queries, update, delete, and will still want to set their default value |
|
29 | + * on inserts, but the model object won't have reference to these fields) |
|
30 | + * |
|
31 | + * @return boolean |
|
32 | + */ |
|
33 | + public function is_db_only_field() |
|
34 | + { |
|
35 | + return true; |
|
36 | + } |
|
37 | 37 | } |
@@ -3,17 +3,17 @@ |
||
3 | 3 | class EE_Foreign_Key_String_Field extends EE_Foreign_Key_Field_Base |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * removes all tags when setting |
|
8 | - * |
|
9 | - * @param string $value_inputted_for_field_on_model_object |
|
10 | - * @return string |
|
11 | - */ |
|
12 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
13 | - { |
|
14 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
15 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
16 | - } |
|
17 | - return strtoupper(wp_strip_all_tags($value_inputted_for_field_on_model_object)); |
|
18 | - } |
|
6 | + /** |
|
7 | + * removes all tags when setting |
|
8 | + * |
|
9 | + * @param string $value_inputted_for_field_on_model_object |
|
10 | + * @return string |
|
11 | + */ |
|
12 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
13 | + { |
|
14 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
15 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
16 | + } |
|
17 | + return strtoupper(wp_strip_all_tags($value_inputted_for_field_on_model_object)); |
|
18 | + } |
|
19 | 19 | } |
@@ -3,22 +3,22 @@ |
||
3 | 3 | class EE_Primary_Key_String_Field extends EE_Primary_Key_Field_Base |
4 | 4 | { |
5 | 5 | |
6 | - public function __construct($table_column, $nicename) |
|
7 | - { |
|
8 | - parent::__construct($table_column, $nicename, null); |
|
9 | - } |
|
6 | + public function __construct($table_column, $nicename) |
|
7 | + { |
|
8 | + parent::__construct($table_column, $nicename, null); |
|
9 | + } |
|
10 | 10 | |
11 | - /** |
|
12 | - * removes all tags when setting |
|
13 | - * |
|
14 | - * @param string $value_inputted_for_field_on_model_object |
|
15 | - * @return string |
|
16 | - */ |
|
17 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
18 | - { |
|
19 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
20 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
21 | - } |
|
22 | - return wp_strip_all_tags($value_inputted_for_field_on_model_object); |
|
23 | - } |
|
11 | + /** |
|
12 | + * removes all tags when setting |
|
13 | + * |
|
14 | + * @param string $value_inputted_for_field_on_model_object |
|
15 | + * @return string |
|
16 | + */ |
|
17 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
18 | + { |
|
19 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
20 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
21 | + } |
|
22 | + return wp_strip_all_tags($value_inputted_for_field_on_model_object); |
|
23 | + } |
|
24 | 24 | } |
@@ -20,47 +20,47 @@ |
||
20 | 20 | class EE_Restriction_Generator_Global extends EE_Restriction_Generator_Base |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * name of the model field that indicates whether or not a model object is "global" |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - protected $_global_field_name; |
|
28 | - /** |
|
29 | - * |
|
30 | - * @param string $global_field_name name of the model field that indicates whether or not |
|
31 | - * a model object is "global" |
|
32 | - */ |
|
33 | - public function __construct($global_field_name) |
|
34 | - { |
|
35 | - $this->_global_field_name = $global_field_name; |
|
36 | - } |
|
23 | + /** |
|
24 | + * name of the model field that indicates whether or not a model object is "global" |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + protected $_global_field_name; |
|
28 | + /** |
|
29 | + * |
|
30 | + * @param string $global_field_name name of the model field that indicates whether or not |
|
31 | + * a model object is "global" |
|
32 | + */ |
|
33 | + public function __construct($global_field_name) |
|
34 | + { |
|
35 | + $this->_global_field_name = $global_field_name; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @return \EE_Default_Where_Conditions |
|
40 | - */ |
|
41 | - protected function _generate_restrictions() |
|
42 | - { |
|
38 | + /** |
|
39 | + * @return \EE_Default_Where_Conditions |
|
40 | + */ |
|
41 | + protected function _generate_restrictions() |
|
42 | + { |
|
43 | 43 | |
44 | - // if there are no standard caps for this model, then for now all we know is |
|
45 | - // if they need the default cap to access this |
|
46 | - if (! $this->model()->cap_slug()) { |
|
47 | - return array( |
|
48 | - EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
|
49 | - ); |
|
50 | - } |
|
51 | - return array( |
|
52 | - EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Return_None_Where_Conditions(), |
|
53 | - EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => new EE_Default_Where_Conditions(array( |
|
54 | - // I need to be the owner, or it must be a global item |
|
55 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => array( |
|
56 | - EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
|
57 | - $this->_global_field_name => true |
|
58 | - ) |
|
59 | - )), |
|
60 | - EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_global') => new EE_Default_Where_Conditions(array( |
|
61 | - // it mustn't be global |
|
62 | - $this->_global_field_name => false |
|
63 | - )) |
|
64 | - ); |
|
65 | - } |
|
44 | + // if there are no standard caps for this model, then for now all we know is |
|
45 | + // if they need the default cap to access this |
|
46 | + if (! $this->model()->cap_slug()) { |
|
47 | + return array( |
|
48 | + EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
|
49 | + ); |
|
50 | + } |
|
51 | + return array( |
|
52 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Return_None_Where_Conditions(), |
|
53 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => new EE_Default_Where_Conditions(array( |
|
54 | + // I need to be the owner, or it must be a global item |
|
55 | + 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => array( |
|
56 | + EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
|
57 | + $this->_global_field_name => true |
|
58 | + ) |
|
59 | + )), |
|
60 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_global') => new EE_Default_Where_Conditions(array( |
|
61 | + // it mustn't be global |
|
62 | + $this->_global_field_name => false |
|
63 | + )) |
|
64 | + ); |
|
65 | + } |
|
66 | 66 | } |
@@ -43,21 +43,21 @@ |
||
43 | 43 | |
44 | 44 | // if there are no standard caps for this model, then for now all we know is |
45 | 45 | // if they need the default cap to access this |
46 | - if (! $this->model()->cap_slug()) { |
|
46 | + if ( ! $this->model()->cap_slug()) { |
|
47 | 47 | return array( |
48 | 48 | EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
49 | 49 | ); |
50 | 50 | } |
51 | 51 | return array( |
52 | 52 | EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Return_None_Where_Conditions(), |
53 | - EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => new EE_Default_Where_Conditions(array( |
|
53 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_others') => new EE_Default_Where_Conditions(array( |
|
54 | 54 | // I need to be the owner, or it must be a global item |
55 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => array( |
|
55 | + 'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_others') => array( |
|
56 | 56 | EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
57 | 57 | $this->_global_field_name => true |
58 | 58 | ) |
59 | 59 | )), |
60 | - EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_global') => new EE_Default_Where_Conditions(array( |
|
60 | + EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_global') => new EE_Default_Where_Conditions(array( |
|
61 | 61 | // it mustn't be global |
62 | 62 | $this->_global_field_name => false |
63 | 63 | )) |
@@ -25,48 +25,48 @@ |
||
25 | 25 | class EE_Restriction_Generator_Protected extends EE_Restriction_Generator_Base |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @return \EE_Default_Where_Conditions |
|
30 | - */ |
|
31 | - protected function _generate_restrictions() |
|
32 | - { |
|
28 | + /** |
|
29 | + * @return \EE_Default_Where_Conditions |
|
30 | + */ |
|
31 | + protected function _generate_restrictions() |
|
32 | + { |
|
33 | 33 | |
34 | - // if there are no standard caps for this model, then for now all we know |
|
35 | - // if they need the default cap to access this |
|
36 | - if (! $this->model()->cap_slug()) { |
|
37 | - return array( |
|
38 | - EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
|
39 | - ); |
|
40 | - } |
|
34 | + // if there are no standard caps for this model, then for now all we know |
|
35 | + // if they need the default cap to access this |
|
36 | + if (! $this->model()->cap_slug()) { |
|
37 | + return array( |
|
38 | + EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
|
39 | + ); |
|
40 | + } |
|
41 | 41 | |
42 | - $restrictions = array(); |
|
43 | - // does the basic cap exist? (eg 'ee_read_registrations') |
|
44 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action())) { |
|
45 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) ] = new EE_Return_None_Where_Conditions(); |
|
46 | - // does the others cap exist? (eg 'ee_read_others_registrations') |
|
47 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others')) {// both caps exist |
|
48 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') ] = new EE_Default_Where_Conditions( |
|
49 | - array( |
|
50 | - EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder |
|
51 | - ) |
|
52 | - ); |
|
53 | - // does the private cap exist (eg 'ee_read_others_private_events') |
|
54 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_private') && $this->model() instanceof EEM_CPT_Base) { |
|
55 | - // if they have basic and others, but not private, restrict them to see theirs and others' that aren't private |
|
56 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') ] = new EE_Default_Where_Conditions( |
|
57 | - array( |
|
58 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') => array( |
|
59 | - EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
|
60 | - 'status' => array( '!=', 'private' ) |
|
61 | - ) |
|
62 | - ) |
|
63 | - ); |
|
64 | - } |
|
65 | - } |
|
66 | - } else { |
|
67 | - // there is no basic cap. So they can only access this if they have the default admin cap |
|
68 | - $restrictions[ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] = new EE_Return_None_Where_Conditions(); |
|
69 | - } |
|
70 | - return $restrictions; |
|
71 | - } |
|
42 | + $restrictions = array(); |
|
43 | + // does the basic cap exist? (eg 'ee_read_registrations') |
|
44 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action())) { |
|
45 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) ] = new EE_Return_None_Where_Conditions(); |
|
46 | + // does the others cap exist? (eg 'ee_read_others_registrations') |
|
47 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others')) {// both caps exist |
|
48 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') ] = new EE_Default_Where_Conditions( |
|
49 | + array( |
|
50 | + EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder |
|
51 | + ) |
|
52 | + ); |
|
53 | + // does the private cap exist (eg 'ee_read_others_private_events') |
|
54 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_private') && $this->model() instanceof EEM_CPT_Base) { |
|
55 | + // if they have basic and others, but not private, restrict them to see theirs and others' that aren't private |
|
56 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') ] = new EE_Default_Where_Conditions( |
|
57 | + array( |
|
58 | + 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') => array( |
|
59 | + EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
|
60 | + 'status' => array( '!=', 'private' ) |
|
61 | + ) |
|
62 | + ) |
|
63 | + ); |
|
64 | + } |
|
65 | + } |
|
66 | + } else { |
|
67 | + // there is no basic cap. So they can only access this if they have the default admin cap |
|
68 | + $restrictions[ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] = new EE_Return_None_Where_Conditions(); |
|
69 | + } |
|
70 | + return $restrictions; |
|
71 | + } |
|
72 | 72 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | // if there are no standard caps for this model, then for now all we know |
35 | 35 | // if they need the default cap to access this |
36 | - if (! $this->model()->cap_slug()) { |
|
36 | + if ( ! $this->model()->cap_slug()) { |
|
37 | 37 | return array( |
38 | 38 | EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions() |
39 | 39 | ); |
@@ -42,22 +42,22 @@ discard block |
||
42 | 42 | $restrictions = array(); |
43 | 43 | // does the basic cap exist? (eg 'ee_read_registrations') |
44 | 44 | if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action())) { |
45 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) ] = new EE_Return_None_Where_Conditions(); |
|
45 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action())] = new EE_Return_None_Where_Conditions(); |
|
46 | 46 | // does the others cap exist? (eg 'ee_read_others_registrations') |
47 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others')) {// both caps exist |
|
48 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') ] = new EE_Default_Where_Conditions( |
|
47 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action().'_others')) {// both caps exist |
|
48 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_others')] = new EE_Default_Where_Conditions( |
|
49 | 49 | array( |
50 | 50 | EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder |
51 | 51 | ) |
52 | 52 | ); |
53 | 53 | // does the private cap exist (eg 'ee_read_others_private_events') |
54 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_private') && $this->model() instanceof EEM_CPT_Base) { |
|
54 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action().'_private') && $this->model() instanceof EEM_CPT_Base) { |
|
55 | 55 | // if they have basic and others, but not private, restrict them to see theirs and others' that aren't private |
56 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') ] = new EE_Default_Where_Conditions( |
|
56 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_private')] = new EE_Default_Where_Conditions( |
|
57 | 57 | array( |
58 | - 'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') => array( |
|
58 | + 'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_private') => array( |
|
59 | 59 | EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder, |
60 | - 'status' => array( '!=', 'private' ) |
|
60 | + 'status' => array('!=', 'private') |
|
61 | 61 | ) |
62 | 62 | ) |
63 | 63 | ); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | } else { |
67 | 67 | // there is no basic cap. So they can only access this if they have the default admin cap |
68 | - $restrictions[ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] = new EE_Return_None_Where_Conditions(); |
|
68 | + $restrictions[EE_Restriction_Generator_Base::get_default_restrictions_cap()] = new EE_Return_None_Where_Conditions(); |
|
69 | 69 | } |
70 | 70 | return $restrictions; |
71 | 71 | } |
@@ -14,60 +14,60 @@ |
||
14 | 14 | class EE_Restriction_Generator_Meta extends EE_Restriction_Generator_Base |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * |
|
19 | - * @var string the name of the field containing the meta key |
|
20 | - */ |
|
21 | - protected $_key_field_name = null; |
|
17 | + /** |
|
18 | + * |
|
19 | + * @var string the name of the field containing the meta key |
|
20 | + */ |
|
21 | + protected $_key_field_name = null; |
|
22 | 22 | |
23 | - /** |
|
24 | - * |
|
25 | - * @var string the name of the field containing the meta value |
|
26 | - */ |
|
27 | - protected $_value_field_name = null; |
|
23 | + /** |
|
24 | + * |
|
25 | + * @var string the name of the field containing the meta value |
|
26 | + */ |
|
27 | + protected $_value_field_name = null; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Accepts the name of the field that indicates whether or not an object is a "system" one or not |
|
31 | - * @param string $key_field_name |
|
32 | - * @param string $value_field_name |
|
33 | - */ |
|
34 | - public function __construct($key_field_name, $value_field_name) |
|
35 | - { |
|
36 | - $this->_key_field_name = $key_field_name; |
|
37 | - $this->_value_field_name = $value_field_name; |
|
38 | - } |
|
29 | + /** |
|
30 | + * Accepts the name of the field that indicates whether or not an object is a "system" one or not |
|
31 | + * @param string $key_field_name |
|
32 | + * @param string $value_field_name |
|
33 | + */ |
|
34 | + public function __construct($key_field_name, $value_field_name) |
|
35 | + { |
|
36 | + $this->_key_field_name = $key_field_name; |
|
37 | + $this->_value_field_name = $value_field_name; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * |
|
43 | - * @return \EE_Default_Where_Conditions |
|
44 | - * @throws EE_Error |
|
45 | - */ |
|
46 | - protected function _generate_restrictions() |
|
47 | - { |
|
48 | - $whitelisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__whitelisted_meta_keys', array()); |
|
49 | - $blacklisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__blacklisted_meta_keys', array()); |
|
50 | - $conditions = array( |
|
51 | - $this->_key_field_name => array( 'NOT_LIKE', "\\\\_%" ),// each slash is escaped because we are using double quotes, and |
|
52 | - // stripslashes will be called on this because the models assume this is from user input |
|
53 | - $this->_value_field_name => array( 'NOT_REGEXP', '^[aOs]:[\d]:.*$') |
|
54 | - ); |
|
55 | - if (! empty($blacklisted_meta_keys)) { |
|
56 | - $conditions[ $this->_key_field_name . '*blacklisted' ] = array( 'NOT_IN', $blacklisted_meta_keys ); |
|
57 | - } |
|
58 | - if (! empty($whitelisted_meta_keys)) { |
|
59 | - $conditions = array( |
|
60 | - 'OR*whitelisted-or-normal' => array( |
|
61 | - 'AND' => $conditions, |
|
62 | - $this->_key_field_name . '*whitelisted' => array( 'IN', $whitelisted_meta_keys ) |
|
63 | - ) |
|
64 | - ); |
|
65 | - } |
|
66 | - return array( |
|
67 | - // only allow access to non-protected metas if they're an admin |
|
68 | - EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(), |
|
69 | - // don't allow access to protected metas to anyone. If they want that, don't apply caps to the query |
|
70 | - 'apply-to-all-queries-using-caps' => new EE_Default_Where_Conditions($conditions), |
|
71 | - ); |
|
72 | - } |
|
41 | + /** |
|
42 | + * |
|
43 | + * @return \EE_Default_Where_Conditions |
|
44 | + * @throws EE_Error |
|
45 | + */ |
|
46 | + protected function _generate_restrictions() |
|
47 | + { |
|
48 | + $whitelisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__whitelisted_meta_keys', array()); |
|
49 | + $blacklisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__blacklisted_meta_keys', array()); |
|
50 | + $conditions = array( |
|
51 | + $this->_key_field_name => array( 'NOT_LIKE', "\\\\_%" ),// each slash is escaped because we are using double quotes, and |
|
52 | + // stripslashes will be called on this because the models assume this is from user input |
|
53 | + $this->_value_field_name => array( 'NOT_REGEXP', '^[aOs]:[\d]:.*$') |
|
54 | + ); |
|
55 | + if (! empty($blacklisted_meta_keys)) { |
|
56 | + $conditions[ $this->_key_field_name . '*blacklisted' ] = array( 'NOT_IN', $blacklisted_meta_keys ); |
|
57 | + } |
|
58 | + if (! empty($whitelisted_meta_keys)) { |
|
59 | + $conditions = array( |
|
60 | + 'OR*whitelisted-or-normal' => array( |
|
61 | + 'AND' => $conditions, |
|
62 | + $this->_key_field_name . '*whitelisted' => array( 'IN', $whitelisted_meta_keys ) |
|
63 | + ) |
|
64 | + ); |
|
65 | + } |
|
66 | + return array( |
|
67 | + // only allow access to non-protected metas if they're an admin |
|
68 | + EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(), |
|
69 | + // don't allow access to protected metas to anyone. If they want that, don't apply caps to the query |
|
70 | + 'apply-to-all-queries-using-caps' => new EE_Default_Where_Conditions($conditions), |
|
71 | + ); |
|
72 | + } |
|
73 | 73 | } |
@@ -48,18 +48,18 @@ |
||
48 | 48 | $whitelisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__whitelisted_meta_keys', array()); |
49 | 49 | $blacklisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__blacklisted_meta_keys', array()); |
50 | 50 | $conditions = array( |
51 | - $this->_key_field_name => array( 'NOT_LIKE', "\\\\_%" ),// each slash is escaped because we are using double quotes, and |
|
51 | + $this->_key_field_name => array('NOT_LIKE', "\\\\_%"), // each slash is escaped because we are using double quotes, and |
|
52 | 52 | // stripslashes will be called on this because the models assume this is from user input |
53 | - $this->_value_field_name => array( 'NOT_REGEXP', '^[aOs]:[\d]:.*$') |
|
53 | + $this->_value_field_name => array('NOT_REGEXP', '^[aOs]:[\d]:.*$') |
|
54 | 54 | ); |
55 | - if (! empty($blacklisted_meta_keys)) { |
|
56 | - $conditions[ $this->_key_field_name . '*blacklisted' ] = array( 'NOT_IN', $blacklisted_meta_keys ); |
|
55 | + if ( ! empty($blacklisted_meta_keys)) { |
|
56 | + $conditions[$this->_key_field_name.'*blacklisted'] = array('NOT_IN', $blacklisted_meta_keys); |
|
57 | 57 | } |
58 | - if (! empty($whitelisted_meta_keys)) { |
|
58 | + if ( ! empty($whitelisted_meta_keys)) { |
|
59 | 59 | $conditions = array( |
60 | 60 | 'OR*whitelisted-or-normal' => array( |
61 | 61 | 'AND' => $conditions, |
62 | - $this->_key_field_name . '*whitelisted' => array( 'IN', $whitelisted_meta_keys ) |
|
62 | + $this->_key_field_name.'*whitelisted' => array('IN', $whitelisted_meta_keys) |
|
63 | 63 | ) |
64 | 64 | ); |
65 | 65 | } |