Completed
Branch BUG/fix-ee-rest-debug-headers (1355bc)
by
unknown
03:38 queued 19s
created
core/db_models/fields/EE_Foreign_Key_String_Field.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -3,17 +3,17 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Primary_Key_String_Field.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -3,22 +3,22 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Restriction_Generator_Global.strategy.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,21 +43,21 @@
 block discarded – undo
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
                 ))
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -19,47 +19,47 @@
 block discarded – undo
19 19
  */
20 20
 class EE_Restriction_Generator_Global extends EE_Restriction_Generator_Base
21 21
 {
22
-    /**
23
-     * name of the model field that indicates whether or not a model object is "global"
24
-     * @var string
25
-     */
26
-    protected $_global_field_name;
27
-    /**
28
-     *
29
-     * @param string $global_field_name name of the model field that indicates whether or not
30
-     * a model object is "global"
31
-     */
32
-    public function __construct($global_field_name)
33
-    {
34
-        $this->_global_field_name = $global_field_name;
35
-    }
22
+	/**
23
+	 * name of the model field that indicates whether or not a model object is "global"
24
+	 * @var string
25
+	 */
26
+	protected $_global_field_name;
27
+	/**
28
+	 *
29
+	 * @param string $global_field_name name of the model field that indicates whether or not
30
+	 * a model object is "global"
31
+	 */
32
+	public function __construct($global_field_name)
33
+	{
34
+		$this->_global_field_name = $global_field_name;
35
+	}
36 36
 
37
-    /**
38
-     * @return \EE_Default_Where_Conditions
39
-     */
40
-    protected function _generate_restrictions()
41
-    {
37
+	/**
38
+	 * @return \EE_Default_Where_Conditions
39
+	 */
40
+	protected function _generate_restrictions()
41
+	{
42 42
 
43
-        // if there are no standard caps for this model, then for now all we know is
44
-        // if they need the default cap to access this
45
-        if (! $this->model()->cap_slug()) {
46
-            return array(
47
-                EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions()
48
-            );
49
-        }
50
-        return array(
51
-            EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Return_None_Where_Conditions(),
52
-            EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => new EE_Default_Where_Conditions(array(
53
-                // I need to be the owner, or it must be a global item
54
-                'OR*no_' . 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->_global_field_name                                => true
57
-                )
58
-            )),
59
-            EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_global') => new EE_Default_Where_Conditions(array(
60
-                    // it mustn't be global
61
-                    $this->_global_field_name => false
62
-                ))
63
-        );
64
-    }
43
+		// if there are no standard caps for this model, then for now all we know is
44
+		// if they need the default cap to access this
45
+		if (! $this->model()->cap_slug()) {
46
+			return array(
47
+				EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions()
48
+			);
49
+		}
50
+		return array(
51
+			EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Return_None_Where_Conditions(),
52
+			EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') => new EE_Default_Where_Conditions(array(
53
+				// I need to be the owner, or it must be a global item
54
+				'OR*no_' . 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->_global_field_name                                => true
57
+				)
58
+			)),
59
+			EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_global') => new EE_Default_Where_Conditions(array(
60
+					// it mustn't be global
61
+					$this->_global_field_name => false
62
+				))
63
+		);
64
+	}
65 65
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Restriction_Generator_Protected.strategy.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -24,48 +24,48 @@
 block discarded – undo
24 24
  */
25 25
 class EE_Restriction_Generator_Protected extends EE_Restriction_Generator_Base
26 26
 {
27
-    /**
28
-     * @return \EE_Default_Where_Conditions
29
-     */
30
-    protected function _generate_restrictions()
31
-    {
27
+	/**
28
+	 * @return \EE_Default_Where_Conditions
29
+	 */
30
+	protected function _generate_restrictions()
31
+	{
32 32
 
33
-        // if there are no standard caps for this model, then for now all we know
34
-        // if they need the default cap to access this
35
-        if (! $this->model()->cap_slug()) {
36
-            return array(
37
-                EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions()
38
-            );
39
-        }
33
+		// if there are no standard caps for this model, then for now all we know
34
+		// if they need the default cap to access this
35
+		if (! $this->model()->cap_slug()) {
36
+			return array(
37
+				EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions()
38
+			);
39
+		}
40 40
 
41
-        $restrictions = array();
42
-        // does the basic cap exist? (eg 'ee_read_registrations')
43
-        if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action())) {
44
-            $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) ] = new EE_Return_None_Where_Conditions();
45
-            // does the others cap exist? (eg 'ee_read_others_registrations')
46
-            if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others')) {// both caps exist
47
-                $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') ] = new EE_Default_Where_Conditions(
48
-                    array(
49
-                        EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder
50
-                    )
51
-                );
52
-                // does the private cap exist (eg 'ee_read_others_private_events')
53
-                if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_private') && $this->model() instanceof EEM_CPT_Base) {
54
-                    // if they have basic and others, but not private, restrict them to see theirs and others' that aren't private
55
-                    $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') ] = new EE_Default_Where_Conditions(
56
-                        array(
57
-                            'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') => array(
58
-                                EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder,
59
-                                'status' => array( '!=', 'private' )
60
-                            )
61
-                        )
62
-                    );
63
-                }
64
-            }
65
-        } else {
66
-            // there is no basic cap. So they can only access this if they have the default admin cap
67
-            $restrictions[ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] = new EE_Return_None_Where_Conditions();
68
-        }
69
-        return $restrictions;
70
-    }
41
+		$restrictions = array();
42
+		// does the basic cap exist? (eg 'ee_read_registrations')
43
+		if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action())) {
44
+			$restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) ] = new EE_Return_None_Where_Conditions();
45
+			// does the others cap exist? (eg 'ee_read_others_registrations')
46
+			if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others')) {// both caps exist
47
+				$restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others') ] = new EE_Default_Where_Conditions(
48
+					array(
49
+						EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder
50
+					)
51
+				);
52
+				// does the private cap exist (eg 'ee_read_others_private_events')
53
+				if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_private') && $this->model() instanceof EEM_CPT_Base) {
54
+					// if they have basic and others, but not private, restrict them to see theirs and others' that aren't private
55
+					$restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') ] = new EE_Default_Where_Conditions(
56
+						array(
57
+							'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_private') => array(
58
+								EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder,
59
+								'status' => array( '!=', 'private' )
60
+							)
61
+						)
62
+					);
63
+				}
64
+			}
65
+		} else {
66
+			// there is no basic cap. So they can only access this if they have the default admin cap
67
+			$restrictions[ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] = new EE_Return_None_Where_Conditions();
68
+		}
69
+		return $restrictions;
70
+	}
71 71
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Restriction_Generator_Meta.strategy.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -48,18 +48,18 @@
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -13,60 +13,60 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Restriction_Generator_Meta extends EE_Restriction_Generator_Base
15 15
 {
16
-    /**
17
-     *
18
-     * @var string the name of the field containing the meta key
19
-     */
20
-    protected $_key_field_name = null;
16
+	/**
17
+	 *
18
+	 * @var string the name of the field containing the meta key
19
+	 */
20
+	protected $_key_field_name = null;
21 21
 
22
-    /**
23
-     *
24
-     * @var string the name of the field containing the meta value
25
-     */
26
-    protected $_value_field_name = null;
22
+	/**
23
+	 *
24
+	 * @var string the name of the field containing the meta value
25
+	 */
26
+	protected $_value_field_name = null;
27 27
 
28
-    /**
29
-     * Accepts the name of the field that indicates whether or not an object is a "system" one or not
30
-     * @param string $key_field_name
31
-     * @param string $value_field_name
32
-     */
33
-    public function __construct($key_field_name, $value_field_name)
34
-    {
35
-        $this->_key_field_name = $key_field_name;
36
-        $this->_value_field_name = $value_field_name;
37
-    }
28
+	/**
29
+	 * Accepts the name of the field that indicates whether or not an object is a "system" one or not
30
+	 * @param string $key_field_name
31
+	 * @param string $value_field_name
32
+	 */
33
+	public function __construct($key_field_name, $value_field_name)
34
+	{
35
+		$this->_key_field_name = $key_field_name;
36
+		$this->_value_field_name = $value_field_name;
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     *
42
-     * @return \EE_Default_Where_Conditions
43
-     * @throws EE_Error
44
-     */
45
-    protected function _generate_restrictions()
46
-    {
47
-        $whitelisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__whitelisted_meta_keys', array());
48
-        $blacklisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__blacklisted_meta_keys', array());
49
-        $conditions = array(
50
-            $this->_key_field_name => array( 'NOT_LIKE', "\\\\_%" ),// each slash is escaped because we are using double quotes, and
51
-            // stripslashes will be called on this because the models assume this is from user input
52
-            $this->_value_field_name => array( 'NOT_REGEXP', '^[aOs]:[\d]:.*$')
53
-        );
54
-        if (! empty($blacklisted_meta_keys)) {
55
-            $conditions[ $this->_key_field_name . '*blacklisted' ] = array( 'NOT_IN', $blacklisted_meta_keys );
56
-        }
57
-        if (! empty($whitelisted_meta_keys)) {
58
-            $conditions = array(
59
-                'OR*whitelisted-or-normal' => array(
60
-                    'AND' => $conditions,
61
-                    $this->_key_field_name . '*whitelisted' => array( 'IN', $whitelisted_meta_keys )
62
-                )
63
-            );
64
-        }
65
-        return array(
66
-            // only allow access to non-protected metas if they're an admin
67
-            EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(),
68
-            // don't allow access to protected metas to anyone. If they want that, don't apply caps to the query
69
-            'apply-to-all-queries-using-caps' => new EE_Default_Where_Conditions($conditions),
70
-        );
71
-    }
40
+	/**
41
+	 *
42
+	 * @return \EE_Default_Where_Conditions
43
+	 * @throws EE_Error
44
+	 */
45
+	protected function _generate_restrictions()
46
+	{
47
+		$whitelisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__whitelisted_meta_keys', array());
48
+		$blacklisted_meta_keys = apply_filters('FHEE__EE_Restriction_Generator_Meta___generate_restrictions__blacklisted_meta_keys', array());
49
+		$conditions = array(
50
+			$this->_key_field_name => array( 'NOT_LIKE', "\\\\_%" ),// each slash is escaped because we are using double quotes, and
51
+			// stripslashes will be called on this because the models assume this is from user input
52
+			$this->_value_field_name => array( 'NOT_REGEXP', '^[aOs]:[\d]:.*$')
53
+		);
54
+		if (! empty($blacklisted_meta_keys)) {
55
+			$conditions[ $this->_key_field_name . '*blacklisted' ] = array( 'NOT_IN', $blacklisted_meta_keys );
56
+		}
57
+		if (! empty($whitelisted_meta_keys)) {
58
+			$conditions = array(
59
+				'OR*whitelisted-or-normal' => array(
60
+					'AND' => $conditions,
61
+					$this->_key_field_name . '*whitelisted' => array( 'IN', $whitelisted_meta_keys )
62
+				)
63
+			);
64
+		}
65
+		return array(
66
+			// only allow access to non-protected metas if they're an admin
67
+			EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(),
68
+			// don't allow access to protected metas to anyone. If they want that, don't apply caps to the query
69
+			'apply-to-all-queries-using-caps' => new EE_Default_Where_Conditions($conditions),
70
+		);
71
+	}
72 72
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Restriction_Generator_Reg_Form.strategy.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     {
41 41
         // if there are no standard caps for this model, then for now all we know
42 42
         // if they need the default cap to access this
43
-        if (! $this->model()->cap_slug()) {
43
+        if ( ! $this->model()->cap_slug()) {
44 44
             return array(
45 45
                 EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions()
46 46
             );
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
         // there is no "ee_read_system_questions" cap; in order to read reg form items you only need "ee_read_{model_name}".
52 52
         // there is also no "ee_delete_system_questions" cap. But folks shouldn't be deleting system questions anyway
53 53
         if ($this->action() !== EEM_Base::caps_read) {
54
-            $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_system') ] = new EE_Default_Where_Conditions(
54
+            $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_system')] = new EE_Default_Where_Conditions(
55 55
                 array(
56
-                    'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_system') => array(
56
+                    'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_system') => array(
57 57
                         $this->_system_field_name       => array('IN', array('', 0)),
58
-                        $this->_system_field_name . '*' => array('IS_NULL')
58
+                        $this->_system_field_name.'*' => array('IS_NULL')
59 59
                     )
60 60
                 )
61 61
             );
Please login to merge, or discard this patch.
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -14,51 +14,51 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Restriction_Generator_Reg_Form extends EE_Restriction_Generator_Base
16 16
 {
17
-    /**
18
-     *
19
-     * @var string the name of the field that indicates whether or not this is a system thing
20
-     */
21
-    protected $_system_field_name = null;
17
+	/**
18
+	 *
19
+	 * @var string the name of the field that indicates whether or not this is a system thing
20
+	 */
21
+	protected $_system_field_name = null;
22 22
 
23
-    /**
24
-     * Accepts the name of the field that indicates whether or not an object is a "system" one or not
25
-     * @param string $system_field_name
26
-     */
27
-    public function __construct($system_field_name)
28
-    {
29
-        $this->_system_field_name = $system_field_name;
30
-    }
23
+	/**
24
+	 * Accepts the name of the field that indicates whether or not an object is a "system" one or not
25
+	 * @param string $system_field_name
26
+	 */
27
+	public function __construct($system_field_name)
28
+	{
29
+		$this->_system_field_name = $system_field_name;
30
+	}
31 31
 
32 32
 
33
-    /**
34
-     *
35
-     * @return \EE_Default_Where_Conditions[]
36
-     * @throws EE_Error
37
-     */
38
-    protected function _generate_restrictions()
39
-    {
40
-        // if there are no standard caps for this model, then for now all we know
41
-        // if they need the default cap to access this
42
-        if (! $this->model()->cap_slug()) {
43
-            return array(
44
-                EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions()
45
-            );
46
-        }
47
-        $restrictions = array(
48
-            EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Return_None_Where_Conditions(),
49
-        );
50
-        // there is no "ee_read_system_questions" cap; in order to read reg form items you only need "ee_read_{model_name}".
51
-        // there is also no "ee_delete_system_questions" cap. But folks shouldn't be deleting system questions anyway
52
-        if ($this->action() !== EEM_Base::caps_read) {
53
-            $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_system') ] = new EE_Default_Where_Conditions(
54
-                array(
55
-                    'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_system') => array(
56
-                        $this->_system_field_name       => array('IN', array('', 0)),
57
-                        $this->_system_field_name . '*' => array('IS_NULL')
58
-                    )
59
-                )
60
-            );
61
-        }
62
-        return $restrictions;
63
-    }
33
+	/**
34
+	 *
35
+	 * @return \EE_Default_Where_Conditions[]
36
+	 * @throws EE_Error
37
+	 */
38
+	protected function _generate_restrictions()
39
+	{
40
+		// if there are no standard caps for this model, then for now all we know
41
+		// if they need the default cap to access this
42
+		if (! $this->model()->cap_slug()) {
43
+			return array(
44
+				EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions()
45
+			);
46
+		}
47
+		$restrictions = array(
48
+			EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Return_None_Where_Conditions(),
49
+		);
50
+		// there is no "ee_read_system_questions" cap; in order to read reg form items you only need "ee_read_{model_name}".
51
+		// there is also no "ee_delete_system_questions" cap. But folks shouldn't be deleting system questions anyway
52
+		if ($this->action() !== EEM_Base::caps_read) {
53
+			$restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_system') ] = new EE_Default_Where_Conditions(
54
+				array(
55
+					'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_system') => array(
56
+						$this->_system_field_name       => array('IN', array('', 0)),
57
+						$this->_system_field_name . '*' => array('IS_NULL')
58
+					)
59
+				)
60
+			);
61
+		}
62
+		return $restrictions;
63
+	}
64 64
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_CPT_Where_Conditions.strategy.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
         return array_merge(
26 26
             parent::_get_default_where_conditions(),
27 27
             array(
28
-                $status_field->get_name() => array('NOT IN',array('auto-draft','trash') )
28
+                $status_field->get_name() => array('NOT IN', array('auto-draft', 'trash'))
29 29
             )
30 30
         );
31 31
     }
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 /**
4 4
  *
5 5
  * Class EE_Default_Where_Conditions
6
-  *
6
+ *
7 7
  * Strategy specifically for adding where conditions specific to CPT models.
8 8
  *
9 9
  * @package         Event Espresso
@@ -14,19 +14,19 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions
16 16
 {
17
-    /**
18
-     * Gets the where default where conditions for a custom post type model
19
-     * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment"
20
-     * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
21
-     */
22
-    protected function _get_default_where_conditions()
23
-    {
24
-        $status_field = $this->_get_field_on_column('post_status');
25
-        return array_merge(
26
-            parent::_get_default_where_conditions(),
27
-            array(
28
-                $status_field->get_name() => array('NOT IN',array('auto-draft','trash') )
29
-            )
30
-        );
31
-    }
17
+	/**
18
+	 * Gets the where default where conditions for a custom post type model
19
+	 * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment"
20
+	 * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
21
+	 */
22
+	protected function _get_default_where_conditions()
23
+	{
24
+		$status_field = $this->_get_field_on_column('post_status');
25
+		return array_merge(
26
+			parent::_get_default_where_conditions(),
27
+			array(
28
+				$status_field->get_name() => array('NOT IN',array('auto-draft','trash') )
29
+			)
30
+		);
31
+	}
32 32
 }
Please login to merge, or discard this patch.
strategies/EE_Restriction_Generator_Taxonomy_Protected.strategy.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,20 +32,20 @@
 block discarded – undo
32 32
     protected function _generate_restrictions()
33 33
     {
34 34
         // if there are no standard caps for this model, then for allow full access
35
-        if (! $this->model()->cap_slug()) {
35
+        if ( ! $this->model()->cap_slug()) {
36 36
             return array(
37 37
             );
38 38
         }
39 39
 
40 40
         return array(
41 41
             'ee_manage_event_categories' => new EE_Default_Where_Conditions(array(
42
-                $this->_path_to_taxonomy_model . 'taxonomy*no_ee_manage_event_categories' => array( '!=', 'espresso_event_categories' )
42
+                $this->_path_to_taxonomy_model.'taxonomy*no_ee_manage_event_categories' => array('!=', 'espresso_event_categories')
43 43
             )),
44 44
             'ee_manage_venue_categories' => new EE_Default_Where_Conditions(array(
45
-                $this->_path_to_taxonomy_model . 'taxonomy*no_ee_manage_venue_categories' => array( '!=', 'espresso_venue_categories' )
45
+                $this->_path_to_taxonomy_model.'taxonomy*no_ee_manage_venue_categories' => array('!=', 'espresso_venue_categories')
46 46
             )),
47 47
             'ee_manage_event_types' => new EE_Default_Where_Conditions(array(
48
-                $this->_path_to_taxonomy_model . 'taxonomy*ee_manage_event_types' => array( '!=', 'espresso_event_types' )
48
+                $this->_path_to_taxonomy_model.'taxonomy*ee_manage_event_types' => array('!=', 'espresso_event_types')
49 49
             )),
50 50
         );
51 51
     }
Please login to merge, or discard this patch.
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -12,40 +12,40 @@
 block discarded – undo
12 12
  */
13 13
 class EE_Restriction_Generator_Taxonomy_Protected extends EE_Restriction_Generator_Base
14 14
 {
15
-    /**
16
-     * Model chain/path to taxonomy model, including the term_taxonomy model itself
17
-     * @var string
18
-     */
19
-    protected $_path_to_taxonomy_model;
20
-    /**
21
-     *
22
-     * @param string $path_to_taxonomy_model Model chain/path to taxonomy model, including the term_taxonomy model itself
23
-     */
24
-    public function __construct($path_to_taxonomy_model)
25
-    {
26
-        if ($path_to_taxonomy_model !== '' && substr($path_to_taxonomy_model, -1, 1) != '.') {
27
-            $path_to_taxonomy_model .= '.';
28
-        }
29
-        $this->_path_to_taxonomy_model = $path_to_taxonomy_model;
30
-    }
31
-    protected function _generate_restrictions()
32
-    {
33
-        // if there are no standard caps for this model, then for allow full access
34
-        if (! $this->model()->cap_slug()) {
35
-            return array(
36
-            );
37
-        }
15
+	/**
16
+	 * Model chain/path to taxonomy model, including the term_taxonomy model itself
17
+	 * @var string
18
+	 */
19
+	protected $_path_to_taxonomy_model;
20
+	/**
21
+	 *
22
+	 * @param string $path_to_taxonomy_model Model chain/path to taxonomy model, including the term_taxonomy model itself
23
+	 */
24
+	public function __construct($path_to_taxonomy_model)
25
+	{
26
+		if ($path_to_taxonomy_model !== '' && substr($path_to_taxonomy_model, -1, 1) != '.') {
27
+			$path_to_taxonomy_model .= '.';
28
+		}
29
+		$this->_path_to_taxonomy_model = $path_to_taxonomy_model;
30
+	}
31
+	protected function _generate_restrictions()
32
+	{
33
+		// if there are no standard caps for this model, then for allow full access
34
+		if (! $this->model()->cap_slug()) {
35
+			return array(
36
+			);
37
+		}
38 38
 
39
-        return array(
40
-            'ee_manage_event_categories' => new EE_Default_Where_Conditions(array(
41
-                $this->_path_to_taxonomy_model . 'taxonomy*no_ee_manage_event_categories' => array( '!=', 'espresso_event_categories' )
42
-            )),
43
-            'ee_manage_venue_categories' => new EE_Default_Where_Conditions(array(
44
-                $this->_path_to_taxonomy_model . 'taxonomy*no_ee_manage_venue_categories' => array( '!=', 'espresso_venue_categories' )
45
-            )),
46
-            'ee_manage_event_types' => new EE_Default_Where_Conditions(array(
47
-                $this->_path_to_taxonomy_model . 'taxonomy*ee_manage_event_types' => array( '!=', 'espresso_event_types' )
48
-            )),
49
-        );
50
-    }
39
+		return array(
40
+			'ee_manage_event_categories' => new EE_Default_Where_Conditions(array(
41
+				$this->_path_to_taxonomy_model . 'taxonomy*no_ee_manage_event_categories' => array( '!=', 'espresso_event_categories' )
42
+			)),
43
+			'ee_manage_venue_categories' => new EE_Default_Where_Conditions(array(
44
+				$this->_path_to_taxonomy_model . 'taxonomy*no_ee_manage_venue_categories' => array( '!=', 'espresso_venue_categories' )
45
+			)),
46
+			'ee_manage_event_types' => new EE_Default_Where_Conditions(array(
47
+				$this->_path_to_taxonomy_model . 'taxonomy*ee_manage_event_types' => array( '!=', 'espresso_event_types' )
48
+			)),
49
+		);
50
+	}
51 51
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Return_None_Where_Conditions.strategy.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@
 block discarded – undo
12 12
  */
13 13
 class EE_Return_None_Where_Conditions extends EE_Default_Where_Conditions
14 14
 {
15
-    protected function _get_default_where_conditions()
16
-    {
17
-        if ($this->_model->has_primary_key_field()) {
18
-            return array( $this->_model->primary_key_name() => array('<', 0 ) );
19
-        } else {
20
-            $fk_field = $this->_model->get_a_field_of_type('EE_Foreign_Key_Field_Base');
21
-            return array( 'AND*impossible' => array( $fk_field->get_name() => array('IS_NULL'), $fk_field->get_name() => 'IS_NOT_NULL' ) );
22
-        }
23
-    }
15
+	protected function _get_default_where_conditions()
16
+	{
17
+		if ($this->_model->has_primary_key_field()) {
18
+			return array( $this->_model->primary_key_name() => array('<', 0 ) );
19
+		} else {
20
+			$fk_field = $this->_model->get_a_field_of_type('EE_Foreign_Key_Field_Base');
21
+			return array( 'AND*impossible' => array( $fk_field->get_name() => array('IS_NULL'), $fk_field->get_name() => 'IS_NOT_NULL' ) );
22
+		}
23
+	}
24 24
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@
 block discarded – undo
15 15
     protected function _get_default_where_conditions()
16 16
     {
17 17
         if ($this->_model->has_primary_key_field()) {
18
-            return array( $this->_model->primary_key_name() => array('<', 0 ) );
18
+            return array($this->_model->primary_key_name() => array('<', 0));
19 19
         } else {
20 20
             $fk_field = $this->_model->get_a_field_of_type('EE_Foreign_Key_Field_Base');
21
-            return array( 'AND*impossible' => array( $fk_field->get_name() => array('IS_NULL'), $fk_field->get_name() => 'IS_NOT_NULL' ) );
21
+            return array('AND*impossible' => array($fk_field->get_name() => array('IS_NULL'), $fk_field->get_name() => 'IS_NOT_NULL'));
22 22
         }
23 23
     }
24 24
 }
Please login to merge, or discard this patch.