Completed
Branch EDTR/input-labels (73d1b5)
by
unknown
11:26 queued 01:08
created
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.
core/db_models/strategies/EE_Restriction_Generator_Reg_Form.strategy.php 2 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -15,51 +15,51 @@
 block discarded – undo
15 15
 class EE_Restriction_Generator_Reg_Form extends EE_Restriction_Generator_Base
16 16
 {
17 17
 
18
-    /**
19
-     *
20
-     * @var string the name of the field that indicates whether or not this is a system thing
21
-     */
22
-    protected $_system_field_name = null;
18
+	/**
19
+	 *
20
+	 * @var string the name of the field that indicates whether or not this is a system thing
21
+	 */
22
+	protected $_system_field_name = null;
23 23
 
24
-    /**
25
-     * Accepts the name of the field that indicates whether or not an object is a "system" one or not
26
-     * @param string $system_field_name
27
-     */
28
-    public function __construct($system_field_name)
29
-    {
30
-        $this->_system_field_name = $system_field_name;
31
-    }
24
+	/**
25
+	 * Accepts the name of the field that indicates whether or not an object is a "system" one or not
26
+	 * @param string $system_field_name
27
+	 */
28
+	public function __construct($system_field_name)
29
+	{
30
+		$this->_system_field_name = $system_field_name;
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     *
36
-     * @return \EE_Default_Where_Conditions[]
37
-     * @throws EE_Error
38
-     */
39
-    protected function _generate_restrictions()
40
-    {
41
-        // if there are no standard caps for this model, then for now all we know
42
-        // if they need the default cap to access this
43
-        if (! $this->model()->cap_slug()) {
44
-            return array(
45
-                EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions()
46
-            );
47
-        }
48
-        $restrictions = array(
49
-            EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Return_None_Where_Conditions(),
50
-        );
51
-        // there is no "ee_read_system_questions" cap; in order to read reg form items you only need "ee_read_{model_name}".
52
-        // there is also no "ee_delete_system_questions" cap. But folks shouldn't be deleting system questions anyway
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(
55
-                array(
56
-                    'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_system') => array(
57
-                        $this->_system_field_name       => array('IN', array('', 0)),
58
-                        $this->_system_field_name . '*' => array('IS_NULL')
59
-                    )
60
-                )
61
-            );
62
-        }
63
-        return $restrictions;
64
-    }
34
+	/**
35
+	 *
36
+	 * @return \EE_Default_Where_Conditions[]
37
+	 * @throws EE_Error
38
+	 */
39
+	protected function _generate_restrictions()
40
+	{
41
+		// if there are no standard caps for this model, then for now all we know
42
+		// if they need the default cap to access this
43
+		if (! $this->model()->cap_slug()) {
44
+			return array(
45
+				EE_Restriction_Generator_Base::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions()
46
+			);
47
+		}
48
+		$restrictions = array(
49
+			EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Return_None_Where_Conditions(),
50
+		);
51
+		// there is no "ee_read_system_questions" cap; in order to read reg form items you only need "ee_read_{model_name}".
52
+		// there is also no "ee_delete_system_questions" cap. But folks shouldn't be deleting system questions anyway
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(
55
+				array(
56
+					'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_system') => array(
57
+						$this->_system_field_name       => array('IN', array('', 0)),
58
+						$this->_system_field_name . '*' => array('IS_NULL')
59
+					)
60
+				)
61
+			);
62
+		}
63
+		return $restrictions;
64
+	}
65 65
 }
Please login to merge, or discard this patch.
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.
strategies/EE_Restriction_Generator_Default_Protected.strategy.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -17,85 +17,85 @@
 block discarded – undo
17 17
  */
18 18
 class EE_Restriction_Generator_Default_Protected extends EE_Restriction_Generator_Base
19 19
 {
20
-    /**
21
-     * Name of the field on this model (or a related model, including the model chain to it)
22
-     * that is a boolean indicating whether or not a model object is considered "Default" or not
23
-     * @var string
24
-     */
25
-    protected $_default_field_name;
20
+	/**
21
+	 * Name of the field on this model (or a related model, including the model chain to it)
22
+	 * that is a boolean indicating whether or not a model object is considered "Default" or not
23
+	 * @var string
24
+	 */
25
+	protected $_default_field_name;
26 26
 
27
-    /**
28
-     * The model chain to follow to get to the event model, including the event model itself.
29
-     * Eg 'Ticket.Datetime.Event'
30
-     * @var string
31
-     */
32
-    protected $_path_to_event_model;
33
-    /**
34
-     *
35
-     * @param string $default_field_name the name of the field Name of the field on this model (or a related model, including the model chain to it)
36
-     * that is a boolean indicating whether or not a model object is considered "Default" or not
37
-     * @param string $path_to_event_model The model chain to follow to get to the event model, including the event model itself.
38
-     * Eg 'Ticket.Datetime.Event'
39
-     */
40
-    public function __construct($default_field_name, $path_to_event_model)
41
-    {
42
-        $this->_default_field_name = $default_field_name;
43
-        if (substr($path_to_event_model, -1, 1) != '.') {
44
-            $path_to_event_model .= '.';
45
-        }
46
-        $this->_path_to_event_model = $path_to_event_model;
47
-    }
27
+	/**
28
+	 * The model chain to follow to get to the event model, including the event model itself.
29
+	 * Eg 'Ticket.Datetime.Event'
30
+	 * @var string
31
+	 */
32
+	protected $_path_to_event_model;
33
+	/**
34
+	 *
35
+	 * @param string $default_field_name the name of the field Name of the field on this model (or a related model, including the model chain to it)
36
+	 * that is a boolean indicating whether or not a model object is considered "Default" or not
37
+	 * @param string $path_to_event_model The model chain to follow to get to the event model, including the event model itself.
38
+	 * Eg 'Ticket.Datetime.Event'
39
+	 */
40
+	public function __construct($default_field_name, $path_to_event_model)
41
+	{
42
+		$this->_default_field_name = $default_field_name;
43
+		if (substr($path_to_event_model, -1, 1) != '.') {
44
+			$path_to_event_model .= '.';
45
+		}
46
+		$this->_path_to_event_model = $path_to_event_model;
47
+	}
48 48
 
49 49
 
50 50
 
51
-    /**
52
-     *
53
-     * @return \EE_Default_Where_Conditions
54
-     */
55
-    protected function _generate_restrictions()
56
-    {
57
-        // if there are no standard caps for this model, then for now all we know is
58
-        // if they need the default cap to access this
59
-        if (! $this->model()->cap_slug()) {
60
-            return array(
61
-                self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions()
62
-            );
63
-        }
51
+	/**
52
+	 *
53
+	 * @return \EE_Default_Where_Conditions
54
+	 */
55
+	protected function _generate_restrictions()
56
+	{
57
+		// if there are no standard caps for this model, then for now all we know is
58
+		// if they need the default cap to access this
59
+		if (! $this->model()->cap_slug()) {
60
+			return array(
61
+				self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions()
62
+			);
63
+		}
64 64
 
65
-        $event_model = EEM_Event::instance();
65
+		$event_model = EEM_Event::instance();
66 66
 
67
-        $restrictions =  array(
68
-            // first: basically access to non-defaults is essentially controlled by which events are accessible
69
-            // if they don't have the basic event cap, they can't access ANY non-default items
70
-            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions(array( $this->_default_field_name => true )),
71
-            // if they don't have the others event cap, they can't access others' non-default items
72
-            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => new EE_Default_Where_Conditions(array(
73
-                'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => array(
74
-                    $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder ),
75
-                    $this->_default_field_name => true )),
76
-            // if they have basic and others, but not private, they can't access others' private non-default items
77
-            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions(array(
78
-                'OR*no_' .EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => array(
79
-                $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder,
80
-                $this->_path_to_event_model . 'status' => array( '!=', 'private' ),
81
-                $this->_default_field_name => true ) )),
82
-            // second: access to defaults is controlled by the defaulty capabilities
83
-            // if they don't have the default capability, restrict access to only non-default items
84
-            EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_default') => new EE_Default_Where_Conditions(array( $this->_default_field_name => false )),
85
-            // if they don't have the "others" default capability, restrict access to only their default ones, and non-default ones
86
-             );
87
-        if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others_default')) {
88
-            $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') ] = new EE_Default_Where_Conditions(array(
89
-                    // if they don't have the others default cap, they can't access others default items (but they can access
90
-                    // their own default items, and non-default items)
91
-                    'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') => array(
92
-                        'AND' => array(
93
-                            $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder,
94
-                            $this->_default_field_name => true
95
-                            ),
96
-                        $this->_default_field_name => false
97
-                    ) ));
98
-        }
99
-        return $restrictions;
100
-    }
67
+		$restrictions =  array(
68
+			// first: basically access to non-defaults is essentially controlled by which events are accessible
69
+			// if they don't have the basic event cap, they can't access ANY non-default items
70
+			EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions(array( $this->_default_field_name => true )),
71
+			// if they don't have the others event cap, they can't access others' non-default items
72
+			EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => new EE_Default_Where_Conditions(array(
73
+				'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => array(
74
+					$this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder ),
75
+					$this->_default_field_name => true )),
76
+			// if they have basic and others, but not private, they can't access others' private non-default items
77
+			EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions(array(
78
+				'OR*no_' .EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => array(
79
+				$this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder,
80
+				$this->_path_to_event_model . 'status' => array( '!=', 'private' ),
81
+				$this->_default_field_name => true ) )),
82
+			// second: access to defaults is controlled by the defaulty capabilities
83
+			// if they don't have the default capability, restrict access to only non-default items
84
+			EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_default') => new EE_Default_Where_Conditions(array( $this->_default_field_name => false )),
85
+			// if they don't have the "others" default capability, restrict access to only their default ones, and non-default ones
86
+			 );
87
+		if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others_default')) {
88
+			$restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') ] = new EE_Default_Where_Conditions(array(
89
+					// if they don't have the others default cap, they can't access others default items (but they can access
90
+					// their own default items, and non-default items)
91
+					'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') => array(
92
+						'AND' => array(
93
+							$this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder,
94
+							$this->_default_field_name => true
95
+							),
96
+						$this->_default_field_name => false
97
+					) ));
98
+		}
99
+		return $restrictions;
100
+	}
101 101
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     {
57 57
         // if there are no standard caps for this model, then for now all we know is
58 58
         // if they need the default cap to access this
59
-        if (! $this->model()->cap_slug()) {
59
+        if ( ! $this->model()->cap_slug()) {
60 60
             return array(
61 61
                 self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions()
62 62
             );
@@ -64,33 +64,33 @@  discard block
 block discarded – undo
64 64
 
65 65
         $event_model = EEM_Event::instance();
66 66
 
67
-        $restrictions =  array(
67
+        $restrictions = array(
68 68
             // first: basically access to non-defaults is essentially controlled by which events are accessible
69 69
             // if they don't have the basic event cap, they can't access ANY non-default items
70
-            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions(array( $this->_default_field_name => true )),
70
+            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions(array($this->_default_field_name => true)),
71 71
             // if they don't have the others event cap, they can't access others' non-default items
72
-            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => new EE_Default_Where_Conditions(array(
73
-                'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_others') => array(
74
-                    $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder ),
72
+            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action().'_others') => new EE_Default_Where_Conditions(array(
73
+                'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action().'_others') => array(
74
+                    $this->_path_to_event_model.'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder ),
75 75
                     $this->_default_field_name => true )),
76 76
             // if they have basic and others, but not private, they can't access others' private non-default items
77
-            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions(array(
78
-                'OR*no_' .EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action() . '_private') => array(
79
-                $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder,
80
-                $this->_path_to_event_model . 'status' => array( '!=', 'private' ),
77
+            EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action().'_private') => new EE_Default_Where_Conditions(array(
78
+                'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($event_model, $this->action().'_private') => array(
79
+                $this->_path_to_event_model.'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder,
80
+                $this->_path_to_event_model.'status' => array('!=', 'private'),
81 81
                 $this->_default_field_name => true ) )),
82 82
             // second: access to defaults is controlled by the defaulty capabilities
83 83
             // if they don't have the default capability, restrict access to only non-default items
84
-            EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_default') => new EE_Default_Where_Conditions(array( $this->_default_field_name => false )),
84
+            EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_default') => new EE_Default_Where_Conditions(array($this->_default_field_name => false)),
85 85
             // if they don't have the "others" default capability, restrict access to only their default ones, and non-default ones
86 86
              );
87
-        if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action() . '_others_default')) {
88
-            $restrictions[ EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') ] = new EE_Default_Where_Conditions(array(
87
+        if (EE_Restriction_Generator_Base::is_cap($this->model(), $this->action().'_others_default')) {
88
+            $restrictions[EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_others_default')] = new EE_Default_Where_Conditions(array(
89 89
                     // if they don't have the others default cap, they can't access others default items (but they can access
90 90
                     // their own default items, and non-default items)
91
-                    'OR*no_' . EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action() . '_others_default') => array(
91
+                    'OR*no_'.EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action().'_others_default') => array(
92 92
                         'AND' => array(
93
-                            $this->_path_to_event_model . 'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder,
93
+                            $this->_path_to_event_model.'EVT_wp_user' => EE_Default_Where_Conditions::current_user_placeholder,
94 94
                             $this->_default_field_name => true
95 95
                             ),
96 96
                         $this->_default_field_name => false
Please login to merge, or discard this patch.
core/db_models/strategies/EE_CPT_Where_Conditions.strategy.php 3 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.
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@
 block discarded – undo
16 16
 {
17 17
     /**
18 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 19
      * @return array @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
21 20
      */
22 21
     protected function _get_default_where_conditions()
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
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -13,40 +13,40 @@
 block discarded – undo
13 13
 class EE_Restriction_Generator_Taxonomy_Protected extends EE_Restriction_Generator_Base
14 14
 {
15 15
 
16
-    /**
17
-     * Model chain/path to taxonomy model, including the term_taxonomy model itself
18
-     * @var string
19
-     */
20
-    protected $_path_to_taxonomy_model;
21
-    /**
22
-     *
23
-     * @param string $path_to_taxonomy_model Model chain/path to taxonomy model, including the term_taxonomy model itself
24
-     */
25
-    public function __construct($path_to_taxonomy_model)
26
-    {
27
-        if ($path_to_taxonomy_model !== '' && substr($path_to_taxonomy_model, -1, 1) != '.') {
28
-            $path_to_taxonomy_model .= '.';
29
-        }
30
-        $this->_path_to_taxonomy_model = $path_to_taxonomy_model;
31
-    }
32
-    protected function _generate_restrictions()
33
-    {
34
-        // if there are no standard caps for this model, then for allow full access
35
-        if (! $this->model()->cap_slug()) {
36
-            return array(
37
-            );
38
-        }
16
+	/**
17
+	 * Model chain/path to taxonomy model, including the term_taxonomy model itself
18
+	 * @var string
19
+	 */
20
+	protected $_path_to_taxonomy_model;
21
+	/**
22
+	 *
23
+	 * @param string $path_to_taxonomy_model Model chain/path to taxonomy model, including the term_taxonomy model itself
24
+	 */
25
+	public function __construct($path_to_taxonomy_model)
26
+	{
27
+		if ($path_to_taxonomy_model !== '' && substr($path_to_taxonomy_model, -1, 1) != '.') {
28
+			$path_to_taxonomy_model .= '.';
29
+		}
30
+		$this->_path_to_taxonomy_model = $path_to_taxonomy_model;
31
+	}
32
+	protected function _generate_restrictions()
33
+	{
34
+		// if there are no standard caps for this model, then for allow full access
35
+		if (! $this->model()->cap_slug()) {
36
+			return array(
37
+			);
38
+		}
39 39
 
40
-        return array(
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' )
43
-            )),
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' )
46
-            )),
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' )
49
-            )),
50
-        );
51
-    }
40
+		return array(
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' )
43
+			)),
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' )
46
+			)),
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' )
49
+			)),
50
+		);
51
+	}
52 52
 }
Please login to merge, or discard this patch.
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.
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.
core/db_models/strategies/EE_Restriction_Generator_WP_User.strategy.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,18 +15,18 @@
 block discarded – undo
15 15
 class EE_Restriction_Generator_WP_User extends EE_Restriction_Generator_Base
16 16
 {
17 17
 
18
-    /**
19
-     * @return \EE_Default_Where_Conditions
20
-     */
21
-    protected function _generate_restrictions()
22
-    {
18
+	/**
19
+	 * @return \EE_Default_Where_Conditions
20
+	 */
21
+	protected function _generate_restrictions()
22
+	{
23 23
 
24
-        return array(
25
-            // if they can't access users, they can still access themselves
26
-            EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Default_Where_Conditions(array(
27
-                EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder
28
-            )),
24
+		return array(
25
+			// if they can't access users, they can still access themselves
26
+			EE_Restriction_Generator_Base::get_cap_name($this->model(), $this->action()) => new EE_Default_Where_Conditions(array(
27
+				EE_Default_Where_Conditions::user_field_name_placeholder => EE_Default_Where_Conditions::current_user_placeholder
28
+			)),
29 29
 
30
-        );
31
-    }
30
+		);
31
+	}
32 32
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Question_Option.model.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,39 +11,39 @@
 block discarded – undo
11 11
 class EEM_Question_Option extends EEM_Soft_Delete_Base
12 12
 {
13 13
 
14
-    // private instance of the Attendee object
15
-    protected static $_instance = null;
14
+	// private instance of the Attendee object
15
+	protected static $_instance = null;
16 16
 
17
-    protected function __construct($timezone = null)
18
-    {
19
-        $this->singular_item = __('Question Option', 'event_espresso');
20
-        $this->plural_item = __('Question Options', 'event_espresso');
17
+	protected function __construct($timezone = null)
18
+	{
19
+		$this->singular_item = __('Question Option', 'event_espresso');
20
+		$this->plural_item = __('Question Options', 'event_espresso');
21 21
 
22
-        $this->_tables = array(
23
-            'Question_Option'=>new EE_Primary_Table('esp_question_option', 'QSO_ID')
24
-        );
25
-        $this->_fields = array(
26
-            'Question_Option'=>array(
27
-                    'QSO_ID'=>new EE_Primary_Key_Int_Field('QSO_ID', __('Question Option ID', 'event_espresso')),
28
-                    'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'),
29
-                    'QSO_value'=>new EE_Plain_Text_Field('QSO_value', __("Question Option Value", "event_espresso"), false, ''),
30
-                    'QSO_desc'=>new EE_Post_Content_Field('QSO_desc', __('Question Option Description', 'event_espresso'), false, ''),
31
-                    'QSO_order' => new EE_Integer_Field('QSO_order', __('Question Option Order', 'event_espresso'), false, 0),
32
-                    'QSO_system'=>new EE_Plain_Text_Field('QSO_system', __('Internal string ID for question option', 'event_espresso'), true, null),
33
-                    'QSO_deleted'=>new EE_Trashed_Flag_Field('QSO_deleted', __('Flag indicating Option was trashed', 'event_espresso'), false, false)
34
-                )
35
-        );
36
-        $this->_model_relations = array(
37
-            'Question'=>new EE_Belongs_To_Relation()
38
-        );
22
+		$this->_tables = array(
23
+			'Question_Option'=>new EE_Primary_Table('esp_question_option', 'QSO_ID')
24
+		);
25
+		$this->_fields = array(
26
+			'Question_Option'=>array(
27
+					'QSO_ID'=>new EE_Primary_Key_Int_Field('QSO_ID', __('Question Option ID', 'event_espresso')),
28
+					'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'),
29
+					'QSO_value'=>new EE_Plain_Text_Field('QSO_value', __("Question Option Value", "event_espresso"), false, ''),
30
+					'QSO_desc'=>new EE_Post_Content_Field('QSO_desc', __('Question Option Description', 'event_espresso'), false, ''),
31
+					'QSO_order' => new EE_Integer_Field('QSO_order', __('Question Option Order', 'event_espresso'), false, 0),
32
+					'QSO_system'=>new EE_Plain_Text_Field('QSO_system', __('Internal string ID for question option', 'event_espresso'), true, null),
33
+					'QSO_deleted'=>new EE_Trashed_Flag_Field('QSO_deleted', __('Flag indicating Option was trashed', 'event_espresso'), false, false)
34
+				)
35
+		);
36
+		$this->_model_relations = array(
37
+			'Question'=>new EE_Belongs_To_Relation()
38
+		);
39 39
 
40
-        $this->_model_chain_to_wp_user = 'Question';
41
-        // this model is generally available for reading
42
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
43
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
44
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
45
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
46
-        $this->_caps_slug = 'questions';
47
-        parent::__construct($timezone);
48
-    }
40
+		$this->_model_chain_to_wp_user = 'Question';
41
+		// this model is generally available for reading
42
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
43
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
44
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
45
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
46
+		$this->_caps_slug = 'questions';
47
+		parent::__construct($timezone);
48
+	}
49 49
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,10 +39,10 @@
 block discarded – undo
39 39
 
40 40
         $this->_model_chain_to_wp_user = 'Question';
41 41
         // this model is generally available for reading
42
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
43
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
44
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
45
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSO_system');
42
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
43
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('QSO_system');
44
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('QSO_system');
45
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('QSO_system');
46 46
         $this->_caps_slug = 'questions';
47 47
         parent::__construct($timezone);
48 48
     }
Please login to merge, or discard this patch.
core/db_models/EEM_Answer.model.php 2 patches
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -9,142 +9,142 @@
 block discarded – undo
9 9
 class EEM_Answer extends EEM_Base
10 10
 {
11 11
 
12
-    /**
13
-     * private instance of the EEM_Answer object
14
-     * @type EEM_Answer
15
-     */
16
-    protected static $_instance = null;
12
+	/**
13
+	 * private instance of the EEM_Answer object
14
+	 * @type EEM_Answer
15
+	 */
16
+	protected static $_instance = null;
17 17
 
18
-    /**
19
-     * Mapping from system question ids to attendee field names
20
-     * @type array
21
-     * @deprecated since version 4.8.8
22
-     */
23
-    protected $_question_id_to_att_field_map = array(
24
-        EEM_Attendee::fname_question_id => 'ATT_fname',
25
-        EEM_Attendee::lname_question_id => 'ATT_lname',
26
-        EEM_Attendee::email_question_id => 'ATT_email',
27
-        EEM_Attendee::address_question_id => 'ATT_address',
28
-        EEM_Attendee::address2_question_id => 'ATT_address2',
29
-        EEM_Attendee::city_question_id => 'ATT_city',
30
-        EEM_Attendee::state_question_id => 'STA_ID',
31
-        EEM_Attendee::country_question_id => 'CNT_ISO',
32
-        EEM_Attendee::zip_question_id => 'ATT_zip',
33
-        EEM_Attendee::phone_question_id => 'ATT_phone'
34
-    );
18
+	/**
19
+	 * Mapping from system question ids to attendee field names
20
+	 * @type array
21
+	 * @deprecated since version 4.8.8
22
+	 */
23
+	protected $_question_id_to_att_field_map = array(
24
+		EEM_Attendee::fname_question_id => 'ATT_fname',
25
+		EEM_Attendee::lname_question_id => 'ATT_lname',
26
+		EEM_Attendee::email_question_id => 'ATT_email',
27
+		EEM_Attendee::address_question_id => 'ATT_address',
28
+		EEM_Attendee::address2_question_id => 'ATT_address2',
29
+		EEM_Attendee::city_question_id => 'ATT_city',
30
+		EEM_Attendee::state_question_id => 'STA_ID',
31
+		EEM_Attendee::country_question_id => 'CNT_ISO',
32
+		EEM_Attendee::zip_question_id => 'ATT_zip',
33
+		EEM_Attendee::phone_question_id => 'ATT_phone'
34
+	);
35 35
 
36 36
 
37 37
 
38
-    /**
39
-     *  constructor
40
-     */
41
-    protected function __construct($timezone = null)
42
-    {
43
-        $this->singular_item = __('Answer', 'event_espresso');
44
-        $this->plural_item = __('Answers', 'event_espresso');
45
-        $this->_tables = array(
46
-            'Answer'=> new EE_Primary_Table('esp_answer', 'ANS_ID')
47
-        );
48
-        $this->_fields = array(
49
-            'Answer'=>array(
50
-                'ANS_ID'=> new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID', 'event_espresso')),
51
-                'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'),
52
-                'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'),
53
-                'ANS_value'=>new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value', 'event_espresso'), false, '')
54
-            ));
55
-        $this->_model_relations = array(
56
-            'Registration'=>new EE_Belongs_To_Relation(),
57
-            'Question'=>new EE_Belongs_To_Relation()
58
-        );
59
-        $this->_model_chain_to_wp_user = 'Registration.Event';
60
-        $this->_caps_slug = 'registrations';
61
-        parent::__construct($timezone);
62
-    }
38
+	/**
39
+	 *  constructor
40
+	 */
41
+	protected function __construct($timezone = null)
42
+	{
43
+		$this->singular_item = __('Answer', 'event_espresso');
44
+		$this->plural_item = __('Answers', 'event_espresso');
45
+		$this->_tables = array(
46
+			'Answer'=> new EE_Primary_Table('esp_answer', 'ANS_ID')
47
+		);
48
+		$this->_fields = array(
49
+			'Answer'=>array(
50
+				'ANS_ID'=> new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID', 'event_espresso')),
51
+				'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'),
52
+				'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'),
53
+				'ANS_value'=>new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value', 'event_espresso'), false, '')
54
+			));
55
+		$this->_model_relations = array(
56
+			'Registration'=>new EE_Belongs_To_Relation(),
57
+			'Question'=>new EE_Belongs_To_Relation()
58
+		);
59
+		$this->_model_chain_to_wp_user = 'Registration.Event';
60
+		$this->_caps_slug = 'registrations';
61
+		parent::__construct($timezone);
62
+	}
63 63
 
64 64
 
65 65
 
66
-    /**
67
-     * Gets the string answer to the question for this registration (it could either be stored
68
-     * on the attendee or in the answer table. This function finds its value regardless)
69
-     * @param EE_Registration $registration
70
-     * @param int $question_id
71
-     * @param boolean $pretty_answer whether to call 'pretty_value' or just 'value'
72
-     * @return string
73
-     */
74
-    public function get_answer_value_to_question(EE_Registration $registration, $question_id = null, $pretty_answer = false)
75
-    {
76
-        $value = $this->get_attendee_property_answer_value($registration, $question_id, $pretty_answer);
77
-        if ($value === null) {
78
-            $answer_obj = $this->get_registration_question_answer_object($registration, $question_id);
79
-            if ($answer_obj instanceof EE_Answer) {
80
-                if ($pretty_answer) {
81
-                    $value = $answer_obj->pretty_value();
82
-                } else {
83
-                    $value = $answer_obj->value();
84
-                }
85
-            }
86
-        }
87
-        return apply_filters('FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id);
88
-    }
66
+	/**
67
+	 * Gets the string answer to the question for this registration (it could either be stored
68
+	 * on the attendee or in the answer table. This function finds its value regardless)
69
+	 * @param EE_Registration $registration
70
+	 * @param int $question_id
71
+	 * @param boolean $pretty_answer whether to call 'pretty_value' or just 'value'
72
+	 * @return string
73
+	 */
74
+	public function get_answer_value_to_question(EE_Registration $registration, $question_id = null, $pretty_answer = false)
75
+	{
76
+		$value = $this->get_attendee_property_answer_value($registration, $question_id, $pretty_answer);
77
+		if ($value === null) {
78
+			$answer_obj = $this->get_registration_question_answer_object($registration, $question_id);
79
+			if ($answer_obj instanceof EE_Answer) {
80
+				if ($pretty_answer) {
81
+					$value = $answer_obj->pretty_value();
82
+				} else {
83
+					$value = $answer_obj->value();
84
+				}
85
+			}
86
+		}
87
+		return apply_filters('FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id);
88
+	}
89 89
 
90 90
 
91 91
 
92
-    /**
93
-     * Gets the EE_Answer object for the question for this registration (if it exists)
94
-     * @param EE_Registration $registration
95
-     * @param int $question_id
96
-     * @return EE_Answer
97
-     */
98
-    public function get_registration_question_answer_object(EE_Registration $registration, $question_id = null)
99
-    {
100
-        $answer_obj = $this->get_one(array( array( 'QST_ID'=>$question_id, 'REG_ID'=>$registration->ID() )));
101
-        return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id);
102
-    }
92
+	/**
93
+	 * Gets the EE_Answer object for the question for this registration (if it exists)
94
+	 * @param EE_Registration $registration
95
+	 * @param int $question_id
96
+	 * @return EE_Answer
97
+	 */
98
+	public function get_registration_question_answer_object(EE_Registration $registration, $question_id = null)
99
+	{
100
+		$answer_obj = $this->get_one(array( array( 'QST_ID'=>$question_id, 'REG_ID'=>$registration->ID() )));
101
+		return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id);
102
+	}
103 103
 
104 104
 
105 105
 
106
-    /**
107
-     * Gets the string answer to the question for this registration's attendee
108
-     * @param EE_Registration $registration
109
-     * @param int|string $question_system_id if an INT this is understood to be the question's ID; if a string then it should be its QST_system value.
110
-     *  Passing in the QST_system value is more efficient
111
-     * @param boolean $pretty_answer
112
-     * @return string|null (if the registration has no attendee, or the question_system_id is not a QST_ID or QST_system for
113
-     * a question corresponding to an attendee field, returns null)
114
-     */
115
-    public function get_attendee_property_answer_value(EE_Registration $registration, $question_system_id = null, $pretty_answer = false)
116
-    {
117
-        $field_name = null;
118
-        $value = null;
119
-                // backward compat: we still want to find the question's ID
120
-        if (is_numeric($question_system_id)) {
121
-            // find this question's QST_system value
122
-            $question_id = $question_system_id;
123
-            $question_system_id = EEM_Question::instance()->get_var(array( array( 'QST_ID' => $question_system_id ) ), 'QST_system');
124
-        } else {
125
-            $question_id = (int) EEM_Question::instance()->get_var(array( array( 'QST_system' => $question_system_id ) ), 'QST_ID');
126
-        }
127
-        // only bother checking if the registration has an attendee
128
-        if ($registration->attendee() instanceof EE_Attendee) {
129
-            $field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question($question_system_id);
130
-            if ($field_name) {
131
-                if ($pretty_answer) {
132
-                    if ($field_name === 'STA_ID') {
133
-                        $state = $registration->attendee()->state_obj();
134
-                        $value = $state instanceof EE_State ? $state->name() : sprintf(__('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID());
135
-                    } elseif ($field_name === 'CNT_ISO') {
136
-                        $country = $registration->attendee()->country_obj();
137
-                        $value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"), $registration->attendee()->country_ID());
138
-                    } else {
139
-                        $value = $registration->attendee()->get_pretty($field_name);
140
-                    }
141
-                    // if field name is blank, leave the value as null too
142
-                } else {
143
-                    $value = $registration->attendee()->get($field_name);
144
-                }
145
-            }
146
-            // if no field was found, leave value blank
147
-        }
148
-        return apply_filters('FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id);
149
-    }
106
+	/**
107
+	 * Gets the string answer to the question for this registration's attendee
108
+	 * @param EE_Registration $registration
109
+	 * @param int|string $question_system_id if an INT this is understood to be the question's ID; if a string then it should be its QST_system value.
110
+	 *  Passing in the QST_system value is more efficient
111
+	 * @param boolean $pretty_answer
112
+	 * @return string|null (if the registration has no attendee, or the question_system_id is not a QST_ID or QST_system for
113
+	 * a question corresponding to an attendee field, returns null)
114
+	 */
115
+	public function get_attendee_property_answer_value(EE_Registration $registration, $question_system_id = null, $pretty_answer = false)
116
+	{
117
+		$field_name = null;
118
+		$value = null;
119
+				// backward compat: we still want to find the question's ID
120
+		if (is_numeric($question_system_id)) {
121
+			// find this question's QST_system value
122
+			$question_id = $question_system_id;
123
+			$question_system_id = EEM_Question::instance()->get_var(array( array( 'QST_ID' => $question_system_id ) ), 'QST_system');
124
+		} else {
125
+			$question_id = (int) EEM_Question::instance()->get_var(array( array( 'QST_system' => $question_system_id ) ), 'QST_ID');
126
+		}
127
+		// only bother checking if the registration has an attendee
128
+		if ($registration->attendee() instanceof EE_Attendee) {
129
+			$field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question($question_system_id);
130
+			if ($field_name) {
131
+				if ($pretty_answer) {
132
+					if ($field_name === 'STA_ID') {
133
+						$state = $registration->attendee()->state_obj();
134
+						$value = $state instanceof EE_State ? $state->name() : sprintf(__('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID());
135
+					} elseif ($field_name === 'CNT_ISO') {
136
+						$country = $registration->attendee()->country_obj();
137
+						$value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"), $registration->attendee()->country_ID());
138
+					} else {
139
+						$value = $registration->attendee()->get_pretty($field_name);
140
+					}
141
+					// if field name is blank, leave the value as null too
142
+				} else {
143
+					$value = $registration->attendee()->get($field_name);
144
+				}
145
+			}
146
+			// if no field was found, leave value blank
147
+		}
148
+		return apply_filters('FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id);
149
+	}
150 150
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function get_registration_question_answer_object(EE_Registration $registration, $question_id = null)
99 99
     {
100
-        $answer_obj = $this->get_one(array( array( 'QST_ID'=>$question_id, 'REG_ID'=>$registration->ID() )));
100
+        $answer_obj = $this->get_one(array(array('QST_ID'=>$question_id, 'REG_ID'=>$registration->ID())));
101 101
         return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id);
102 102
     }
103 103
 
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
         if (is_numeric($question_system_id)) {
121 121
             // find this question's QST_system value
122 122
             $question_id = $question_system_id;
123
-            $question_system_id = EEM_Question::instance()->get_var(array( array( 'QST_ID' => $question_system_id ) ), 'QST_system');
123
+            $question_system_id = EEM_Question::instance()->get_var(array(array('QST_ID' => $question_system_id)), 'QST_system');
124 124
         } else {
125
-            $question_id = (int) EEM_Question::instance()->get_var(array( array( 'QST_system' => $question_system_id ) ), 'QST_ID');
125
+            $question_id = (int) EEM_Question::instance()->get_var(array(array('QST_system' => $question_system_id)), 'QST_ID');
126 126
         }
127 127
         // only bother checking if the registration has an attendee
128 128
         if ($registration->attendee() instanceof EE_Attendee) {
Please login to merge, or discard this patch.