Completed
Branch EDTR/master (af42c6)
by
unknown
50:36 queued 42:13
created
core/db_models/fields/EE_Maybe_Serialized_Simple_HTML_Field.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -11,59 +11,59 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
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());
Please login to merge, or discard this patch.
core/db_models/fields/EE_DB_Only_Field_Base.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -10,28 +10,28 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
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_Enum_Text_Field.php 2 patches
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -11,130 +11,130 @@
 block discarded – undo
11 11
 class EE_Enum_Text_Field extends EE_Text_Field_Base
12 12
 {
13 13
 
14
-    /**
15
-     * @var array $_allowed_enum_values
16
-     */
17
-    public $_allowed_enum_values;
18
-
19
-    /**
20
-     * @param string  $table_column
21
-     * @param string  $nice_name
22
-     * @param boolean $nullable
23
-     * @param mixed   $default_value
24
-     * @param array   $allowed_enum_values keys are values to be used in the DB, values are how they should be displayed
25
-     */
26
-    public function __construct($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values)
27
-    {
28
-        $this->_allowed_enum_values = $allowed_enum_values;
29
-        parent::__construct($table_column, $nice_name, $nullable, $default_value);
30
-        $this->setSchemaType('object');
31
-    }
32
-
33
-
34
-
35
-    /**
36
-     * Returns the list of allowed enum options, but filterable.
37
-     * This is used internally
38
-     *
39
-     * @return array
40
-     */
41
-    protected function _allowed_enum_values()
42
-    {
43
-        return apply_filters(
44
-            'FHEE__EE_Enum_Text_Field___allowed_enum_options',
45
-            $this->_allowed_enum_values,
46
-            $this
47
-        );
48
-    }
49
-
50
-
51
-
52
-    /**
53
-     * When setting, just verify that the value being used matches what we've defined as allowable enum values.
54
-     * If not, throw an error (but if WP_DEBUG is false, just set the value to default).
55
-     *
56
-     * @param string $value_inputted_for_field_on_model_object
57
-     * @return string
58
-     * @throws EE_Error
59
-     */
60
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
61
-    {
62
-        if ($value_inputted_for_field_on_model_object !== null
63
-            && ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values())
64
-        ) {
65
-            if (defined('WP_DEBUG') && WP_DEBUG) {
66
-                $msg = sprintf(
67
-                    __('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
68
-                    $value_inputted_for_field_on_model_object,
69
-                    $this->_name
70
-                );
71
-                $msg2 = sprintf(
72
-                    __('Allowed values for "%1$s" are "%2$s". You provided: "%3$s"', 'event_espresso'),
73
-                    $this->_name,
74
-                    implode(', ', array_keys($this->_allowed_enum_values())),
75
-                    $value_inputted_for_field_on_model_object
76
-                );
77
-                EE_Error::add_error("{$msg}||{$msg2}", __FILE__, __FUNCTION__, __LINE__);
78
-            }
79
-            return $this->get_default_value();
80
-        }
81
-        return $value_inputted_for_field_on_model_object;
82
-    }
83
-
84
-
85
-    /**
86
-     * Gets the pretty version of the enum's value.
87
-     *
88
-     * @param     int |string $value_on_field_to_be_outputted
89
-     * @param    null         $schema
90
-     * @return    string
91
-     */
92
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
93
-    {
94
-        $options = $this->_allowed_enum_values();
95
-        if (isset($options[ $value_on_field_to_be_outputted ])) {
96
-            return $options[ $value_on_field_to_be_outputted ];
97
-        } else {
98
-            return $value_on_field_to_be_outputted;
99
-        }
100
-    }
101
-
102
-
103
-
104
-    /**
105
-     * When retrieving something from the DB, don't enforce the enum's options. If it's in the DB, we just have to live
106
-     * with that. Note also: when we're saving to the DB again, we also don't enforce the enum options. It's ONLY
107
-     * when we're receiving USER input from prepare_for_set() that we enforce the enum options.
108
-     *
109
-     * @param mixed $value_in_db
110
-     * @return mixed
111
-     */
112
-    public function prepare_for_set_from_db($value_in_db)
113
-    {
114
-        return $value_in_db;
115
-    }
116
-
117
-
118
-    public function getSchemaProperties()
119
-    {
120
-        return array(
121
-            'raw' => array(
122
-                'description' =>  sprintf(
123
-                    __('%s - the value in the database.', 'event_espresso'),
124
-                    $this->get_nicename()
125
-                ),
126
-                'type' => 'string',
127
-                'enum' => array_keys($this->_allowed_enum_values)
128
-            ),
129
-            'pretty' => array(
130
-                'description' =>  sprintf(
131
-                    __('%s - the value for display.', 'event_espresso'),
132
-                    $this->get_nicename()
133
-                ),
134
-                'type' => 'string',
135
-                'enum' => array_values($this->_allowed_enum_values),
136
-                'read_only' => true
137
-            )
138
-        );
139
-    }
14
+	/**
15
+	 * @var array $_allowed_enum_values
16
+	 */
17
+	public $_allowed_enum_values;
18
+
19
+	/**
20
+	 * @param string  $table_column
21
+	 * @param string  $nice_name
22
+	 * @param boolean $nullable
23
+	 * @param mixed   $default_value
24
+	 * @param array   $allowed_enum_values keys are values to be used in the DB, values are how they should be displayed
25
+	 */
26
+	public function __construct($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values)
27
+	{
28
+		$this->_allowed_enum_values = $allowed_enum_values;
29
+		parent::__construct($table_column, $nice_name, $nullable, $default_value);
30
+		$this->setSchemaType('object');
31
+	}
32
+
33
+
34
+
35
+	/**
36
+	 * Returns the list of allowed enum options, but filterable.
37
+	 * This is used internally
38
+	 *
39
+	 * @return array
40
+	 */
41
+	protected function _allowed_enum_values()
42
+	{
43
+		return apply_filters(
44
+			'FHEE__EE_Enum_Text_Field___allowed_enum_options',
45
+			$this->_allowed_enum_values,
46
+			$this
47
+		);
48
+	}
49
+
50
+
51
+
52
+	/**
53
+	 * When setting, just verify that the value being used matches what we've defined as allowable enum values.
54
+	 * If not, throw an error (but if WP_DEBUG is false, just set the value to default).
55
+	 *
56
+	 * @param string $value_inputted_for_field_on_model_object
57
+	 * @return string
58
+	 * @throws EE_Error
59
+	 */
60
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
61
+	{
62
+		if ($value_inputted_for_field_on_model_object !== null
63
+			&& ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values())
64
+		) {
65
+			if (defined('WP_DEBUG') && WP_DEBUG) {
66
+				$msg = sprintf(
67
+					__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
68
+					$value_inputted_for_field_on_model_object,
69
+					$this->_name
70
+				);
71
+				$msg2 = sprintf(
72
+					__('Allowed values for "%1$s" are "%2$s". You provided: "%3$s"', 'event_espresso'),
73
+					$this->_name,
74
+					implode(', ', array_keys($this->_allowed_enum_values())),
75
+					$value_inputted_for_field_on_model_object
76
+				);
77
+				EE_Error::add_error("{$msg}||{$msg2}", __FILE__, __FUNCTION__, __LINE__);
78
+			}
79
+			return $this->get_default_value();
80
+		}
81
+		return $value_inputted_for_field_on_model_object;
82
+	}
83
+
84
+
85
+	/**
86
+	 * Gets the pretty version of the enum's value.
87
+	 *
88
+	 * @param     int |string $value_on_field_to_be_outputted
89
+	 * @param    null         $schema
90
+	 * @return    string
91
+	 */
92
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
93
+	{
94
+		$options = $this->_allowed_enum_values();
95
+		if (isset($options[ $value_on_field_to_be_outputted ])) {
96
+			return $options[ $value_on_field_to_be_outputted ];
97
+		} else {
98
+			return $value_on_field_to_be_outputted;
99
+		}
100
+	}
101
+
102
+
103
+
104
+	/**
105
+	 * When retrieving something from the DB, don't enforce the enum's options. If it's in the DB, we just have to live
106
+	 * with that. Note also: when we're saving to the DB again, we also don't enforce the enum options. It's ONLY
107
+	 * when we're receiving USER input from prepare_for_set() that we enforce the enum options.
108
+	 *
109
+	 * @param mixed $value_in_db
110
+	 * @return mixed
111
+	 */
112
+	public function prepare_for_set_from_db($value_in_db)
113
+	{
114
+		return $value_in_db;
115
+	}
116
+
117
+
118
+	public function getSchemaProperties()
119
+	{
120
+		return array(
121
+			'raw' => array(
122
+				'description' =>  sprintf(
123
+					__('%s - the value in the database.', 'event_espresso'),
124
+					$this->get_nicename()
125
+				),
126
+				'type' => 'string',
127
+				'enum' => array_keys($this->_allowed_enum_values)
128
+			),
129
+			'pretty' => array(
130
+				'description' =>  sprintf(
131
+					__('%s - the value for display.', 'event_espresso'),
132
+					$this->get_nicename()
133
+				),
134
+				'type' => 'string',
135
+				'enum' => array_values($this->_allowed_enum_values),
136
+				'read_only' => true
137
+			)
138
+		);
139
+	}
140 140
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -89,8 +89,8 @@
 block discarded – undo
89 89
     public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
90 90
     {
91 91
         $options = $this->_allowed_enum_values();
92
-        if (isset($options[ $value_on_field_to_be_outputted ])) {
93
-            return $options[ $value_on_field_to_be_outputted ];
92
+        if (isset($options[$value_on_field_to_be_outputted])) {
93
+            return $options[$value_on_field_to_be_outputted];
94 94
         } else {
95 95
             return $value_on_field_to_be_outputted;
96 96
         }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Foreign_Key_Int_Field.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -3,36 +3,36 @@
 block discarded – undo
3 3
 class EE_Foreign_Key_Int_Field extends EE_Foreign_Key_Field_Base
4 4
 {
5 5
 
6
-    /**
7
-     * @param string  $table_column  name fo column for field
8
-     * @param string  $nicename      should eb internationalized with __('blah','event_espresso')
9
-     * @param boolean $nullable
10
-     * @param mixed   $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul
11
-     *                               dbe a string
12
-     * @param string  $model_name    eg 'Event','Answer','Term', etc. Basically its the model class's name without the
13
-     *                               "EEM_"
14
-     */
15
-    public function __construct($table_column, $nicename, $nullable, $default_value, $model_name)
16
-    {
17
-        parent::__construct($table_column, $nicename, $nullable, $default_value, $model_name);
18
-        $this->setSchemaType('integer');
19
-    }
6
+	/**
7
+	 * @param string  $table_column  name fo column for field
8
+	 * @param string  $nicename      should eb internationalized with __('blah','event_espresso')
9
+	 * @param boolean $nullable
10
+	 * @param mixed   $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul
11
+	 *                               dbe a string
12
+	 * @param string  $model_name    eg 'Event','Answer','Term', etc. Basically its the model class's name without the
13
+	 *                               "EEM_"
14
+	 */
15
+	public function __construct($table_column, $nicename, $nullable, $default_value, $model_name)
16
+	{
17
+		parent::__construct($table_column, $nicename, $nullable, $default_value, $model_name);
18
+		$this->setSchemaType('integer');
19
+	}
20 20
 
21 21
 
22
-    /**
23
-     * @param int|EE_Base_Class $value_inputted_for_field_on_model_object
24
-     * @return int
25
-     */
26
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
27
-    {
28
-        if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) {
29
-            $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID();
30
-        }
31
-        return absint($value_inputted_for_field_on_model_object);
32
-    }
22
+	/**
23
+	 * @param int|EE_Base_Class $value_inputted_for_field_on_model_object
24
+	 * @return int
25
+	 */
26
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
27
+	{
28
+		if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) {
29
+			$value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID();
30
+		}
31
+		return absint($value_inputted_for_field_on_model_object);
32
+	}
33 33
 
34
-    public function prepare_for_set_from_db($value_found_in_db_for_model_object)
35
-    {
36
-        return intval($value_found_in_db_for_model_object);
37
-    }
34
+	public function prepare_for_set_from_db($value_found_in_db_for_model_object)
35
+	{
36
+		return intval($value_found_in_db_for_model_object);
37
+	}
38 38
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Default_Where_Conditions.strategy.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -112,24 +112,24 @@  discard block
 block discarded – undo
112 112
     public function prepare_where_conditions_for_querying($where_conditions, $model_relation_chain)
113 113
     {
114 114
         $where_conditions_with_model_relation_chain_prefixes = array();
115
-        if (! is_array($where_conditions)) {
115
+        if ( ! is_array($where_conditions)) {
116 116
             $where_conditions = array();
117 117
         }
118 118
         foreach ($where_conditions as $key => $value) {
119
-            if (in_array($key, array( 'OR', 'AND', 'NOT' ))
119
+            if (in_array($key, array('OR', 'AND', 'NOT'))
120 120
                 || strpos($key, 'OR*') !== false
121 121
                 || strpos($key, 'AND*') !== false
122 122
                 || strpos($key, 'NOT*') !== false
123 123
             ) {
124
-                $where_conditions_with_model_relation_chain_prefixes[ $key ] = $this->prepare_where_conditions_for_querying(
124
+                $where_conditions_with_model_relation_chain_prefixes[$key] = $this->prepare_where_conditions_for_querying(
125 125
                     $value,
126 126
                     $model_relation_chain
127 127
                 );
128 128
             } else {
129 129
                 if ($model_relation_chain != ''
130
-                    && $model_relation_chain[ strlen($model_relation_chain) - 1 ] != '.'
130
+                    && $model_relation_chain[strlen($model_relation_chain) - 1] != '.'
131 131
                 ) {
132
-                    $model_relation_chain = $model_relation_chain . ".";
132
+                    $model_relation_chain = $model_relation_chain.".";
133 133
                 }
134 134
                 // check for the current user id place holder, and if present change it
135 135
                 if ($value === self::current_user_placeholder) {
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
                 }
138 138
                 // check for user field placeholder
139 139
                 if ($key == self::user_field_name_placeholder) {
140
-                    if (! $this->_model->wp_user_field_name()) {
140
+                    if ( ! $this->_model->wp_user_field_name()) {
141 141
                         throw new EE_Error(
142 142
                             sprintf(
143 143
                                 __(
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
                     }
151 151
                     $key = $this->_model->wp_user_field_name();
152 152
                 }
153
-                $where_conditions_with_model_relation_chain_prefixes[ $model_relation_chain . $key ] = $value;
153
+                $where_conditions_with_model_relation_chain_prefixes[$model_relation_chain.$key] = $value;
154 154
             }
155 155
         }
156 156
         return $where_conditions_with_model_relation_chain_prefixes;
Please login to merge, or discard this patch.
Indentation   +140 added lines, -140 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 to be used for getting default where conditions for EEM_Base children.
8 8
  * Should be initialized and set on construction of model
9 9
  *
@@ -16,143 +16,143 @@  discard block
 block discarded – undo
16 16
 class EE_Default_Where_Conditions
17 17
 {
18 18
 
19
-    /**
20
-     * This const can be used in EE_Default_Where_Conditions values, and at the time of querying it will be
21
-     * replaced with the current user's ID (because we don't want to use the current user's ID at time of
22
-     * initializing the models because it's too early)
23
-     */
24
-    const current_user_placeholder = '%$current_user_placeholder_should_be_replaced_automatically$%';
25
-
26
-    /**
27
-     * This const can be used in EE_Default_Where_Conditions where parameters as the name
28
-     * of the user field. When we are actually generating the where conditions it will be
29
-     * replaced with the model's wp user fieldname
30
-     */
31
-    const user_field_name_placeholder = '%$user_field_name_placeholder$%';
32
-
33
-    /**
34
-     * Model for which this strategy find default where conditions
35
-     * @var EEM_Base
36
-     */
37
-    protected $_model;
38
-
39
-    /**
40
-     * Where conditions specified on construction
41
-     * @var array
42
-     */
43
-    protected $_where_conditions_provided = array();
44
-
45
-    /**
46
-     * Custom where conditions. Model relation chains will be automatically added
47
-     * onto any field names
48
-     * @param array $custom_where_conditions
49
-     */
50
-    public function __construct($custom_where_conditions = array())
51
-    {
52
-        $this->_where_conditions_provided = $custom_where_conditions;
53
-    }
54
-
55
-
56
-
57
-    /**
58
-     * finalizes construction of the strategy for use in getting default where conditions
59
-     * for querying of the model.
60
-     * @param EEM_Base $model
61
-     */
62
-    public function _finalize_construct(EEM_Base $model)
63
-    {
64
-        $this->_model = $model;
65
-    }
66
-
67
-
68
-
69
-    /**
70
-     * Returns the where conditions explicitly passed in the constructor
71
-     * @return array
72
-     */
73
-    public function get_where_conditions_provided()
74
-    {
75
-        return $this->_where_conditions_provided;
76
-    }
77
-
78
-
79
-
80
-    /**
81
-     * Gets the where conditions to be added onto the query
82
-     * @param string $model_relation_chain
83
-     * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
84
-     */
85
-    public function get_default_where_conditions($model_relation_chain = '')
86
-    {
87
-        return $this->prepare_where_conditions_for_querying(array_merge($this->_get_default_where_conditions(), $this->get_where_conditions_provided()), $model_relation_chain);
88
-    }
89
-
90
-
91
-
92
-    /**
93
-     * Gets the default where conditions that are specific to this child of EE_Default_Where_Conditions.
94
-     * Adding model relation chains is handled by the public method get_default_where_conditions
95
-     * @return array
96
-     */
97
-    protected function _get_default_where_conditions()
98
-    {
99
-        return array();
100
-    }
101
-
102
-
103
-
104
-    /**
105
-     * Takes the default query parameters, and traverses them, adding the model relation chain
106
-     * onto them (intelligently doesn't do that to logic query params like NOT, OR, and AND)
107
-     * @param array $where_conditions
108
-     * @param string $model_relation_chain
109
-     * @return array
110
-     * @throws \EE_Error
111
-     */
112
-    public function prepare_where_conditions_for_querying($where_conditions, $model_relation_chain)
113
-    {
114
-        $where_conditions_with_model_relation_chain_prefixes = array();
115
-        if (! is_array($where_conditions)) {
116
-            $where_conditions = array();
117
-        }
118
-        foreach ($where_conditions as $key => $value) {
119
-            if (in_array($key, array( 'OR', 'AND', 'NOT' ))
120
-                || strpos($key, 'OR*') !== false
121
-                || strpos($key, 'AND*') !== false
122
-                || strpos($key, 'NOT*') !== false
123
-            ) {
124
-                $where_conditions_with_model_relation_chain_prefixes[ $key ] = $this->prepare_where_conditions_for_querying(
125
-                    $value,
126
-                    $model_relation_chain
127
-                );
128
-            } else {
129
-                if ($model_relation_chain != ''
130
-                    && $model_relation_chain[ strlen($model_relation_chain) - 1 ] != '.'
131
-                ) {
132
-                    $model_relation_chain = $model_relation_chain . ".";
133
-                }
134
-                // check for the current user id place holder, and if present change it
135
-                if ($value === self::current_user_placeholder) {
136
-                    $value = get_current_user_id();
137
-                }
138
-                // check for user field placeholder
139
-                if ($key == self::user_field_name_placeholder) {
140
-                    if (! $this->_model->wp_user_field_name()) {
141
-                        throw new EE_Error(
142
-                            sprintf(
143
-                                __(
144
-                                    'There is no foreign key to the WP_User model on model %s. Please either modify your default where conditions, add a _model_chain_to_wp_user onto the model, or a proper EE_WP_User_Field onto the model',
145
-                                    'event_espresso'
146
-                                ),
147
-                                $this->_model->get_this_model_name()
148
-                            )
149
-                        );
150
-                    }
151
-                    $key = $this->_model->wp_user_field_name();
152
-                }
153
-                $where_conditions_with_model_relation_chain_prefixes[ $model_relation_chain . $key ] = $value;
154
-            }
155
-        }
156
-        return $where_conditions_with_model_relation_chain_prefixes;
157
-    }
19
+	/**
20
+	 * This const can be used in EE_Default_Where_Conditions values, and at the time of querying it will be
21
+	 * replaced with the current user's ID (because we don't want to use the current user's ID at time of
22
+	 * initializing the models because it's too early)
23
+	 */
24
+	const current_user_placeholder = '%$current_user_placeholder_should_be_replaced_automatically$%';
25
+
26
+	/**
27
+	 * This const can be used in EE_Default_Where_Conditions where parameters as the name
28
+	 * of the user field. When we are actually generating the where conditions it will be
29
+	 * replaced with the model's wp user fieldname
30
+	 */
31
+	const user_field_name_placeholder = '%$user_field_name_placeholder$%';
32
+
33
+	/**
34
+	 * Model for which this strategy find default where conditions
35
+	 * @var EEM_Base
36
+	 */
37
+	protected $_model;
38
+
39
+	/**
40
+	 * Where conditions specified on construction
41
+	 * @var array
42
+	 */
43
+	protected $_where_conditions_provided = array();
44
+
45
+	/**
46
+	 * Custom where conditions. Model relation chains will be automatically added
47
+	 * onto any field names
48
+	 * @param array $custom_where_conditions
49
+	 */
50
+	public function __construct($custom_where_conditions = array())
51
+	{
52
+		$this->_where_conditions_provided = $custom_where_conditions;
53
+	}
54
+
55
+
56
+
57
+	/**
58
+	 * finalizes construction of the strategy for use in getting default where conditions
59
+	 * for querying of the model.
60
+	 * @param EEM_Base $model
61
+	 */
62
+	public function _finalize_construct(EEM_Base $model)
63
+	{
64
+		$this->_model = $model;
65
+	}
66
+
67
+
68
+
69
+	/**
70
+	 * Returns the where conditions explicitly passed in the constructor
71
+	 * @return array
72
+	 */
73
+	public function get_where_conditions_provided()
74
+	{
75
+		return $this->_where_conditions_provided;
76
+	}
77
+
78
+
79
+
80
+	/**
81
+	 * Gets the where conditions to be added onto the query
82
+	 * @param string $model_relation_chain
83
+	 * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
84
+	 */
85
+	public function get_default_where_conditions($model_relation_chain = '')
86
+	{
87
+		return $this->prepare_where_conditions_for_querying(array_merge($this->_get_default_where_conditions(), $this->get_where_conditions_provided()), $model_relation_chain);
88
+	}
89
+
90
+
91
+
92
+	/**
93
+	 * Gets the default where conditions that are specific to this child of EE_Default_Where_Conditions.
94
+	 * Adding model relation chains is handled by the public method get_default_where_conditions
95
+	 * @return array
96
+	 */
97
+	protected function _get_default_where_conditions()
98
+	{
99
+		return array();
100
+	}
101
+
102
+
103
+
104
+	/**
105
+	 * Takes the default query parameters, and traverses them, adding the model relation chain
106
+	 * onto them (intelligently doesn't do that to logic query params like NOT, OR, and AND)
107
+	 * @param array $where_conditions
108
+	 * @param string $model_relation_chain
109
+	 * @return array
110
+	 * @throws \EE_Error
111
+	 */
112
+	public function prepare_where_conditions_for_querying($where_conditions, $model_relation_chain)
113
+	{
114
+		$where_conditions_with_model_relation_chain_prefixes = array();
115
+		if (! is_array($where_conditions)) {
116
+			$where_conditions = array();
117
+		}
118
+		foreach ($where_conditions as $key => $value) {
119
+			if (in_array($key, array( 'OR', 'AND', 'NOT' ))
120
+				|| strpos($key, 'OR*') !== false
121
+				|| strpos($key, 'AND*') !== false
122
+				|| strpos($key, 'NOT*') !== false
123
+			) {
124
+				$where_conditions_with_model_relation_chain_prefixes[ $key ] = $this->prepare_where_conditions_for_querying(
125
+					$value,
126
+					$model_relation_chain
127
+				);
128
+			} else {
129
+				if ($model_relation_chain != ''
130
+					&& $model_relation_chain[ strlen($model_relation_chain) - 1 ] != '.'
131
+				) {
132
+					$model_relation_chain = $model_relation_chain . ".";
133
+				}
134
+				// check for the current user id place holder, and if present change it
135
+				if ($value === self::current_user_placeholder) {
136
+					$value = get_current_user_id();
137
+				}
138
+				// check for user field placeholder
139
+				if ($key == self::user_field_name_placeholder) {
140
+					if (! $this->_model->wp_user_field_name()) {
141
+						throw new EE_Error(
142
+							sprintf(
143
+								__(
144
+									'There is no foreign key to the WP_User model on model %s. Please either modify your default where conditions, add a _model_chain_to_wp_user onto the model, or a proper EE_WP_User_Field onto the model',
145
+									'event_espresso'
146
+								),
147
+								$this->_model->get_this_model_name()
148
+							)
149
+						);
150
+					}
151
+					$key = $this->_model->wp_user_field_name();
152
+				}
153
+				$where_conditions_with_model_relation_chain_prefixes[ $model_relation_chain . $key ] = $value;
154
+			}
155
+		}
156
+		return $where_conditions_with_model_relation_chain_prefixes;
157
+	}
158 158
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Restriction_Generator_Global.strategy.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -20,47 +20,47 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
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.
core/db_models/strategies/EE_Restriction_Generator_Protected.strategy.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -25,48 +25,48 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
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.
core/db_models/strategies/EE_Restriction_Generator_Meta.strategy.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -14,60 +14,60 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
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.